My dad (also a computer programmer) emailed me yesterday about a silly little issue he was having trying to get a python cgi script to run. We went back and forth a couple of times but didn't come up with an answer. I just got this email from him:
Ok, this if funny... I got it working...
Started searching the Textdrive forums for some other occurrence of this problem and found one. Turns out I was using Windows/DOS line endings (0D0A) rather than UNIX line endings (0A). Fixed that (and some problems I had with the html header) and it's working. Don't know how my editor got switched from UNIX to DOS for .py files but it's fixed now.
Now for the good part... guess which forum message I ran across that got me going? ... ... Yep, it was from you about 2 years ago. Got a good laugh out of that.

Inspired by this, I set out to build myself a microprinter. That is, a receipt printer that would sit on my desk and print out whatever little bits of text I happened to send to it. Why would I want to do this? Well, first, I'd been looking for some kind of project that would result in a physical thing (too much software in my life normally). Secondly, I'm obsessed with notification systems. I don't trust myself to remember things, so over the years I've used a variety of what could laughingly be called "systems" for reminding myself of various tasks, dates, ideas, etc.... Before I started working at home, it was the rare day that I wouldn't come home with at least one or two random notes stuffed in my pocket. So the original idea was to make something that I could use to create unignorable physical reminders for myself. But first, I needed a printer.
I like the way thermal printed receipts look, so I looked for a thermal printer instead of a dot matrix variety. After perusing ebay a bit, I settled on the Epson TM-T88 series, which is the one you see pretty much everywhere in stores and restaurants (at least in my area). I wasn't willing to spend a fortune on it though, so it took me awhile to find a resonably priced one on ebay, but I finally did.
With the printer secured, I needed some hardware. A shopping list:
The general plan is for the Arduino (which is really just a little standalone programmable computer) to make periodic requests to a web service, and send whatever it receives to the printer. I'm not going to get into the electronics details because, frankly, I don't really understand it all that well. Plus, there was a large amount of frustration, false steps, cursing, trips to Frys and Radio Shack, and a little help from my friends (thanks Matt!) before I got it all working, and I'd rather not relive that. So let's just sum it up by saying that I finally got it working. If anyone reading this wants help building their own, well, there are probably much better sources of help out there than me, but feel free to contact me if you have any questions you think I might be able to answer.
With the hardware working, I could finally move to the more comfortable area of the web service. I set the Arduino/printer rig up so that it sends periodic requests to my server, and if it gets a correctly formatted response, it prints it out. The web side is a pretty simple Django app. It has a basic Message model, and a view that returns any unread messages. When the request comes in from the Arduino, it also checks to see if it needs to run any message gathering jobs, which is based on the time since the job was last run. So, for instance, I run the Twitter job every 15 minutes, and the Trac job every 10 minutes. I originally planned to run these jobs via cron, but my server setup doesn't let me run cron jobs more fequently than hourly.
The messages currently come from three sources:
- A simple form where I can send reminders to myself. This just directly creates a new Message object and adds it to the queue.
- Twitter messages. I check for any @replies or direct messages to myself, plus any tweets from a few friends who update relatively infrequently.
- Trac tickets. The job fetches the Trac RSS feed for all tickets and prints out any new ones.
This was a fun little project, and although it ended up taking a lot longer than I expected it to, I'm pretty happy with the results. If anyone has any other ideas for interesting message sources, please share! The only other ideas I have at the moment are a grocery list (print it out at the press of a button), and a daily calendar summary (publish my iCal calendar to my server, and print out a daily summary out every morning).
Barring an extremely unlikely last minute turnaround, or a (hopefully unlikely) stolen election, I have just cast my first ever vote for the winning presidential candidate. He would also happen to be the first African American to hold the office. It's a proud day to be an American. Let's hope this becomes a national turning point and gets us back on the right path.
It's also my fervent hope that Californians will show national leadership by rejecting a constitutional amendment based on bigotry. That would make it a very proud day indeed.
Go vote!
From the "I always forget how to do this, so here's a reminder for next time" files: Installing PIL with JPEG support on OS X - but without using Fink.
All the PIL documentation just says to install libjpeg using Fink. I'm not really into Fink, so I always flounder around for how to do it when installing libjpeg from source. The secret is that after you install libjpeg, also do:
sudo make install-lib
(where I found it this time)
I just launched a new site to help groups decide where to go to lunch. Ironically, I don't work in an office where this is a daily issue anymore, so I won't be getting as much use out of it as I would have a couple of months ago. Oh well, at least the rest of the world can use it.
You can check it out at http://whatsforlun.ch?.