| marginal hacks | ||||||||
|
So, here's some stuff. I wrote these programs because, at some
point, I needed them. That means they are not necessarily very
pretty, but maybe you'll find some of them useful. A lot of
this is not the greatest code in the world (in particular, some
of the Perl programs below were written a long time ago, when I
was just learning | ||||||||
| http10proxy | Have you ever wanted to run a really, really old web browser, like one from 1994? I have. If you have, you may have discovered that they don't work with most modern web servers, because they spoke HTTP/1.0 instead of HTTP/1.1. Specifically, they don't send a "Host" header, and don't understand the "charset" parameter in "Content-Type". However, if you point one of these antique browsers at this proxy server, it will translate. (To run those old browsers on modern Linux systems, you'll also need some old libraries.) | |||||||
| mp3dir | This is a CGI that gives your web server prettier directory listings for directories full of MP3 files: instead of just listing the file names, it will display the ID3 data for name, artist, album, etc. It will also include a link to a (generated) zip file of each directory. | |||||||
| rotimg | Losslessly rotates a JPEG image (using jpegtran). Preserves (and updates) the existing EXIF data, if any, including also losslessly rotating the embedded thumbnail image. | |||||||
| sms-backup | A perl script that runs sms2csv to extract the log of SMS messages from a Palm Treo and logs the messages to text files, with one file per conversation per month (analagously to the way most AIM and IRC clients archive things, instead of just dumping it all into one file). It's careful to never delete old archived messages, even if the phone's SMS log has shrunk or vanished. | |||||||
| google-itunes | There are a zillion programs out there that will try to automatically download album artwork for iTunes tracks, mostly by searching Amazon or the Apple store, but I've found that just feeding the artist and album name into Google Images and dragging the images in by hand is the most reliable way. This script gets the list of selected tracks from iTunes, and opens multiple browser windows running Google image searches. | |||||||
| itunes-recent | This perl script generates an HTML page listing the music that has been added to your iTunes library in the last 90 days. It does this by interrogating the running iTunes via AppleScript. (It's possible to generate such a list manually from iTunes by creating an "added in the last 90 days" smart playlist and exporting the list; but this script is suitable for use from cron.) | |||||||
| id3-clean | This perl script walks through a directory of MP3 files and deletes any ID3v2 frames that aren't used by iTunes. I find that I have a lot of useless crap in my MP3s, left there by whatever software happened to rip them or touch them in the past. This removes all the cruft that iTunes can't edit (since, by my estimation, what iTunes can't edit or display might as well not exist). As a side-effect, it will also upgrade the ID3v2 tag to the latest version supported by the MP3::Tag Perl module (currently ID3v2.3). | |||||||
| id3-check | This perl script walks through a directory of MP3 files and points out trivial spelling differences in band names, e.g., if sometimes you used "Pixies" and sometimes used "The Pixies". | |||||||
| emlx | This script knows how to parse the (undocumented) .emlx mailbox files written by Mail.app on MacOS X 10.4. With it you can, for example, get a list of all unread messages in your Inbox. In this way, you can remotely ssh in to your Mac and easily peek at whatever messages Mail.app has downloaded while you were away. This can also convert Mail.app folders back into standard BSD "mbox" files. | |||||||
| mvpix | This script is how I get pictures off of my digital camera. It files each image that it moves from the card into an appropriate directory of the form YYYY-MM-DD, and does some clever tricks to divide multiple "sessions" on the same day into different directories: e.g., when 30+ minutes has passed between photos, it starts a new directory. This script works on both Linux and MacOS X. | |||||||
| cvslogall |
This script is like
| |||||||
| bookmarklets |
A few bookmarklets (clickable JavaScript functions) that manipulate
the URL of the page you're looking at:
| |||||||
| wgetn |
A wrapper for wget to
download numerically contiguous URLs based on a format string; for example,
| |||||||
| mirror |
A wrapper for wget
that automatically computes a proper --cut-dirs value based
on the number of directory components in the given URL. E.g.,
| |||||||
| gallerydown | I wish people wouldn't use the creatively-named software called "Gallery" because, well, it sucks in all kinds of ways. But the most irritating way is that the URLs it produces are non-hierarchical, meaning there is no "wget" incantation that can mirror it without mirroring the entire site. So, here's a Perl script that parses the HTML and downloads the large versions of all the images in one of those. | |||||||
| flickrdown | Same thing, but for mirroring Flickr galleries. | |||||||
| youtubedown | Given a YouTube URL, downloads the underlying FLV (Flash Video) file, with a sensible file name. | |||||||
| pf-mode.el | An Emacs mode for editing OpenBSD "pf.conf" files, with font-lock highlighting. | |||||||
| resizeimg | Resizes all of the image files passed on the command line to fit within the given bounding rectangle. Any existing EXIF data is preserved. | |||||||
| gimploop | For each file on the command line, runs "gimp-remote" to load that image into GIMP; then waits for you to hit return before loading the next one. Also makes sure that GIMP is running first. | |||||||
| mork | This script lets you extract the URLs from your Mozilla history file, sorted by last access time. There were scripts to do this with every version of Netscape Navigator, because it stored history in a straightforward Berkeley DBM file. Sadly, the Mozilla folks saw fit to replace that with a brand new database called "Mork" for which no tools exist. So I wrote this to parse Mork and spit out the URLs. Mork sucks. | |||||||
| validate | A small HTML validator: really all this does is make sure your tags are balanced, and that your tables aren't missing TRs around the TDs. There are much more fully-featured validators out there, but I haven't found them very useful: when all I want to know is "you left out a </UL>", they tend to spend their time whining at me about "where's your DTD?" and similar nonsense. | |||||||
| scrmable |
I raed a scrmabled-up peice of text taht cliamed that
| |||||||
| multalt |
This is a script that converts an HTML document into a
multipart/alternative mail message, with a text/plain first part, and a
text/html second part. It produces very readable text/plain parts.
The most interesting part of this script is that it contains a simple HTML parser that does a reasonable conversion of HTML to plain text. It handles most interesting tags: it does nested indentation for UL, OL, BLOCKQUOTE, etc; it handles PRE; it handles character entities; it wraps paragraphs. (It does not, however, handle TABLEs.) Quoted-printable encoding will be used when necessary. When QP is used, lines are broken at word boundaries instead of merely every 72 characters: this means that the QP-encoded text will be highly readable in raw form, unlike most QP text you've probably run across in the past. | |||||||
|
jwz-lj.el monkeybutter.el | A simple Emacs mode for posting to LiveJournal. There was one out there already, but it doesn't work with XEmacs, so it was of no use to me... Closely related is monkeybutter.el, which is an Emacs command I use for forwarding amusing messages on to a mailing list I maintain, and sending it to LiveJournal at the same time. | |||||||
| irc2html | This is a script that converts raw IRC logs into a readable HTML form, with wrapped lines, clickable links, etc. IRC color/font codes are also handled. This script works from the command line, or as a CGI web page. | |||||||
| check-links | I guess everybody has written their own version of this; well, here's mine. This script checks for dead and/or moved links in the given HTML files. It parses the HREFs out of the HTML, then does a GET on each of them (not a HEAD, because that doesn't work with all sites) and prints out a list of URLs that were not retrievable, or that redirected to elsewhere. | |||||||
| gallery | Everybody has also written their own image-gallery thumbnail-generator script. Guess what, me too. This makes thumbnails of images and generates HTML index pages. You can control the maximum pixel width of the page (it fits as many thumbs on a line as it can) and the number of lines per page. The thumbs can also have table-ized captions beneath them. For an example of what this script generates, see the DNA Lounge photo galleries. | |||||||
| jwz-html-mode.el |
I hate the HTML mode that XEmacs comes with: it does too much
second- | |||||||
| copyright-image | This script slaps a copyright notice into the comment field of a JPEG, TIFF, or GIF image, by using wrjpgcom or giftrans, as appropriate. Update: Now it also writes the copyright info into the EXIF data, using exiftool. (Note that Canon RAW files are actually TIFFs, so it works on those too.) | |||||||
| interlace-gif | This is a little script that makes a GIF be interlaced (or non-interlaced) without changing whether it is transparent. You have to use both giftopnm and giftrans to do this, so this encapsulates the various steps. | |||||||
| gdb-highlight.el |
This is a package that makes Emacs's gdb-mode much more usable by
making almost everything that shows up in the *gdb* buffer be
clickable, and have a context-sensitive pop-up menu of commands on
the object that have been printed.
(Some people, when confronted with a problem, think ``I know, I'll use regular expressions.'' Now they have two problems.) | |||||||
| undoc | This is a really simple perl script that converts MS Word `.doc' files to plain text. It's only slightly better than running strings on the file, but it also re-wraps paragraphs, and converts some Windows characters to their Latin1 equivalents. | |||||||
| jack |
A predecessor of the XJack hack from
XScreenSaver;
I won't spoil the joke, but will instead just tell you:
| |||||||
| whois | The parasites at Network Solutions have cripped the WHOIS server, but you can still get actual information out of them if you go to a particular URL. This is a script that duplicates the historical behavior of the whois command-line program by connecting to the appropriate URL. Lots of people have probably written their own version of this script, well, so did I... (Though recent versions of Linux seem to come with a /usr/bin/whois that works again, so I don't use this any more.) | |||||||
| nntp-to-mbox | Have you ever wanted to convert the contents of a newsgroup into a mail folder? I did once, and so that's what this script does. Point it at your news server, tell it what group you want, and optionally, what message to start at, and it will write out a properly-quoted mbox file (the kind used by Netscape, Eudora, and just about all of the Unix mail readers.) | |||||||
| folderstat | This is a script that prints out some statistics about the messages in an mbox folder, e.g., to show who the most prolific posters to a mailing list are. It prints out a table of stats sorted several different ways. | |||||||
| xmtr | I like the MTR program; I wrote this script before there was a Gtk interface for it. This script makes it easier to use under X, by opening an xterm window and prompting you for a host name; and if you just hit return, it lets you select from the hosts to which your machine has active connections. | |||||||
| mtr.command | A variant of the above xmtr script for MacOS X: place this in your dock, and opening it will launch a Terminal window running mtr. | |||||||
| worth |
Do you hate your job? Are you only still there because you're waiting
to vest? I feel your pain, brother. The only thing that kept me from
leaving Netscape in 1997 and walking away from a dumptruck full of cash
in frustration was this script. I ran this every morning for at least
a year: it prints out the following motivational message:
Hang in there, little trooper!
Only It's amazing how this script can put it all back into perspective and keep you from going postal and strangling someone. Fill in your numbers, and let it remind you not to do something you'll regret later. As I'm not maintaining this any more, you may also be interested it a descendant of it over on dzm's site. He's added more features. | |||||||
| mgrep | This is a CGI that I used in the early nineties for searching through my saved email. I index my mail with Glimpse, and this CGI does Glimpse searches, then turns the results into clickable mailbox: URLs, so that I can see the matches, properly formatted, in my web browser. But that only works in Netscape 3.x, because the boneheads responsible for the 4.x mail reader screwed up the way the mailbox: URL works. These days I search my mail with Spotlight on OSX, and it just works. | |||||||
| audio-tape.ps | This prints j-cards for cassettes, cartridge tapes, 8mm tapes, DATs, and CD jewel cases, does all kinds of automagic font scaling, and has the ability to include graphics. It is implemented completely in PostScript and is thus totally out of control. (I've hardly touched this since 1994, since I don't use cassettes any more.) | |||||||
| video-tape.ps | Another labeler, this one for VHS video cassettes. This is much simpler than audio-tape.ps. Last modified: 1991. Likewise, don't expect to ever see another update to this... | |||||||
| blacken-cmap | This is a little program that will cause all unallocated color cells to be black. Normally, X leaves whatever color was last used in the unallocated cells. This program (in conjunction with xcmap or another colormap displayer) can help when debugging color allocation problems. | |||||||
| get-pixmap |
Given the ID of an X Pixmap, this will get the bits off the server and
print out an XPM file on stdout. So if you're debugging a program, and
you can see the ID of a pixmap in the debugger, you can look at that
image by going to another shell and saying something like
| |||||||
| CID | A set of tools that I used to use back in the early nineties to have my Unix machine pop up a window with caller-ID info whenever my land line rang. This almost certainly doesn't work any more, and I'm sure it's not what you're looking for. | |||||||
| Lisp Machines | Back before the current dark ages began, I hacked on Lisp Machines. If you've still got an Explorer or Symbolics, you might find some of the stuff I wrote in the good old days useful. It's archived in the CMU AI Repository. | |||||||