Posts

Showing posts from November, 2008

A Flashlight Story

Image
Back in May of this year, in preparation for a campout, I bought a nice looking LED headband flashlight at Walmart. It's a Garrity light and it ran me about $13. I used it on the campout and fell in love. It was incredibly light-weight and I soon forgot it was on my head, yet it was plenty bright (click these images for larger versions). After the campout it sat in a drawer for a few days before I had occasion to use it again. When I pulled it out of said drawer and pushed the button to turn it on, nothing happened. Saddened, I figured it must have been bumped and turned on while in the drawer or maybe one of my boys had found it and left it on. I bought new batteries and used it while performing some bicycle maintenance in my dimly lit garage late one night. I put it away high on a shelf away from any bumps or curious hands afterwords. A few days later, the batteries were dead again. I've gotta return this defective thing to Walmart, I thought to myself, but n

Carefully Upgrading to Django 1.0

I’m a little behind, but I finally upgraded my family website to Django 1.0 . First of all, I wanted to keep the main site running my older version of django from subversion while having 1.0 installed and being used by the development version. First I added the old install to my apache configuration’s PythonPath. Here’s the diff: - PythonPath "['/home/bryan/web/murdockfamily'] + sys.path" + PythonPath "['/home/bryan/web/django_src', '/home/bryan/web/murdockfamily'] + sys.path" Then I deleted the symlinks to that django install from any site-packages locations: sudo rm /usr/lib/python2.4/site-packages/django /usr/lib/python2.5/site-packages/django /usr/local/lib/python2.5/site-packages/django Then reloaded apache: sudo /etc/init.d/apache2 reload And it seemed to still work. Next I untarred Django 1.0, and installed it: tar -zxvf /home/bryan/downloads/Django-1.0.tar.gz cd Django-1.0 python setup.py build sudo python s

Convert a PostgreSQL Database from LATIN1 to UTF8

I had a problem with my family django-powered website. I have an aggregator for all our friends blogs, very similar to the Django aggregator , except that mine hasn’t been aggregating. After some serious investigation, I found that psycopg was barfing error messages because the feeds that were being stuffed into my postgresql database contained utf-8 characters that it couldn’t figure out how to convert into latin1 characters. I hadn’t paid any attention to this, but apparently my blog database was using latin1. Lame. I decided it was time to learn how to convert it to utf-8. First, I did a pg_dumpall in order to get a look at things (this happens automatically every night, actually): /usr/bin/pg_dumpall -U <special user> > /home/bryan/backups/all.dbs.out Sure enough, my database was created like so: CREATE DATABASE bryan WITH TEMPLATE = template0 OWNER = bryan ENCODING = 'LATIN1'; So, I dumped just that database: pg_dump -U <special user> bry