The Extraction Script

One of my more recent projects is a new literary magazine. Part of the process is reading submissions. As a poet myself, I know a lot of poets. To mitigate this fact, I wanted to read the submitted poems blinded. Part of my solution was to set very strict submission guidelines. But as it turns out, e-mails have author information on them. So I wrote a little script to extract submissions from my inbox and put them into Google Drive, where I could read them without any of the e-mail information. I got some interest in the script, so I decided to post the code.

function downloadSubmissions() {
  // ‘Submissions’ is the name of the Gmail label
  // that is automatically applied to incoming submissions.
  // You can use any label here.
  // See also: API reference.
  var label = GmailApp.getUserLabelByName(‘Submissions’);
  var threads = label.getThreads();

  // Again, this is the name of the Drive folder
  // where I want to put documents. Change it to suit you.
  var folder = DocsList.getFolder(‘Submissions’);

  // Loop through all the threads in the label.
  for (var i = 0; i < threads.length; i++) {     var messages = threads[i].getMessages();     // If the most recent message is unread...     var currentMessage = messages[messages.length-1];     if (currentMessage.isUnread()) {       // ... move it's attachments to the folder.       var attachments = currentMessage.getAttachments();       for (var j = 0; j < attachments.length; j++) {         var file = DocsList.createFile(             attachments[j].copyBlob());         file.addToFolder(folder);       }     }     // Mark the message as read so that we don't     // process it twice.     currentMessage.markRead();   } };

This code is a Google Apps script. If you don’t know what that means, you can read a little more about it here. Otherwise, enjoy. Feel free to leave questions or comments.

Bathroom Light Mark I


I have been thinking about getting into Arduinos for a long time. A friend told me about them years ago and I since have been looking for an excuse to start playing with them. Grad school did well at interfering with this desire. Now, though, I have a bit of free time and a bit of disposable income. All I needed was a project.

My girlfriend has roommates and shares a bathroom. For her, discovering that the bathroom is occupied is currently an enormous waste of time. The impetus behind my first project, then, is to create a light in her room that turns on when the bathroom is occupied, saving her the trouble of a trip.

Mark I

I won’t go into immense detail here. First of all, I have no real inclination to catalogue every passing change I made. I would like this blog to more catalog my progress. Certainly if someone is interested (ha) then I am willing to expound; it’s not necessary for me. But perhaps more pertinently, this circuit is not all that interesting. Bathroom Light Mark I was my Hello World! project.

So here we are.

The first iteration of my Bathroom Light project.

The first iteration of my Bathroom Light project.

Right now, the Arudino is hooked into a breadboard. The breadboard is holding two components: a Hall Effect sensor that was kindly donated by a coworker (far left of the breadboard) and a tiny red LED light (far right). When a magnet is placed near the Hall Effect sensor, it senses the Hall Effect (whatever that is… I’m not big on physics), and relays that signal to the Arudino, which in turn lights up the LED. A magnet turns the light on.

This is a very simple version of what I envision for the bathroom. I intend to mount the sensor on the doorframe and a magnet on the door. When the door is closed, the magnet will be in close proximity to the sensor, and can trigger an alert light.

I’ve got a long way to go, obviously, but this felt like an achievement stable enough to christen Mark I. Plus I just got a box full of new parts and I wanted to document the milestone before disassembling it in favor of a more intricate system.

The Return

Apparently I never deleted WordPress from the Think… Or Else servers. This is good. It makes it much easier to bootstrap this blog once again. I don’t know what will come of it. I’m not entirely optimistic. Past efforts have failed, some spectacularly and some quietly. In any case, I have started tinkering with some hobbyist electronics, namely an Arduino board. I thought it might be personally useful—if not particularly interesting—to blog about my developments.

So… that is what I will be doing. Keep posted. Or not. Either way, really.