Code Samples

I thought that I had to dump specific columns from a table. In the end I needed to parse the resulting XML with a script anyway to convert it to CSV, but here is a reminder for myself (and maybe you): more

There were packages of salt 0.10.1 in backports but they were removed, and the only saltstack packages in Debian are now in unstable. However, building your own backport is quite easy. This assumes you have an up to date Debian squeeze install without any backported saltstack or other packages. Use … more

Update: See also http://kuttler.eu/code/wordpress-emergency-admin/ which is a little easier to use. Recently I had to update a site but didn't have an admin account or access to the SQL database. So I wrote this short script to reset a forgotten password. To use it, edit it and fill in the … more

Looking at the code I'm really not sure how it could have taken me more than one minute to figure this out.. but here's an example how to query for documents with a timestamp in the past. Your model's schema obviously needs a timestamp field of the Date type, and … more

Mongoose is quite easy to use, but modifying or annotating a query result manually is a little tricky. The problem is that the result objects are mongoose documents that can't be modified at will. In my case I was trying to change a Date type field to a human readable … more

Are you getting "You do not have sufficient permissions to access this page." errors everywhere in the WordPress admin? I had this happening on a site, apparently the problem is that somebody changed the database prefix. It's a little suprising that this would totally break the admin, but whatever... As … more

I thought there was a simpler method of adding context through the urlconf but after having a look at the source this is what I came up with. Apparently there's only get_context_data() so I used a lambda to add what I needed. Update: I should probably have used extra_context={'model': 'Frontpage'} more

So I had this project with a peculiar requirement: It had to do a redirect to an existing object when the CreateView failed because such an object already existed in the db. Not really hard to do but it took me a while to figure out.. so here's the code. more

Update: This script is almost obsolete as github will switch to their v3 API on may 1st, 2012 and doesn't display the API token any more... With this this script you can easily migrate a WordPress plugin from the wordpress.org svn repository to github. This script will NOT import the … more

Very annoying typo3 "bug" and it took me long to find a solution. See this Bug report for some more info. more