Pocket Django

At the Western Mass. Developers Group meeting this week I showed a few people some of the unixy fun you can have with a (jailbroken) iPod touch and the Cydia package manager. Cydia is a port of Debian’s APT system to the iPhone platform – i.e. it’s a real package manager. It made it a snap to install Python, Mobile Terminal, Mobile Text Edit, Subversion, etc. This is the toolset that has allowed me to even do some work on the book as I mentioned in my last post.

Python one-liner of the day

This is a function that takes an integer and returns its ordinal representation, e.g. “1st” for 1 and so on. It’s not the most readable thing, but once I saw the pieces falling into place I couldn’t help myself. Repetition of the “th” literal is the only thing that bugs me. Oh well. ord_text = lambda n: "%d%s" % (n, "th" if 10 < n % 100 < 14 else {1:"st", 2:"nd", 3:"rd"}.

History lesson

This has been going around – give people a peek at what commands you run most often. I ran this on my server, where I spend most of my shell time: > history|awk '{a[$2]++} END{for(i in a){printf "%5d\t%s\n",a[i],i}}'|sort -rn|head 103 hg 81 cd 67 ll 29 ./ 23 ab 21 re-ap 17 hgup 14 svn 13 cat 12 ls Notes: Mercurial has pushed my use of Subversion way down.
The original Lego Star Wars

The original Lego Star Wars

I attempted to make a Super-8 animated-Lego version of Star Wars when I was 14 – in 1982 or so. I had made several other animated movies, Lego-powered and otherwise, but this was my most ambitious project. Over several weeks of painstaking stop-motion animation, I got as far as the escape-from-the-Death-Star scene. In real time this was about four minutes of footage (yes, it was a multi-reel production), but as anyone who has done traditional animation can tell you, that’s a lot of work.

A weather site in six (declarative) lines

For several years I maintained a hodge-podge of little web-based utilities at Recently I decided to wipe the slate clean, bringing things back selectively. One of the few that I missed personally was my weather site. It returned National Weather Service forecasts in response to compact URLs of the form, for any five-digit US zipcode. Originally, the site worked by scraping plaintext forecast files on the NWS servers. Eventually those went away; I looked at and gave up on the arcane (to me) SOAP interface that superseded them.

The Language I Will Kind of Learn in 2008: Smalltalk

In 2007, I took a whack at learning Haskell as my Language of the Year. It was an educational experience on more levels than I had expected. I didn’t get as far with the language as I might have hoped, but I did have the essential mind-opening experience of dealing with a purely functional, “lazy” language. My approach and style in my primary day-to-day language (Python) changed in a positive way.
World's ugliest Django app

World's ugliest Django app

OK, this is an ugly hack. But also (possibly) cool if you’re into ugly hacks. I’ve written a small Python script that is a fully functional, self-contained, self-starting Django application. You don’t need to put it on your PYTHONPATH or set DJANGO_SETTINGS_MODULE. You don’t need a web server. It even creates some dummy content for you. I call it – it’s somewhat compressed. The only prerequisites are a Unix-like operating system (i.