Projects: I Need Them

Yesterday, I went to McGill’s Tech Fair. All manner of companies were there, scouting talent and taking applications, looking for young students who need jobs. Needless to say, they found plenty, and I was one of them.

It was the first time I had ever been to the Tech Fair, and I wasn’t entirely sure what to expect. I’ve been told my CV is impressive, but I didn’t know what companies would be looking for, or even what – exactly – I was looking for. Among the myriad mining companies (I counted around three gold mining companies) and engineering firms, I managed to find a few software companies that interested me. I chatted, asked questions, and tried to make myself seem knowledgeable, curious, and passionate. The one question I wasn’t prepared for, however, was the question I expected to be the most prepared for: what projects have you done lately?

I’ve always thought of myself as someone who does projects. I’ve always done projects. Ever since I was a kid, I’ve been building things, even to the detriment of my own schooling. I have all but four volumes of Make Magazine that have ever been published. MacGyver is my hero. On any given day, I would rather code for five hours on one of my own projects than for one hour on an assignment for school, and yet I couldn’t think of a single project that I have done recently for my own interest, and of my own volition.

This realization has been a long time coming, I think. School and extracurricular activities (read: work) have sucked up a lot of the time I would ordinarily spend hacking and coding. And when I’m not studying or working, I’m usually too lazy and worn out to start working on something else. Sure, I’ve written some little programs here and there on the weekends or over the summer – coding is a part of life for me – but I haven’t really built any of the super cool, outlandish, crazy awesome projects that I used to build when I was younger and cared less about school. And that’s a shame.

So today is when it changes. This evening, I’m going to blow a TON of time that I could be spending on a DOZEN other things, writing a program that I’ve wanted to write for a few weeks. I’m not going to finish it tonight – I may not even finish it in a week, a month, or a year – but I’m going to start it, and I’m going to have fun. I’m going to tap into my passion again: I’m going to focus on what’s important.

Advertisements

Valentine’s Day 2013: What Twitter Thinks About Love

Every year, I create some sort of computer art project for Valentine’s Day. This year, I created another video, and I think this may be the coolest one yet.

Two years ago, my video was an attempt at capturing the spirit of valentine’s day by processing a video I took on my bus ride to school. I wanted to go back to that theme this year, but the whole “searching for colors thing” was played out. This year, I decided to get my computer to describe love.

Basically, I had my computer suck down every tweet on Twitter for a certain time period that had the word “love” in it, and then processed it, looking for the most common chains of words. I did this using a method called Bigram Probability, which basically calculates the probability of one word coming after another in a sentence. The more often the word “you” comes after the word “love”, the higher the probability assigned to the word “you” coming after “love.” It’s simple enough, but it produced some beautiful results.

Because of this method’s simplicity, I had to do a little “post processing,” which involved taking out the garbage sentences that the program produced. In the end, this became “picking the good ones.” Now, that’s not to say that I’m only picking the cute ones. No no, I’m picking the ones that are grammatically correct; the computer is doing the cute all by itself. Or rather, Twitter is.

Then I shot some video of a hike to the top of the mountain (story after the video,) added the text over it, and set the whole thing to some awesome music by Broke For Free that I found on Free Music Archive.org.

Before we get to the video, let’s have some stats. Of all the words the computer processed, the most common (other than love, which was the search query,) was “I”, and the next most common was “you.” Starting with “I”, the sentence with the highest probability was “I love you”. (D’awwwww.) The most common word after “you” was “love,” but if we ignore that one (because it creates an infinitely cute loop of infinite “love you”s),* the next most common sentence was “I love you too.” And if you think it’s cute that the sentences with the highest probability resulting from a search for the word “love” on Twitter are “I love you” and “I love you too,” wait until you see the ones I used in the video.

Note that the video is a bit shaky. If I had a better camera and/or a Steadycam, I might have been able to record more stable footage, and track the text better. The music is by Broke for Free.

A Story

As I walked up the mountain, I was honestly worried that the video would be a little boring. The computery stuff is cool, and I love playing with video editing sofware, but my idea for the background footage seemed a bit boring. Fate brought me the heart-shaped balloons in the trees, which I thought was a pretty cool end to my journey. But actually, that was the beginning of a different, far more exciting journey.

Coming from the direction of the heart-shaped balloons (make of that, symbolically speaking, what you will,) I heard the song “If I Had a Million Dollars” by the Barenaked Ladies. It seemed to be coming from the woods, but I had no idea who would be playing music that loudly near the park. I thought about trying to find it, and then decided against it. As I was leaving the great patio that forms the lookout on the mountain, something turned me back. Where’s my spirit of adventure, I thought to myself. So I turned about face, and I went in search of the music.

Because I value the integrity of my limbs, I decided against filming my hike through the woods and snow, which took place entirely off the paths in the park that are maintained during the winter (the first thing I did was boot-ski down a staircase that was “closed for the winter”) and mostly off the few paths beaten into the snow by other daring travelers.

I ran through the woods, slid down slopes, and hung on to trees. It was an exhilarating feeling. I’ve always loved running through the woods, and I haven’t done it in a long time. Every so often I would stop, prick my ears, and listen for the music. Sometimes it would fade out, and I had to try to head toward where I thought it had been the last time. My best guess is that someone had set up an outdoor skating rink, as towns and schools commonly do in Quebec during the winter, and that they were playing music for people skate to. But I didn’t come across a skating rink.

Eventually, I reached the road. There was no sign of the music, or where it was coming from. I knew where I was, and I had an appointment in an hour and a half, and I thought I’d head back. The adventure was fun, and I had gotten something out of my search, even if I hadn’t solved my puzzle. So I started walking home, and after a block or so, the music piped up again. It was louder this time. I could tell that it was bouncing off the buildings, so it was hard to say exactly where it was coming from. I hesitated, then took my best guess and started after it again. As I walked down the street, the music got louder, and louder, and louder, until I could finally see where it was coming from.

It was coming from a protest at the Montreal General Hospital. One of the unions there is on strike, and they were picketing and playing music. My mystery music was coming from an amp strapped to the back of a pickup truck. The mystery was solved.

It’s amazing how, sometimes, if you look hard enough, life gives you exactly what you want. I was cranky that day, my mood sharpened by not wanting to get out of bed, and my usual frustration with the commercial assumption that all people everywhere are paired off on Valentine’s Day. Something was telling me, right before I had started my trek, that life was holding out exactly what I needed at that moment. And whether you believe in fate, God, synchronicity, or probability, I felt that one or all of them were giving me an opportunity; a free pass to improve my mood and learn something.

The lesson I learned (or relearned) is this: what you’re looking for is out there somewhere. It applies very well to those of us who are single during this season, and to love, but it also applies more generally to any other pursuit in life. You’ll hit rough patches, you’ll get lost, you’ll have fun, you’ll face adversity, and maybe you’ll even give up a few times, but if you keep your ear to the ground and your goal in mind, you’ll find what you’re looking for eventually.

*Those familiar with bigram probabilities will probably realize that there shouldn’t be repeats. However, the data structure I used to store the bigram probabilities made the usual manner of iteration somewhat difficult, and I wanted to allow some repeats.

How to Heat Your Livingroom with Computers

It’s time I explained what all this cluster computer stuff is about. It’s kind of an insane project, but bare with me. Some of you may have played the Wikipedia game “Seven Steps to Jesus.” Basically, it’s a special case of the Wikipedia game Wikirace, where you try to get from one article to another as quickly as possible. In Seven Steps to Jesus, you try to get to the Wikipedia article about Jesus in seven clicks or less. Why Jesus? Why seven? Who knows, who cares. But the point is, that it’s fun for about ten minutes.

This ridiculous game wandered into my mind the other day, and I started thinking, “I wonder how you could create a computer program that would play Seven Steps to Jesus…” The answer depends. If you give the program access to the entire Wikipedia database, then the task is trivial. It’s very simple and quite fast to spit out the minimum number of steps from one article to another. But what if you don’t give the program access to the entire Wikipedia database? What if it has to go to an article, and choose which link to click just like humans do: with “intuition?”*

As you might have guessed, the task becomes more complicated. Now we’re talking about machine learning (FUN!) I started to think about how you could train an AI to assign a “relatedness” value to every given article on Wikipedia by giving it access to the Wikipedia database, and having it traverse the links from one article to another. If you’ve taken a class on AI, you know that eventually, this relatedness value will converge to the shortest path. Basically, this program will do nothing useful… except heat my living room.

Except! Except that I’m going to train an RL agent in parallel. That’s the only thing that might be novel about this (other than the fact that I’m introducing the “Seven Steps to Jesus” task to the AI world.) Ordinarily, you would want the agent to learn sequentially, because if the links change, you want the agent to learn with the changes. But in this case, I really don’t give a damn about sequential updates. Also, this task is stationary (the distance between any two articles in my downloaded Wikipedia database will never change,) so updating sequentially doesn’t matter all that much.

So what you should get from this, is that this project is a HUGE waste of time. But it’s fun, and I’m learning about graph databases, and RMI, and I got to build and run a computing cluster. Maybe there’s a real task for which this approach is suited. I’m not sure though. Usually in RL, you have to run a trial many times in order to test an approach, so there’s really no point in distributing the actual processing. In other words, if you’re going to run 100 trials of your schmancy new algorithm, you might as well just run one trial on five different machines until you finish, rather than splitting up the computation (which adds overhead,) into five different parts.

The point is, I’m having fun. Leave me alone.

Discipline Week Update: Today was day four of Discipline Week, and so far so good. I’ve been trying to avoid napping, because I want to really embrace this 7am to 11pm schedule I’ve got going, but today I really needed a nap. I ended up sleeping for maybe an hour and a half, which is really too much, but we’ll see how things go tomorrow. I’ll write a more detailed post tomorrow about how Discipline Week is going, but I thought I’d let you know that it’s still a thing, and it’s going well!

*Yes, there are algorithms that do this quickly, but you’re still missing the point: the point is, this will be fun. Fun, I tell you, FUN!

Valentine’s Day: Musical Hearts

Here it is, ladies and gentlemen: this year’s Valentine’s Day computer art project. For the past two years, I’ve done some sort of computer art project for Valentine’s Day. The first was a 3D printed heart with a red LED inside. Last year, I recorded my entire bus trip to school, and wrote a program to select only frames with a certain amount of red in them, and compile them into a video. This year’s project was slightly more ambitious.

My original idea was to take videos of artistically interesting things on my walk to school. A computer program would then find trackable points on the video, and “stick” hearts to those objects. The sizes of the hearts would correspond to the amplitudes of certain frequency ranges in a song that would play in the background… a song which I would compose and create on my computer.

Several factors led to my cutting out the motion tracking entirely (namely that OpenCV is complicated, and Adobe After Effects hates me.) However, the hearts respond to the sound of a song that I composed and performed using ChucK, which is a programming language for creating sound. If you hadn’t already guessed, the red heart is low frequency, pink is midrange, and white/light pink is high. While the result isn’t nearly as cool as my original idea would have been, I think it’s pretty nifty, and it was fun to make. I also learned about some valuable tools in Processing.

To record the videos, I walked from Westmount to McGill at 7:40am, in -15 degree weather, without gloves. When I got to McGill, I could hardly feel my hands. So it’s safe to say that I put a lot of effort into this video.

(There was initially a problem with the upload, which has now been corrected.)

For the sake of comparison, for last year’s video I used two programs, one of which I wrote myself (Cinelerra and a python script for selecting video frames based on color composition.) For this year’s video, I used a grand total of 8. In order of usage (more or less:) ChucK, miniAudicle, Sound Flower, Audacity, Processing, Adobe After Effects, and Adobe Premiere*, and a Java program that I wrote in Processing.

*I am currently upset with Adobe. As a student, I cannot afford a license for the Adobe Creative Suite; a marvelous collection of software. I also have no intention or ability to make a profit from the work I have would do with the Creative Suite. If I spent my free time playing with Photoshop, After Effects, and all the other neat programs on my own computer, however, I might be able to make money from my work some day, at which point I would buy the Creative Suite so I could profit from my art. On the other hand, there isn’t a chance in hell I’m going to spend $899 on the Master Collection just to tinker. Therefore, it’s in Adobe’s best interest to offer a FREE (as in beer) version of the Master Collection to students for strictly non-profit, educational use. So there, Adobe, the ball is in your court now.

Kernel Vomit

Another compiler comic, not because of a lack of time or writing inspiration, but because C has been getting on my nerves.

When you get a core dump, you've done something horribly, horribly wrong. (In case it isn't obvious, K is the kernel.)

This has been happening to me pretty much all day. I didn’t get a core dump, but some error generated by the kernel that I couldn’t figure out, and which magically disappeared after I closed the terminal, waited half an hour, and then came back to it. C is making me angry right now; time for a break from coding.

PumpDownload: The Return

Several years ago, I started working on a program that I called “PumpDownload.” I was frustrated that most diabetes record software was horrible and that none of it worked on Mac or Linux. Being young and foolish, I decided I would write my own. How hard could it be, right? It turns out that it was a LOT more work than I thought it would be, and along the way I had to teach myself Java GUI programming, how to create data structures, and how to communicate with serial devices. It was a lot of work, but somehow, through hours and hours of work, I pulled it off. The “end” result was a somewhat glitchy, but fairly robust piece of software that works on Windows, Mac, and Linux, and is capable of downloading blood glucose readings from both Freestyle and OneTouch meters (I haven’t tried the new OneTouch meters, but I know the new Freestyle meters work.)  In fact, whenever I need to bring blood glucose readings to my endocrinologist I dig out my old backup of PumpDownload, figure out how I started it up the last time, download my readings, and print out the beautiful, clear, easy to read reports that it creates. Every time I do that, I think about how I should really start working on it again, but I usually get too busy with school, or waste too much time doing something else. But not this time.

I’m pleased to announce that I’ve brushed the dust off PumpDownload, and I’m working on what I hope will become a new release! Over the past few years I’ve learned a lot about software development, programming practices, and data structures, and I’m using what I’ve learned to help me write a more robust, easier to use version of PumpDownload, which I hope to release some time this summer. I probably won’t be adding many new features, but I’ll be streamlining the work flow for using the program and making the code more robust. Before I stopped working on PumpDownload, I added some new features that didn’t make it to my last official release, so those will be about as new as it gets, but what I’m doing now will lay the groundwork for features to come.

When I first started writing PumpDownload, I didn’t have much knowledge of good programming practices, or how to use and write data structures, but what I lacked most of all was experience. There are certain aspects of programming that I simply didn’t know or think about, which made writing PumpDownload fairly difficult at first. I had to kluge a lot of things together, which means that I’ve had to go back and rewrite major portions of the code more than once – just today I overhauled the entire portion of the program that deals with settings (it’s a relatively small component, but it has its tendrils everywhere,) which took me probably one to two hours of code, compile, fix, repeat until I managed to repair code that I thought was fine the first time around.

While my dreams for the program have changed slightly, I’ve realized recently that I really do want to get the program out there. The strength of PumpDownload isn’t that it’s coded well, or that it’s faster than other programs, or even that it produces fancy reports. On the contrary, PumpDownload’s strength is that it produces useful reports; reports that you can look at for a few seconds and see exactly where you need to make changes to your basal rates or insulin to carb ratios. That and the fact that it will run equally well on Windows, Linux, or Mac OS. It’s simple without making the user feel stupid, and it doesn’t give irrelevant information.

It will probably be a while before I post anything about this project again, but at some point I will try to update the PumpDownload Project Page on SourceForge (I may also upload my code to CVS, for those who are interested.) Stay tuned!

Note: If you are a diabetic, you can help me (at some point) by testing PumpDownload and telling me what you think of it – what you like, what works, what doesn’t, what you’d like to see in the program or the reports it generates. Please contact me if you’d like to try it.

C Doesn’t Care About Your Kernel

Due to a busier than usual week and the fact that the project I was planning to post today isn’t ready yet, I’m afraid I’ll have to post another compiler comic today. Maybe some day I’ll branch out from compilers into some other comic topic. Maybe some day I’ll take some drawing lessons.

Fun fact: When I first wrote "Poof!" above the addresses, it looked quite a lot like "Poot!" I enjoy the idea of memory addresses giving one last fart of defiance before being zeroed out.

Apparently, though I’ve never actually tried this, if you malloc enough data without freeing any, and if you have the appropriate permissions, a C program will overwrite all your RAM, move to swap, fill to the end of your hard drive, wrap around, and overwrite your entire drive with junk. Never drink and code in C, kids.

Also, no: this was not done in MS Paint, though the awkward speech bubbles would make you think it was. Apparently GIMP is terrible for drawing. I drew the main comic in MyPaint, then added the text in GIMP, and cringed all the way through.