Easy Django management commands with autogenerated aliases

Recently, I got sick of typing django-admin.py <command> to run Django management commands and decided that something must be done about it. This is what I came up with:

This little script creates short aliases for all available Django management commands. Typing this every time you want to work on your project obviously defeats the point, so I added it to bin/activate which is created by virtualenv (you do use virtualenv, don’t you?). I actually do this in a bootstrap script, using this snippet:

If you use virtualenvwrapper, you can append the script to the bin/postactivate script instead.

I know there is bash completion for Django management commands. The advantage of my solution is that it is available for every developer on the project after running the bootstrap script. And it is one character less to type.

To run django-admin.py syncdb, just type djsy<TAB> instead of dj<TAB>sy<TAB>.

What’s in a name? A MPMoviePlayerController pitfall

I was struggeling playing a movie file on iOS with MPMoviePlayerController. The file was just recorded with AVCaptureMovieFileOutput and was called file.avi, located in the Document directory of the app.

The movie player was presented and then immediately disappeared. The URL was correct, the file played without problems on the Mac. Apparently, MPMoviePlayerController expects the file ending to match the file type. Once I renamed the file to file.mov, everything worked as expected.

Hacker News Aftermath

After I submitted my review of Hacker News iPad Apps to Hacker News, it shortly made it to the frontpage, with the result that the thundering horde quickly exhausted the tiny traffic quota I had at my hoster. I’ve decided to migrate to another hoster and if you read this, the DNS change has reached your corner of the Intertubes.

If you notice broken links or anything else that is flaky, please let me know on Twitter (@danielhepper) or drop me a mail at daniel [at] hepper [dot] net. Thanks!

A review of all available Hacker News iPad Apps

Browsing Hacker News on the iPad is okay, but far from perfect. As of this writing, there are five Hacker News iPad Apps available on the App Store that promise a more comfortable experience:

I took the time (and money) to try them all, this are my findings.
Continue reading

How to make a Pac-Man ghost lamp

In this post, I will show you how to make a Pac-Man ghost lamp. You can also find it on Instructables.

To be precise, we will create small ghost lamp shades to turn a boring spotlight system into a great looking Pac-Man themed lamp.

You will need:

  • plastic bottles with the right shape
  • a lamp, preferably a halogen spotlight system
  • some white and black plastic
  • spray paint in red, pink, cyan and orange

Once you found the right bottles and a nice lamp, this project will take about 2 x 2 hours.
Continue reading

Fixing a messed up Vagrant installation

I’m currently struggling with what seems like a bug in Virtualbox that affects the new Core i7 MacBooks. While trying to fix it by building Virtualbox from source, uninstalling and reinstalling, I managed to mess up a box managed with Vagrant, rendering it inaccessible.

If you find yourself in a similar situation, you can try to fix it with the VBoxManage command.

$ VBoxManage list vms
"" {b68ed7a7-6e72-4f16-a438-8775cd80d9b3}
$ VBoxManage unregistervm {b68ed7a7-6e72-4f16-a438-8775cd80d9b3} --delete
VBoxManage: error: The object is not ready
VBoxManage: error: Details: code E_ACCESSDENIED (0x80070005), component Machine, interface IMachine, callee nsISupports
Context: "Delete(ComSafeArrayAsInParam(aMedia), pProgress.asOutParam())" at line 175 of file VBoxManageMisc.cpp
Segmentation fault

As you can see, it died with a segmentation fault, but the broken box was now gone and I could restart it with vagrant up.
Continue reading

Change order of PATH entries on Mac OS X

I wanted to have /usr/local/bin to be listed before /usr/bin in my PATH environment variable.

One way to achieve this would be to add a ~/.profile file with a line like this:

export PATH=/usr/local/bin:$PATH

This would result in /usr/local/bin being listed twice. It wouldn’t hurt but it’s not pretty either.

If you look at /etc/profile, you will see that the initial value of PATH is set by path_helper(8).

The right way to change to order of default paths is to edit /etc/paths. It contains one path per line, in descending order. Mine looks like this:

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin

Using Python Packages – An Overview

Yesterday I gave a presentation at PyCologne about Python packages. It was meant as a kind of sequel to the “Cooking Eggs” talk given by Christopher Arndt (in German) in September. While he presented ways to create Python packages, I focused on how to use Python packages.

Python comes with batteries included, but sometimes, battery power is not enough. Thankfully, there are countless packages available for use. Given that there “should be one– and preferably only one –obvious way to do it,” using Python packages can be quite intimidating. The documentation of your package might say to download, unzip und run python setup.py install. Meet distutils. Or just do easy_install MyPackage, which is uses setuptools. But then you hear that setuptools is superseeded by distribute and instead of easy_install, you should use pip. And then there is virtualenv, which is awesome, but can be even more awesome with virtualenvwrapper. What a mess!

My conclusion: use distribute, pip, virtualenv and virtualenvwrapper.

You can download the slides or view them with Slideshare:

Verify AWS free tier

Starting from November 1st, Amazon offers a free usage tier for new AWS customers. After finishing the horrible signup process, I was left wondering wether the free usage tier was activated for my account.

To find out, just start an EC2 micro instance*. Don’t forget to stop it. After some time, go to the account activity page and click on “expand all services”. You should see something like this:

* This will cost you a few cents if you don’t have a free usage tier.