Getting Lisp to run on heroku

For a while, I’d been working on cloning twitter in Lisp, since I’d been playing with Lisp web frameworks (weblocks, hunchentoot, caveman, clack) for a while. Now that I know so much more about web development, it seemed like a perfect chance. Also, with hunchensocket around, I could do push notifications with websockets, too, which Rails can’t without third party services.

I have a site up now, at Chirp, after many hours of beating my head against the wall. I thought I’d write down some major points for others who try to sort the madness out.

  1. Your app will be compiled, don’t expect it to behave like you’re running it from the REPL.

    I had my configuration defined using envy’s (defconfig) in the top level of a file. That meant that all of the configurations were defined at compile time, when the environment variables I was using weren’t defined. So, I had a few nil’s in my configurations.

    Now, I wrap the (defconfig)‘s in a function call when the app starts up. Works like a charm.

  2. You don’t own the database, you just get to use it.

    CLSQL doesn’t have permission do do a number of things you might have been doing on your own database server. I had a helper function that made the database and tables if they didn’t exist. I got a lot of complaining about “template1,” which seems to be some internal postgres thing that administrators get access to. Don’t use (clsql:probe-database) or (clsql:create-database), they both try to do things they’re not allowed to.

  3. Getting environment variables is a necessary evil.

    Environment variables are not a first-class part of the lisp world, but they’re not too hard to get to. Heroku uses a lot of them to show you your configuration, pay special attention to PORT and DATABASE_URL.

    You can get at these two ways. ASDF has a private (getenv) function, which is handy and generally available. If you’re using SBCL, you can also (require 'sb-posix) and use (sb-posix:getenv). It has a sibling, (sb-posix:setenv), should you need it.

Hopefully, we’ll make a better, more user-friendly buildpack, soon.

Starting Over All Over Again

So, back in July I took the plunge and decided that I wasn’t cut out for the world of Academia. Grad school was taking an emotional toll that was turning into a physical toll and wasn’t paying the fulfillment dividends that it needed to. I’d spent years acquiring very specific skills in quantum computing research that people didn’t value at all. The pay was terrible. The social environment was terrible. The management was terrible. It was time to leave.

So I went ahead and enrolled in App Academy, which my friend Scott had done before. So, for the last two months, I’ve spent every waking hour programming (well, maybe a few reading and playing Dota). I know Ruby, Rails, Javascript, Backbone (learning Angular) and I already knew Common Lisp.

Most importantly, I feel like it’s a good life choice. I miss doing physics, but the universities have made it such a horrible environment to work in, it’s not worth it to me, anymore. I’m happy I get to keep problem-solving in programming and, if I’m lucky, I’ll find a job that uses my considerable skills in debugging and engineering.

The Job search starts today and I’m confident it will give me a fuller life than a career in Physics was offering.

Injera and Company

Tonight is an exciting night. Tonight, I’m making Ethiopian food for the first time. During my time as a grad student, I barely cooked (or wrote) anything, let alone something new. So, I’m very excited to be doing something new tonight.

A few days ago, I started preparing the dough to make Injera, the national bread of Etiopia and, as far as I’m going to count, my first sourdough bread. The recipe is really simple, once you’ve found some teff flour. All you do is mix it with water and wait for it to start to go bad!

Aside from finding the teff flour, the other difficult part of this (and it gets much easier afterwards) is finding berbere spice mix. I have no idea where to do this in Kitchener, so I found this recipe that suggests how you can make your own. It doesn’t contain ground lentils, which another site suggested was part of the mix, but I’m not one to work too hard at accuracy. I’ll be using tomato sauce instead of tomato paste, as well, and grinding up my own chilis, probably with a blender (I did end up doing that, and only using half the suggested amount).


I found a helpful article on the Toronto Sun website that contains some vegetarian recipes for the various toppings that go on the Injera, so I’ll use that!

After sitting out for a day, covered with a damp towel, the teff mixture smelled a bit odd, which seemed right for sourdough. I had tried to make the batter once before, and it had grown mold, being left alone for three days. That might just be our apartment in the summer, though. I wonder if the wintertime would require a longer fermentation time.

Ideally, the bread is made like a thick crepe, but it didn’t run very quickly in my pan, so it ended up fairly thick and misshapen, but it did bubble in a way similar to the bread I’ve gotten at restaurants. Apparently, many Ethiopian places in North America cut their teff flour with wheat flour in order to make the flavor less intense, and I wonder how that affects the consistency of the dough itself. I might have to try, just to see if it makes it easier to cook.

finished ethiopian-scaled

The Martians

Recently, I’ve been reading The Martians by Kim Stanley Robinson. It’s a book of short stories related to his {Red,Green,Blue} Mars books, which I enjoyed a lot. He managed to create a fully bleievable world with exciting new things going on and, at the same time, create a cast of characters who are believeable and complex – something that is somewhat rare for science fiction. The science is pretty fun, too, but pplied in a very human way.

Some of the stories have been misses for me, as one would expect. For example: I don’t really care enough about mountain climbing for the story about climbing Olympus Mons to have made a huge impact on me. The one that I just read, however, Arthur Sternbach brings the Curveball to Mars, was a wonderful example of the best of Kim Stanley Robinson. It is, as you might guess, about playing baseball on Mars. It features the aspects of Mars that Robinson tends to bring up – the lower gravity, the shorter distance to the horizon – but he makes it interesting every time he brings it up by showing how those things really affect the everyday lives of people on Mars. In this case, the baseball field needs to be much larger – with a fraction of the gravity on Earth, it would be pretty simple to hit a home run otherwise. But, once you’ve done that and considered the shortened horizon, it means the field stretches out almost to the horizon around you.

The story also went into the culture of Baseball on Mars, suggesting that the Martians had only learned it from videos and so, didn’t do many things that the protagonist, a visiting American, took for granted. Things like heckling or calling to each other on the field about what they were doing. They also had never seen a curveball.

In any event, it was a good story and I’d recommend it.


Tonight, Sarah and I went with some friends to the local makerspace, KwartzLab, in Kitchener. It was a ‘bring your own project’ night, though only a few people were there while we were.

There was a pretty impressive array of machinery represented, although, from what I’ve read of makerspaces, it was probably pretty run of the mill. 3D printer, laser cutter, …. the usual.

One thing that we saw that I’ve never heard of before was a knitting machine. It was a long line of hooks that the knitted piece hang on. You slide a piece back and forth across and it somehow automatically knits! Apparently, they’re also programmable, which is nice. Unfortunately, though, it seems most are programmed with punch cards and the woman operating it claimed that they predated modern computers!

Hopefully, we’ll manage to make it back for their Tuesday night open house to work on something. It was nice being around a bunch of people working on projects.

Mining on Linux

This weekend, I decided to look into crypto currencies again.  Three years ago, I poked around bitcoin and managed to find a site that would give you 1/1000th of a bitcoin for free, just to get people to use the currency.  Now, there are lots of new currencies online and who knows which will become as popular as Bitcoin, although I expect some of them will make it.  I, personally, like the vibe of Dogecoin, which has a level of seriousness I find appropriate for currencies anyway.

I set about trying to mine some on Fedora 20.  I am the sort of Linux user who tolerates very little non-free code on the machine and graphics-related topics especially give me pause.  It seemed worthwhile to me to figure out how to get a miner running on the open-source drivers, then.  I was happy to find that Tom Stellard, a mesa developer, posted on his blog about getting mining working with the open radeon drivers.

The trick, it turns out, was getting a new enough version of mesa, clang, and LLVM to get things working.  I ended up having to install fedora-release-rawhide and then running

sudo yum install mesa mesa-libOpenCL clang llvm --enablerepo=rawhide

to get the appropriate bits.

Now I’m chugging away at ~160Mhashes/s, which seems to be pretty slow by modern standards, but within a factor of 2 of what other people report for my card.  Not bad for new code.

If you find this useful, feel free to throw some of your shiny, new crypto-currency at me!  Maybe then I’ll be able to get hardware I can actually play this strange lottery with!

BTC: 1QKPMpRNEbpwhzzP33HpiNSEfEgDdTYvd3

DOGE: D5A9ngH7mb3roJgpAGUjUPdAcbV3svvkvH

Let’s Try Anyway

A great problem in any job is orthodoxy. I see it everyday in myriad ways at the University where, despite nominally being all about the future (students, research, etc.), we really do the same things, uniformly, over and over.

A few moments ago, I head a colleague talking about a class she is a teaching assistant for. All I head was someone asking if it “would work with three people,” and her saying, “Well… probably not.” This particular conversation is not important, but it’s an example of something that happens a thousand times a day in this building alone. I’m certain of it!

We make many snap-judgments in our hectic, university lives. How to grade, how to teach, how to assemble experiments in vacuum environments. A good deal of these things are simply based on prior experience; things which haven’t necessarily been taught, just picked up. A lot of these things have never been thought through. Some of them don’t even make any sort of sense when thought through. Some of them make sense but don’t hold up to scrutiny.

I would like to work in a place where people say, “I don’t think that will work, but let’s try it anyway.”

I think it implies that people have enough time to explore, that they are supportive enough to want to explore your ideas, and that they are open to the possibility that they are wrong.

I dislike the capitulations that seem to be required of any statement today, but I do concede that these moments of support and understanding happen – but only occasionally. They should happen in far greater numbers, though.

The First Days

So now I’m about two weeks in, I have homework, about 40 lab reports to grade, and need to find a sub for my lab TA section. I’ve gotten a social insurance number from the government of Canada (the Canadian equivalent of a social security number) and it seems likely that I might get paid this Friday. Now, while I have a few minutes before I go upstairs to get to better know some of my new colleagues over lunch, seems like as good a chance as I’ll get to go over what I’ve been thinking about since I started here at the IQC.

First, dealing with office staff is always frustrating. As a foreigner, even from the US, it was a mess of people not telling me what I needed to do in time. I still laugh thinking about the email that came out a week or two before classes from the international office explaining how to put off coming to school for a term because they hadn’t really told people in time to apply for visas.

Getting my study permit was something I got done well in advance and, consequently, without much help from the university at all. The SIN was another one of those things. Sarah and I biked out to the service Canada center on a hot day and arrived sweaty, carrying our stacks of documents, only to find that Sarah, who doesn’t yet need a SIN because nobody is paying her anything, could get a number, but I – the reason we were in the country in the first place – hadn’t been supplied the right paperwork by the University to get mine. There were a number of other small things as well, but that was the one that required the most physical effort by far.

I’m now slowly being won over to the idea that the university might actually care about some of us, but they certainly didn’t show it at all until long after I’d arrived and started attending classes.

Now that I’m here, though, it’s nice to be teaching a little (as a Teaching Assistant) and good to have some things to think about during the day. The minor office snafu’s keep coming (I wasn’t given a key to the room I TA in yet), but we’ll iron them out and hopefully I’ll have less and less to ask of confused people in offices as time goes on.

There are people from a lot of different countries here. It’s hard to tell how much is the university and how much is Kitchener-Waterloo generally, because both seem to be fairly diverse. The grad students from India have commented that they can get some of the same food as at home since there’s such a large population with Indian heritage here.

After our year in Evanston/Chicago, I think we’re doing a pretty good job of setting up a life here. Making new friends is hard, and takes a lot of time. Sadly, I don’t really get to see the other grad students much other that at lunch, which I try to make the most of. Hopefully, some of them will be friends, and perhaps someday, we’ll make it to Food Not Bombs here in Waterloo or in Kitchener, closer to home, and meet some people there, too.