Category Archives: Code

Django & AWS Lambda

Slides and code from my talk at Django User Group London  on running Django on AWS Lambda are now online. This included a live coding demo which surprisingly went off without a hitch. Clearly the earlier sacrifice to the demo gods had been accepted.



Thanks to Karl for the invitation to speak, and thanks to the audience for the excellent questions.


OS X Mavericks: Fixing broken Python development environments

Upgrading to OS X Mavericks (10.9) broke my Python development environment by deleting the contents of  /Library/Python/2.7/site-packages and X11. Why an OS upgrade should be deleting things I put there is another question, but here’s how to get back up.

My Mac Python setup is reasonably standard I think: I use a system-wide install of some basic stuff (virtualenv, pip, easy_install) and then virtualenvs for all development.

After upgrading, existing virtualenvs were fine – the problem started when I wanted to create a fresh one. Suddenly virtualenv wasn’t there, and once virtualenv had been restored pip found it impossible to build several of the libraries that I depend on (including Pillow, lxml, gevent – basically anything with a C library dependency).

Step 1: Get virtualenv back

cd /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command
python virtualenv

Step 2: Create a virtualenv and try installing the modules you need

virtualenv <path>
pip install -r <your requirements file>

If all installs fine, then you’re done! If like me you get errors, here’s some of the things that are probably missing:

Step 3: Reinstall X11 (required for Pillow / PIL)

Download from

Step 4: Reinstall XCode command line tools

Install the latest XCode (currently 5.0.1) then install the command line tools:

xcode-select --install

Step 5: Repair homebrew

If you’re using Homebrew for access to various open source packages – and I strongly recommend you do – then you may need to repair things.

brew update
brew upgrade
brew doctor

and follow the recommendations

After all this, you should find you’re back where you were before Mavericks, and able to build and install Python modules. Happy hacking!

Sniffing iOS and Android HTTP traffic

Sometimes when you’re debugging a problem with a remote server, only seeing the actual bits on the wire is good enough. Recently I needed to do this to confirm whether it was my app or the server that was causing a bug.

In the past I’ve used HTTPScoop and Wireshark to debug this sort of problem, but recently I’ve discovered a much better option for anything that’s passing over HTTP – which these days is most things.

My new go-to tool is Charles. This is a great cross-platform (Mac, Windows, Linux) logging HTTP proxy with all sorts of nice features – including SSL proxying, so you can see what’s going to/from Facebook or other web services over https!

Here’s a step by step on getting Charles working with your iOS or Android phone, including the SSL proxying. Continue reading