All little pieces of code that don't really fit anywhere else. All are released under the GNU Public License (GPL) unless otherwise indicated.

high_precision_mysql_timer.c - a LD_PRELOAD to make mysql command line client have higher timer resoltion

see this blog post: http://www.flamingspork.com/blog/2011/02/08/timing-queries-in-the-21st-century-with-ld_preload-and-sed/

mysqlbug.py Deskbar plugin (handler)

The Deskbar is a GNOME panel applet that lets you hit (for example) Alt-F3, type in a search query and take action on it. This lets you type "bug11459" and has an Action of "Open MySQL Bug 11459". It also lets you type "edit bug 11459" which will jump to the edit bug page. This should be useful for developers


You've always wanted to be able to see the output of stat on the command line! Yes, you know you have! Here it is.


Small command line PHP4 script to generate a random string (good for generating passwords.


Shows how you can fork off something into the background. Useful for starting jobs and having them run detatched.


Makes a sparse file of nothing. Useful for creating empty disk images.


Borne out of weirdness going wrong with a friend's compact flash card while we were on holiday - suddenly a bunch of photos went missing. It didn't seem to be easy to recover them using conventional manipulations of the FAT filesystem, so instead (without an internet connection, but with lots of beer) hacked up a program that searches through a file (given as the command line parameter) extracts things that look like jpeg files and dumps them in the current directory. It can produce a number of false-positives, which is probably due to the fact that I didn't have access to any jpeg specs, so this is all from looking at some jpeg files and working out something simple, quickly. But hey, we got a fair few of the photos back.


Simple program that shows how GCC predefined macros can be used to aide debugging output


Quick proof-of-concept type program using librsync to generate rsync signatures to (in future) use to generate diffs for incremental backup. Really needs work to make it actually useful.

LaTeX Word Count

I wrote a little shell script wc.sh which strips out LaTeX tags and pipes the result to wc -w so you can get a (pretty accurate) word count on a LaTeX file. Provide the (single) .tex file as a command line argument.

MacOS X address book vcf to Evolution vcf

For some reason, the OSX address book and Ximian Evolution behave differently when it comes to phone numbers and their VCard export. I used this perl script vcf.pl to convert my exported vcf file to something that Evolution would import correctly. Previously, evolution would import things correctly (you could see it in the data files), but evolution wouldn't display the phone numbers.

Tru64 to FreeBSD Account Migration

A couple of Perl scripts I wrote to help aid the user migration for YoYo. We were going from an AlphaStation running Tru64 to FreeBSD on a dual Xeon and needed a way to get about 1600 user accounts (preferably keeping the passwords intact) from the Tru64 machine to the FreeBSD box.

The first script, migrate_accounts.pl runs through /etc/passwd and prints out a script that will create the user accounts on FreeBSD (using the adduser command). This way, all the databases are updated correctly. Run the perl script on Tru64, saving the output to a file. Then, run this file as a shell script (as root) on FreeBSD. It's probably a good idea to look at it before you run it though to ensure sanity :)

The second script, migrate_passwd.pl uses the Tru64 edauth program to extract the crypt()ed password of each user. FreeBSD understands crypt passwords, so each user can use their old password on the new system! However, if for some reason some of your users have passwords in the crypt16 format, you're out of luck and will have to get them to change it before they can log into FreeBSD. Patches accepted to fix this! This script should be run on Tru64 (as root) and generates a shell script that should be run on FreeBSD. On our machine, it took a while to do this, so go grab a coffee. There is also a translation table at th top of the script which allows you to translate your users preferred shells from where they were on the Tru64 box to where they are (or will be) on the FreeBSD machine. As you can see, we had some misspelt ones too!

I also insisted we get away from ugly mbox stuff (cpu intensive and easy to corrupt) and transition to Maildir style mailboxes. This makes IMAP a lot saner. To get the /var/spool/mail stuff into Maildir, I ran create_user_maildirs.pl in /var/spool/mail, which created each user a Maildir and imported any pending mail. Then, I used the pine2maildir.pl script (which uses the exelent mbox2maildir.pl script - not written by me, see the file for author details) will aid in migrating users from a PINE style mbox folder layout to a Maildir one. You can still use PINE (if you're insane) by using IMAP to localhost. We use courier-imap, which is excellent (it 'just works').

Hope these are useful. Comments welcome: stewart at flamingspork dot com

Tridge's Disktest GCC 3 Compile fix patch

Makes http://samba.org/ftp/unpacked/junkcode/disktest.c compile under GCC 3.0 and above.

Patch: disktest-gcc3.patch

my .tcshrc

Mainly used on MacOS X, helps set up a slightly more sane tcsh.

Code: tcshrc.txt

Open Diary Import

When moving my blog to MovableType from the Free OpenDiary (which was formerly OpenDiary) I needed to bring all my old entries across (mainly for archival purposes). Out came the perl skills and I wrote this script to change the format of FOD's export to a format that is importable by MovableType.

ODimport.pl Pass the OD file in as an argument to the perl script and it outputs it to stdout

Universal Linked-List C Code

This has been jumping from project-to-project over the past few years, implementing just enough of a linked list to be useful, but not everything. You're welcome to expand and contribute back. It uses void pointers as the item, so you can store anything in one of these babies

Code: list.tar.gz
Documentation: Online HTML

We aim for full XHTML1.1 and CSS2 compliance. If your browser doesn't render it properly then get a better browser.

Valid XHTML 1.1! Valid CSS!

$Id: index.php,v 1.16 2006-06-29 14:53:19 stewart Exp $