Using boto to manage Route 53

Recently there was a bit of an issue with MediaTemple’s DNS servers. So to get a few of our clients back online, we added their DNS info to Amazon’s Route 53 service. As of this post, there is no official interface to manage this information beyond the REST API.

Luckily the latest editions of the boto Python library supports route 53, but there aren’t many examples of how to handle some of the code with boto. So here’s what I did:

Note that you’ll need to likely get a version of boto from the source to get the Route 53 functionality.

Using ffmpeg to get number of MP3 channels (mono/stereo)

Today we found that we had some MP3s that were only had a single channel (mono). I’ll spare you the details why it matters, but if you want to find the number of channels in an audio file, create the following shell script (assuming you have ffmpeg):

Then you can run:

$ bash channels.sh my.mp3
my.mp3: Channels: 1
$ find somepath/ -name "*.mp3" -exec bash channels.sh {} \;

iOS: Downloading and parsing JSON

Recently I set out to update an iPhone app with the ability to accept updates from our server. The plan is to let the app download a JSON file off our web server and update the internal data accordingly. Pretty simple right? It is pretty simple, but many tutorials focus on some aspects that don’t fit with ever project out there so I hope this contributes some “basic knowledge”.

To keep this simple, I’m only going to concentrate on downloading the data from a server and parsing that data. No Core Data, no SQLite, no table views. I’m not going to tell you how to build a Flickr app or a Twitter app. Just download the data and parse. What I’m using: Xcode 3.2.5, ASIHTTPRequest 1.8, and JSON Framework 2.3.1.
Continue reading

Django hostname middleware

Recently I wanted to enforce the hostname in a couple Django-based projects. By default, Django really only allows you to enforce that a “www” is present in the URL. To me this seems rather one-sided as several sites may need:

  • To enforce that the “www” is not present
  • Or that an alternate domain name resolves to the primary domain

So I created the following middleware to enforce hostnames and submitted it to be added to the core (which was rejected). But in case you need to enforce the domain that visitors to your projects use, you may find this to be handy!