Yet Another DeDRM afternoon

Entered on [2015-02-12 Thu 17:12]

Today, I agreed to my first programming job! More on that another time. To celebrate, I got myself a copy of “Effective Javascript” by David Herman.

I decided to give Kobo a try, having been repeatedly disappointed by Barnes and Noble, and not having a Kindle. I thought Kobo was supposed to be DRM-free. I’m not entirely sure how I thought they were doing that when everyone else is trying to lock you into a books-as-a-service ecosystem, but I did.

In any event, it came wrapped in gross Adobe Digital Editions DRM. So, I just spent the last hour stripping it off and then deleting my Kobo account. To save any of you the trouble I went through, here’s some links that were useful in a sea of not-useful stuff.

Clearing up some free space

Entered on [2015-01-13 Tue 13:28]

Every now and then, I get notifications on my laptop that the root partition is running out of space. That’s because I made a rather small root partition for Fedora to run on when I upgraded to a SSD 1 that was smaller than my older, spinning disk drive.

One of the fist places I look for wasted space is /var, because I know that yum/dnf keep caches there and systemd keeps the system log there, too.

Usually, there’s a rather large log sitting in there, for some reason. Today, there was about 950MB of log sitting there. I searched around a little and found that you can edit the configuration for the system log daemon at /etc/systemd/journalctl.conf. There’s a configuration option called SystemMaxUse that you can set to something small, like 16M or 100M, depending on how generous you’re feeling and how much you like logs, and it should max out at that much space.

Sources: A blog post and a stackexchange post.


1Solid State Drive

Keeping the Fun Alive

Entered on [2014-12-16 Tue 14:53]

Over the last few years, with college done and friends scattered out over the US. It’s been hard to keep in touch and, every time I do see people, we talk about how we’d like to keep in better touch.

I was reading Blaster Nation, today (all of it!) and it made me miss my friends. So I set up a mumble server and a Google Calendar, and we’re going to see if we can play games together, even just randomly, but also in some planned state.

In my mind, it could be something like twitch, or steam, or maybe really it should be like meetup for playing with friends.

Maybe that would be a fun project?

Cooking with websockets

Entered on [2014-12-05 Fri 12:57]

I finally got Chirp working with websockets! Well, it had worked before, but just sent down all the chirps that existed. Now it updates in real-time when someone else chirps. Though, it sends it to everyone, so don’t say anything you’d want kept secret!


Eventually, I’d want to send messages only to followers and have them show up in the nav bar as notifications, but this was mostly meant as a proof of concept, anyway. I’d much rather go write a new sql library for lisp, now, that try to finish everything. At some point, paging chirps so you can scroll to fetch more would be good.

This was sort of my minimum product for this project, but I might polish it more as I have time.

Playing with the MOP

Entered on [2014-12-01 Mon 15:30]

I was poking around at my project, Chirp, today and finally decided to deal with a strange bug I was having. When I sent JSON down to the AngularJS controller that renders the page, dates were always coming back as the time the request was made at. This was strange, since the database records of the chirps store when they were created, and the time should have been that. The one I was testing was over a week old.

Eventually, I realized that in the slot definition

(created-at :type clsql:wall-time
            :initform (clsql:get-time))

the time stamp would always be the current if the time wasn’t set on the instance when the database was read.

I’d recently started using clsql-helper to get instances of classes back from complicated SQL queries. By ‘complicated’ I mean ‘contains a basic join.’ Apparently, CLSQL doesn’t feel it needs to do that. I wish I knew why.

In any event, when I used clsql-helper, the dates were wrong, when I used clsql‘s built-in #'select, the dates were correct. So it slowly dawned on me that clsql-helper was doing something wrong. Sure enough, it wasn’t converting the string that the time stamp returned into the wall-time instance that clsql expected.

So I took the chance to play around with the MOP a bit and wrote code to convert the values to the right type, looking at their slot definitions in the class.

(defun get-slot-by-name (name class)
  (find name (closer-mop:class-direct-slots (find-class class))
      :key (lambda (slot)
             (intern (symbol-name (closer-mop:slot-definition-name slot))

(defun coerce-value-to-column-type (class column value)
  (let ((type (clsql-sys::specified-type (get-slot-by-name column class))))
    (coerce-value-to-db-type value type)))

With that code, you just do something like

(coerce-value-to-column-type class coulmn data)

and things come out the right way.

Literate Programming with Emacs

Entered on [2014-11-21 Fri 17:17]

Tried out literate programming a bit today using some info from Sacha Chua’s blog (mostly). It’s actually pretty difficult to figure out how to make it work and what was strangest for me was that I can’t figure out how to put a whole bunch of code blocks into the same file. It seems like you need to specify a :tangle filename for every block!

#+begin_src clojure :tangle "chapter1.clj"

What I was really hoping for was defining a new file at each section. John Zahng invited me to work on SICP in Clojure with him and I thought it was a particularly good case for trying out org-mode’s literate programming functionality. After an hour or two of trying, though, I don’t know how to make it do what I want. I can get it to dump all of the code into a file with the same name as my .org file, but that’s it. I’m not really sure how I’d want to use this to write a large project of any kind.

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.