Converting a south 0.7 migration back to 0.6

I had a minor fight with south earlier today, where someone had created a migration with south 0.7, and I needed it to work with south 0.6.

Needless to say that it would be a pain to manually convert it from the better 0.7 format back into 0.6, so I wrote a fairly small python script, that does the job.

Continue reading

Managing multiple AWS identities

I’m running multiple different project on AWS which was so much of a pain to use, as I often find myself having to use the identity of project-a together with the official amazon ec2 tools.

To help myself manage the multiple identities, I wote a set of bash functions, called:

  • aws_load <config-name> – loads configuration from config-name
  • ec2ssh <instance-number-in-ec2din-list> – ssh’s into a given instance, with the root key
  • ec2scp – a shorthand for scp -i <keyfile>

    Continue reading

Django – sharing a memcached instance

Update: Some Curious User brought to my attention, that a ticket has been opened which, when implemented, will add a setting for a cache prefix. It will also allow other cache key manipulations. Django has implemented KEY_PREFIX in the development version, which currently means, that it will be out in 1.4 iirc. Django 1.3 has implemented KEY_PREFIX which solves the problem once and for all.

Until recently I’ve been using the file:// django cache, but that has a “problem” when multiple users needs to manipulate the cache (think uid 80 writes a key, that uid 1000 wants to delete).

My problem with the memcached:// django cache provider has been, that it cannot handle being used on a shared memcached instance, because of the danger of key collissions.

Continue reading

Django compatible PyAMF test client

While working on a project using PyAMF today, i was about to write a unittest of a service method, when I realized that it would be harder than necessary to make unittests of the service. The cause of this is, that there was no test client wrapper for the django test client for pyamf, which means, that to do a unittest of the gateway, you’ll have to start a django server, and run a unittest elsewhere.

Seeing as how there are a lot of benefits to using djangos own test suite (fixtures and automatic database generation to name a few), i set out to write a little test client for PyAMF to utilize django’s test client, so it would be possible to write a proper test suite.

This turned out great, and is now ticket 508 over at PyAMFs trac. Look at the client.py for the code. At some point, it will be integrated into PyAMF mainline as p.r.c.django.TestClient (or something like that).

Choosing a font in Carbon Emacs

It took me a while of messing with fontsets and various other settings, before i came across how to select fonts in the Emacs wiki:

  1. M-x mac-font-panel-mode and pick the font you want.
  2. M-x describe-font and copy the font name (e.g. “-apple-inconsolata-medium-r-normal--13-130-72-72-m-130-iso10646-1”)
  3. Add the following to your .emacs file: (set-default-font "-apple-inconsolata-medium-r-normal--13-130-72-72-m-130-iso10646-1")

In my case the lines for font selection looks like this:

(set-face-font 'default "-apple-proggytiny-medium-r-normal--11-110-72-72-m-110-iso10646-1")

Using this to make the font display without antialisaing:

defaults write org.gnu.Emacs AppleAntiAliasingThreshold 100

And this to position emacs in the top left, and be 104 chars wide, and 64 high.

(setq initial-frame-alist `((width . 106) (height . 64)
			    (top . 0) (left . 0)))

And of course some other tweaks. Re-learning emacs is turning out to be a good idea. But that’s another story.

A ongoing discussion about C and libmemcached – don’t censor me

And there I was, happy as a 4-year old who had just found a whole box of strawberries.

Then all of a sudden, along came a post about how Amir Salihefendic had made a little daemon in C, using libevent and memcached, that would allow him to cache a http request in memcached. I don’t quite get why one would like to reinvent a reverse http proxy like that, and stated my arguments on why I thought that this seemed like a really bad idea.

As you can tell from the comments, he did not agree. It ended up with him deleting my last comment. Good thing I kept a copy in my clipboard. So, here are the comments. Continue reading

Using mercurial with eclipse to edit actionscript files on os x

We have recently switched to use mercurial as our DVCS. We’re hosting our many repositories on bitbucket.

I love it.

When it comes to actionscript files, flash has always had odd newlines. For some reason, it has always used r as it’s newline. Mercurial, beeing a unix tool, likes it’s newlines to be n. So what better to do, than to make mercurial encode/decode the files for us.

To do that, we can simply add the following to our .hgrc file:

[encode]
*.as = perl -pe 's/r/n/g'
[decode]
*.as = perl -pe 's/r/n/g'

I don’t really know wether the decode part is necessary, but I like to keep it around (if someone should commit poison).

Mercurial trac commit hook

Having searched a lot around google, it does not seem that anyone has published their trac commit hooks for mercurial. Since I had to use just that, I’ve cooked up a little hook which is based on the hook from the timingandestimationplugin. I’ve created it as a changegroup hook, and it’s probably filled with bugs, but it seems to work and it catches the fixes #42 and such.

To use the hook you must place it somewhere inside your PYTHONPATH and tell mercurial to use it (I placed it in a module called trachook — don’t call your module trac):

[hooks]
changegroup = python:trachook.hook

And tell the hook where to find your trac installation:

[trac-hook]
root = /path/to/trac
url = http://url/to/trac

Grab your own copy of the source, and happy coding. And a big thank you to Jesper Nøhr.

Also, if you need a place to host your mercurial repository but don’t wan’t to set it up yourself, check out bitbucket.