These pages describe things I've done which primarily involve coding. Some of these may be useful. Currently, we have hacks, mini-projects, and recipes. I also maintain a page of my Projects.
Created Tuesday, 2011-04-05 — 22:03.Last update 1 week ago.
A short Javascript program to improve detection of users idling or away from their keyboards, which should in turn improve how online users are detected. The file works with both jQuery and Prototype. It autodetects which is available at load time. Putting an AJAX request in one of the handlers can notify the back-end about the online state of a…
Created Monday, 2011-04-11 — 11:03.Last update 2 months ago.
A while ago my work bought a tape library with a barcode reader. By that time, we were making heavy use of AMANDA for our backups, and we needed to keep the physical tape labels in sync with AMANDA's tape labels as stored on disk. Unfortunately, the preprinted labels that came with the drive weren't very good. We looked into…
Created Wednesday, 2011-04-06 — 13:28.Last update 5 months ago.
You have a deep directory tree of files, and you need to flatten it into a single directory, so that there are no files in subdirectories, and all the files are in the same place.
all the filenames are unique. If they're not, some will get overwritten (using the cp command), or not linked (using the ln command).
==Solution==
cd $ROOT_DIRECTORY_OF_TREE
find -type f…
Created Wednesday, 2011-04-06 — 13:48.Last update 5 months ago.
You need to generate Pascal's Triangle in Python, and you're lazy (an admirable trait). Alternatively, you're looking for a Pascal's Triangle generator that can show really high-ranking rows, ones with multi-hundred-digit (or multi-million-digit) coefficients.
==Solution==
Here's the essential, unadorned code:
def pascal(n):
"""
Yield up to row ``n`` of Pascal's triangle, one row at a time.…
Created Thursday, 2011-10-13 — 20:41.Last update 5 months ago.
You run a medium-to-large size MySQL server with lots of databases, possibly for hosted websites. You've experienced performance degradation. You've fine-tuned your database engines, and no joy. Then you finally realise you need to run mysqloptimize, and the day is saved! Good on you. Of course, running mysqloptimize on a large server still takes half an ice age. Maybe you…