Brad's Blog

web dev, django, running, food, or whatever

On select_related() 2010-03-23

If you use Django, and your models have relationships that span across multiple tables, you need to read this: http://docs.djangoproject.com/en/dev/ref/models/querysets/#id4select_related() is awesome.That is all.

Building PIL on OS X: Snow Leopard 2010-02-25

There are several places online that discuss problems installing PIL on Mac OS X Snow LeopardThis is how I got it to work.Install lib jpeg using homebrew (which is super-aweseome!) brew intall jpeg.This installs the library into /usr/local/Cellar/jpeg/7Install libfreetype the old-fashioned way (./configure, make, sudo make install). I used freetype-2.1.10.pre-20050511.Download, unpack PIL (I used Imaging-1.1.6). I had to make the following changes to setup.pyFREETYPE_ROOT = "/usr/local"JPEG_ROOT ...

Specialization 2010-02-24

Thanks to @mxcl for tweeting a link to this: http://gist.github.com/313640Things I've done (or similar)change a diaperplan an invasion (warcraft counts, right?)butcher a hog squirreldesign a building (with legos!)write a sonnet songbalance accountsbuild a wall fencecomfort the dyingtake ordersgive orderscooperateact alonesolve equationsanalyze a new problempitch manureprogram a computercook a tasty meal (yum!)fight efficiently (yay for taekwondo!)...not quite there yet:conn a shipset a bonedie gallantly (here's hoping!)Hooray for Humanity!

Adventures in Bread-Baking: Part 1 2010-01-23

Last weekend I attempted to make Mark Bittman's Speedy No-Knead Bread... sort of. Being the adventurous experimenter that I am, I altered the ingredients:2 cups whole-grain flour + 1 cup all purpose flour2 cups of really warm water (instead of the 1.5 cups)I followed the rest of the recipe perfectly. However, the results were really unsatisfactory. The center was super dense and gooey, and the bread had a really really hard crust (ok, I also cooked it ...

Add JSON syntax highlighting in Vim on OS X 2010-01-15

This is how I got Vim to do syntax highlighting for JSON files (Max OS X - Snow Leopard)Download the syntax file from http://www.vim.org/scripts/script.php?script_id=1945. (I got json.vim version 0.4)If it doesn't already exist, create a .vim/ftplugin in your home directory.Put json.vim into .vim/ftpluginAdd the following lines in your .vimrc file (mine is located at ~/.vimrc)au BufRead,BufNewFile *.json set filetype=jsonau! Syntax json ...

Resize the iTunes Window 2010-01-14

My Macbook Pro is my main machine. At the office, I connect it to a 20" Cinema display. At home, I connect it to a 24" Samsung Monitory (Model 2494SW Glossy Black, which I really like, btw.)There's a down-side to all this, though. I mostly just notice it with iTunes. When I'm working on the laptop without an external monitor, my iTunes window is larger than my screen :( Unfortunately, clicking the Maximize button doesn't do what ...

Ubuntu Audio, YES! Windows XP, NO. 2009-12-13

I run a dual-boot Ubuntu64[1] and Windows XP system. The windows partition really exists for a single purpose, and I occasionally just reboot the machine, choose the XP partition from the Grub menu, and all is well.However, a few weeks ago, I upgraded Ubuntu, but when I rebooted the machine and chose the XP partition, I noticed the sound[2] stopped working. What!? The audio worked fine in ubuntu!The Secret: I had to completely power down the ...

Gahhh!! Django, virtualenv, and cx_Oracle 2009-11-24

UPDATE: Thanks in advance to the comments from Graham Dumpleton whose comments below pointed me in the right direction!This wasis a plea for help.I've got django installed and configured with apache and virtualenv. I also have one particular app (named myapp) that queries an Oracle database directly (django is configured to use MySQL). All of the apps work, except for anything thatbrequires the myapp app... which includes the admin!Requesting any view that uses cx_Oracle results in ...

Sticky Groups 2009-11-24

I often deploy web projects in a directory that's not owned by the user under which my webserver runs. Therefor, I often have to change permissions so the webserver can read from or write to certain files. So, for this example, let's assume I'm logged in to my linux box as brad, and I'm using apache which runs under the user www-data. To give apache access to my public_html directory, I'd change ownership for the ...

Mercurial installation woes on Mac OS X 2009-09-30

I started using mercurial around version 1.2, and I'm pretty sure I used the Mac OS X installer (from http://mercurial.berkwood.com/) to install 1.2.1. This placed hg in /Library/Frameworks/Python.framework/Versions/Current/bin/.Now, I've decided to upgrade to 1.3.1, and I again grab the Mac OS X installer (again from http://mercurial.berkwood.com/), which installs hg in /usr/local/bin/.Ok, but my path is set up ...