Quantum Mechanic

Content from 2014-11

Literate Programming with Emacs

posted on 2014-11-21 22:17:00

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"
...
#+end_src

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

posted on 2014-11-13 16:33:00

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

posted on 2014-11-11 14:15:00

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.