Code

Here are bits of code I've written over the years to accomplish some specific task. Mostly I've put it up so that I can remember how I accomplished something when I need to do it again. But maybe it'll be useful for you. If it is, consider it to be released under the BSD license, unless otherwise noted.

Reinteract Extensions

Reinteract is an incredibly nifty way to use Python. It gives you a worksheet into which you can enter Python code, and it keeps track of changes so that you can edit code and still get consistent results. It also provides an extension mechanism by which you can embed arbitrary GTK widgets into the worksheet.

refigure2
The refigure2 extension embeds matplotlib figures in the notebook, in a different way that the built-in replot. See the website for more details.

Geany Scripts

Geany is my current text editor of choice. The Lua plugin for Geany allows you to write scripts (in Lua) triggered within Geany. I've written two:

detach-tab.lua
Geany only offers a single window at a time, with a tabbed interface. Somtimes I want to look at two files simultaneously. This script fakes detaching a tab by closing the current tab and opening that file in a new Geany process. This requires that the file be saved, and the undo buffer is lost, but it tends to work well enough in practice.
image-tag.lua
Inserting a HTML image tag with the proper size can be a slight pain. This script treats the word under the cursor as a filename, uses ImageMagick to get the file size, and replaces the filename with a full image tag.

Shell Scripts

Basically, a collection of one-off scripts that refused to die. None wins style points, but they're all functional.

backup.sh
There are all sorts of clever rolling backup solutions out there, but I just wanted one that just stored the backup by date, letting me decide which to delete and which to keep. This will backup all files in /home/ to $BASEBACK/yyyymmdd/. It must be run by root.
catpdf.sh
The Numerical Recipes book comes as with each section as its own PDF file. This script joins them together into a single PDF, properly stripping out the repeated pages. Requires pdftk.
startSynergy.sh
Synergy is a nifty way to share a single mouse and keyboard among computers. I use it to be able to control both my laptop and desktop with a full-size desktop keyboard. Synergy transmits keypresses in the clear, so I feel much better about tunneling it though SSH. This script does just that. It checks if the synergy client or the SSH tunnel exists before creating a new one. (This is for the client machine; the server is started as usual.) The $knownIP variable contains a list of default servers to connect to, given the first three-quarters of the client's IP address.
synaptics.sh
Every 18 months or so, Ubuntu feels the need to change how you configure your touchpad. First, it was by x11.conf, then xorg.conf, then HAL, and now it's…well, I'm really not sure. So I run this script at the beginning of my session. This works in Ubuntu 9.10, but don't count on it not breaking in the future.
toggletouchpad.sh
My netbook doesn't have a hardware button to disable the touchpad. So I bound this script to one of the function keys.

Python Scripts

Python is a wonderful scripting language. With NumPy, matplotlib, and SciPy, I've almost replaced Matlab in my scientific programming. It's also good for scripts and user interfaces.

disablescreensaver.py
A little PyGTK app with a button to disable the screensaver. Useful for giving presentations or watching Flash videos. Requires PyGTK and probably only works under GNOME.
sewrap.py
The Surface Evolver is a nifty bit of software for minimizing just about any energy you can imagine on a manifold. It comes with its own language and interactive prompt, but this prompt doesn't have any line-editing capabilities. This script wraps as readline shell around the Surface Evolver prompt, giving you line editing and a history. It also gives you a variable named pid with the current process ID, useful for making unique filenames for backups, for example. Requires Readline.