Code Samples
Mount samba shares from fstab
So... I had to check my backups just to figure out how to mount my shares. How annoying is that? On Debian-based systems you need to install cifs-utils. more
Change initial header level in docutils
I use reStructuredText on parts of this site to write HTML content. But as the main headers don't originate from the rst content I need to start with an h2 tag. It's just a matter of rtfm but here's a solution. more
Cache busting with nginx
Here's a little snippet for cache busting without abusing a query string which can lead to caching problems. The example below will rewrite paths like /css/foo_20130401-5.css to /path/to/static/css/foo.css on the static.example.com host. more
Django almost spaceless template tag
Django has a {{ spaceless }} tag that's a little too greedy for my taste. Removing all whitespace between HTML tags can actually change what the browser renders, so here's a less greedy variant. However, it removes all whitespace, not just between tags, so if you use the pre tag ... more
Keyboard MB110 on Linux
So I got myself a new keyboard. It's an Apple MB110 (D/B variant). Works flawlessly in xorg after configuring it. more
MySQL dump specific columns
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
How to build salt backports on Debian squeeze
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
WordPress password reset
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 proper values. Then upload it to the wp-content/mu-plugins/ directory, create the ... more
Mongoose query by date
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
Modifying mongoose query objects
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