Brad's Blog

web dev, django, running, food, or whatever

Published: 2012-02-05

Net::HTTPServerException: 412 "Precondition Failed"


So, I've been working with Chef quite a bit, lately. Every once in a while, I'll bootstrap a new node and it fails with this: Net::HTTPServerException: 412 "Precondition Failed" Every single time this has happened to me, I've had stop and scratch my head. Why can't I remember what causes this!? Well, in my case it's usually a misspelled cookbook or recipe name. For example, I might have a role that looks something like ...

Published: 2011-12-22

PostgreSQL 9.1.2 via homebrew on OS X 10.7.2

django homebrew osx postgresql python

I just picked up a snazzy new Macbook Air, and I'm working on setting up my development environment(s). For the most part this has been fairly easy. I pull in my repos from github and bitbucket, and I use virtualenv and pip to organize all my python packages (mostly installing from requirements files). Most of the other command-line tools get intalled with homebrew, and this time around I decided to install PostgreSQL with homebrew. I didn't keep ...

Published: 2011-12-13

Chosen.js in the Django admin

chosenjs django javascript jquery python web

Update Nov 23, 2013: I've written a little app (django-chosenadmin) that'll automatically add this to every app. Quite some time ago, I ran across the chosen.js plugin for jQuery and Prototype (I'm using the jQuery flavor). My first thought upon seeing this was, "This would rock in Django's admin app." Yet for some reason, I didn't make that happen.Until recently. I maintain a project where about 10 people use the admin app extensively ...

Published: 2011-10-06

Think Different.

americandream apple death osx stevejobs thinkdifferent

There's a lot of buzz on the net about Steve Job's death, and rightly so. For those of us that work in or around the tech world, he was a giant. I fully attribute his company's products (the iPhone and the iPad) to what I like to think of as a renaissance in computing. These devices have changed the way we think about computers, the web, and what software can be—mobile & fully integrated into our ...

Published: 2011-01-24

SiteSprint III - An update

This post, a followup to my previous post, is now about 2 months overdue. I have to admit, I'm glad I participated in SiteSprint, but I'm fairly disappointed in the amount of work that I accomplished. So, without further ado, here's the update on what happened.Success!Set up a Django stack running nginx, gunicorn, postgresqlSet up MezzanineMigrated my blog posts and comments from BloggerFor a weekend of work, this really wasn't too bad. I like ...

Published: 2011-01-05

Fix: Leopard libedit detected.

If you use iPython on OS X, you've probably seen this: Leopard libedit detected., and then noticed some very quirky behavior related to spacing, and command history. In short, that behavior is related to default version of the readline library bundled in OS X (It's not GNU readline). If you use pip and virtualenv, just instalilng readline doesn't help. So, how do you fix this? Well, the quick and dirty way to fix this is with:easy_install ...

Published: 2010-11-02

SiteSprint III - The Reclaimation

django sitesprint web

My personal website is a disgrace. As a web developer, I find it embarrassing that my own site is a cobbled-together mess of PHP and static html. Only slightly less embarrassing is my blog, which is obviously hosted on Blogger. Even though Blogger has recently added a few new themes, I'm still unhappy with the look-and-feel of my blog. So, since SiteSprint III has officially started, I'm taking this opportunity to Reclaimâ„¢ my personal website.Tech Specs - the ...

Published: 2010-10-15

Python: stray commas cause tuples?


As I try to debug a strange problem in a Django view, I notice a stray comma after a dictionary definition. So I jump over to a python shell, and guess what? Ending a literal dict with a comma creates a tuple. >>> d = {1:'foo'},>>> type(d)<type 'tuple'>>>> d({1: 'foo'},)>>>

Published: 2010-07-19

A case for values_list

django python web

Here's the Scenario: I have a model (lets call it Contact) with two Foreign Keys, one of which is related to User in Django's contrib.auth app. I need to build a form that lets me select an existing object, and a new user. class ContactType(Model): name = CharField(max_length=128)class Contact(Model): user = ForeignKey(User) contact_type = ForeignKey(ContactType) # possibly more fields...I need to select from existing models, so my first thought might be to build ...

Published: 2010-07-14

PyGraphviz on OS X (SL) with virtualenv

Mac OS Python X graphviz virtualenv

There's this cool project called django-extensions that (among other things) adds a lot of commands to django's offerings. One of which is ./ graph_models [appname] which will generate a nice graph displaying the relationships among all of your Models. This comand needs pyGraphViz, though, and I was a little disappointed when i discovered I couldn't install pyGraphViz with pip install pygraphviz. (ok, a lot disappointed). I eventually got this working, and here's how ...