Search Keys For Google Patents

The Search Keys extension for Firefox is perhaps my favorite plugin. I tweaked it so it will work with Google Patent Search as well. The only additional code needed is in the searchkeys.js file:

{
name: "Google Patents",
test: function (uri) { return uri.host.indexOf("google") != -1 && uri.path.substr(0,9) == "/patents?"; },
testLink: function (linkNode) { return (linkNode.className == "big"); }
},

I added a new minor version number and posted it here for download. Hopefully the patch will be adopted upstream.

Windows Tool of the Century

Okay, maybe “century” is overblown, but the True X-Mouse Gizmo for Windows is the best thing since sliced bread (if you use Windows):

Have you ever paid attention to striking difference in the thickness of forefingers in X11/Unix and MS Windows users, respectively? The latter have much more muscular forefingers that often suffer from chronic aches in their joints. They also much more often develop mouse arm, pain in the neck and shoulders, and other troubles known as Repetitive Stress Syndrome and associated with excessive usage of a pointing device. Why?

The Gizmo even solves the classic X copy/paste buffer problem where you want to select text to paste the contents of your copy buffer over it, only to replace your copy buffer with the newly selected text. Linux could use such a solution, as well!

Sodoku SQL Solution

In case this blog hasn’t been meeting its geekiness quota, I present the following. Ken (who deserves to be better known in the blogosphere and elsewhere) wrote a Haskell program to solve Sodoku with a single SQL query:

SELECT * FROM values AS aaaa, values AS aaab, values AS aaba, values AS aabb, values AS aabc, values AS aaca, values AS abab, values AS abba, values AS abbb, values AS abbc, values AS abcb, values AS abcc, values AS acba, values AS acbc, values AS acca, values AS accc, values AS baaa, values AS baac, values AS babb, values AS babc, values AS bacb, values AS bacc, values AS bbba, values AS bbbc, values AS bcaa, values AS bcab, values AS bcba, values AS bcbb, values AS bcca, values AS bccc, values AS caaa, values AS caac, values AS caba, values AS cabc, values AS cbaa, values AS cbab, values AS cbba, values AS cbbb, values AS cbbc, values AS cbcb, values AS ccac, values AS ccba, values AS ccbb, values AS ccbc, values AS cccb, values AS cccc WHERE aaaa.v <> 3 AND aaaa.v <> 9 AND aaaa.v <> baaa.v AND aaaa.v <> 4 AND aaaa.v <> bcaa.v AND aaaa.v <> caaa.v AND aaaa.v <> cbaa.v AND aaaa.v <> 8 AND 3 <> 9 AND 3 <> baaa.v AND 3 <> 4 AND 3 <> bcaa.v AND 3 …

(edited for brevity)

WordPress Upgrade –> 2.2

Just upgraded to WordPress 2.2. That took all of 18 seconds.

Grimmelmann on PrawfsBlawg

Not to be missed: well-known enfant terrible James Grimmelmann is guest-blogging on PrawfsBlawg. His opening commentary on the relationship between law practice and computer science:

Practicing lawyers, like practicing programmers, are professional pragmatists. Both must make their cases (and case mods) out of the materials they have available; both starve or eat steak depending on whether their creations work. The day-to-day practice of law is unlikely ever to require much high theory. We can mourn that fact because it means that they look at us with suspicion, or celebrate it because it frees us to chase Truth and Beauty—and it will remain a fact either way.

Aside from the fact that I don’t eat steak, I think this is correct.

Via a commenter on James’ entry, I learned that the 7th Circuit Court of Appeals is implementing a wiki (the entry page could surely use some more content). Surprisingly, it was not Posner but Easterbrook who spearheaded the effort. This is a very interesting development, but I expect it will be quite a while before any other circuit takes up the idea.

Finally, I have been meaning to write about this New York Times story describing Jonathan Coulton’s success as a musician breaking with the traditional distribution /promotional channels (via 43 folders, a productivity blog that is still on my “probation” list). Unfortunately, slashdot beat me to it. I first re-discovered Jonathan Coulton during his guest episode of the Show with Ze Frank. In any event, the article is well worth reading:

More than 3,000 people, on average, were visiting his site every day, and his most popular songs were being downloaded as many as 500,000 times; he was making what he described as “a reasonable middle-class living” — between $3,000 and $5,000 a month — by selling CDs and digital downloads of his work on iTunes and on his own site…

Coulton realized he could simply poll his existing online audience members, find out where they lived and stage a tactical strike on any town with more than 100 fans, the point at which he’d be likely to make $1,000 for a concert. It is a flash-mob approach to touring: he parachutes into out-of-the-way towns like Ardmore, Pa., where he recently played to a sold-out club of 140….

In total, 41 percent of Coulton’s income is from digital-music sales, three-quarters of which are sold directly off his own Web site. Another 29 percent of his income is from CD sales; 18 percent is from ticket sales for his live shows. The final 11 percent comes from T-shirts, often bought online…

Linux Installation Video

Speaking of funny embeddable videos, here’s another one that will appeal to at least some segment of my readers. I don’t know if this one has already made the rounds and I’m late for the memetrain. If so, I blame the fact that I’m getting on in years.

And here, via Tikirobot, is a not-funny video about Dasher, an amazing information-efficient typing system. Again, I suspect I’m late to the party on this one:

Proof of Spring 2007

For anyone who doubts the arrival of Spring 2007:

Flower Spring 2007

Update: all of the below was fixed by disabling Privoxy! Who would have guessed?

Meanwhile, I can’t for the life of me get the gallery2/wordpress integration plugin (wpg2) to work. I decided it was time to get organized and stop storing/uploading photos in a totally ad hoc fashion. When I try to validate the wpg2 installation, however, I get this error:

Warning: Cannot modify header information – headers already sent by (output started at /home/adam/public_html/adam.rosi-kessel.org/weblog/wp-admin/admin-header.php:16) in /home/adam/public_html/adam.rosi-kessel.org/weblog/wp-includes/functions.php on line 1221

When I then click to confirm that I want to validate, I get an empty page back.

No errors in apache logs.

This problem appears to have come up several times, and the most I can gather is the Gallery people point the finger at the Gallery Plugin people; the Gallery Plugin people point their finger at the Gallery people; and sometimes everyone points their finger at the WordPress people. E.g.

Not the best way to spend a beautiful spring day.

Adam’s Super Simple Guide to mbox->maildir conversion

There are a lot of pages out there explaining how to convert your mail from mbox to maildir. I’m going to add one more, resurrecting the “tips” section of my blog. (All the tips from my blosxom days are grouped together on one page — someday I’ll get around to breaking those up properly.)

If nothing else, I’ll never have to write these instructions in an email to someone again, instead I’ll just send them the link to this entry. I hope these steps are specific enough so anyone savvy enough to even have this problem in the first place will be able to follow them.

One thing I find consistently concerns people when converting to maildir is how to make sure no mail is lost in the transition. The steps below address that concern. It’s really not hard at all once you understand how maildir works.

First, I’m assuming you have mb2md installed and procmail support. Also, if you plan to access your mail through IMAP, your IMAP server needs to know to use ~/Maildir if ~/Mail does not exist. This is often default behavior (at least it is for Dovecot).

Finally, I assume that your inbox is in /var/mail/username, and your other mail folders are in ~/mail.

So, here goes:

  1. Edit your .procmailrc. The first two lines should read:
    MAILDIR=$HOME/Maildir
    DEFAULT=$MAILDIR/

    This will cause all new mail to be delivered (after you save your .procmailrc) to be stored in maildir format under ~/Maildir. The key for procmail to know to use the maildir format is the trailing slash in the “DEFAULT” line. Note that under the new system, your inbox and all your folders are kept in ~/Maildir, rather than having an inbox in /var/mail and your folders under your home directory. (This is nice because it makes it easier to back up all your mail together, among other things).
  2. If you have any specific procmail rules in your .procmailrc, you’ll also need to change the target folders for that. For example, if you have a spam filtering rule like this:
    :0 H
    * ^X-Spam-Level: *****
    spam
    It needs to be changed to this:

    :0 H
    * ^X-Spam-Level: *****
    .spam/

    The trailing slash, again, tells procmail to use maildir rather mbox format for delivery. The leading dot will make the folder appear properly for your IMAP client (there’s a trick I suggest below for making “dot” folders easy to access with a command line client like mutt).

    If you have mail being delivered to a nested mail folder, an additional change is needed because maildir has a flat hierarchy. So if your mail was being delivered to “misc/other/spam” the new target should be “.misc.other.spam/”.

  3. Save your .procmailrc. From this point forward, all mail will be delivered to your maildir folders. You can now import all your old mail to the new folders without concern. Since maildir stores each individual message as a separate unique file, you don’t need to worry about any overwriting issues while you are making the transition. New mail will be delivered to newly named files; old mail will be imported to other, unique, newly named files.
  4. Import your mail folders:
    mb2md -s ~/mail -R
    The -R just means to import recursively through all your folders; if your mail folder is Mail rather than mail, use that instead. No destination is needed because mb2md uses ~/Maildir by default.
  5. Import your inbox:
    mb2md -m
  6. Move your old inbox out of the way. Most people won’t actually be able to move or delete files in /var/mail (since they don’t have directory write privileges), so the easiest thing is probably to just open the inbox in your IMAP client or with mutt and save or delete all the messages.
  7. Move your old mail folder out of the way:mv ~/mail{,.bak}Once you’ve confirmed that everything is okay, you should be able to delete ~/mail.bak (or compress it and move it elsewhere.) If you saved your inbox to mail folder in step 6, that will get moved out of the way here as well.
  8. That’s it, you’re done.
  9. Okay, so you’re not quite done if you access your mail with mutt rather than an IMAP client. (You could just point your mutt at your local IMAP server, of course). I’ve found the most convenient way to access the “dot” folders with mutt is to create a parallel symlinked folder structure without the dots. Here’s a hacked-together shell script that will do that. This could obviously be rewritten to be much more elegant (probably in perl). But we all have our messy scripts, right?

    #!/bin/bash

    cd ~/Maildir

    for x in .*
    do
    y=${x##.}
    if ( echo $y | grep -q '.' )
    then
    mkdir -p ~/mymail/${y%.*}
    fi
    ln -s ~/Maildir/$x ~/mymail/`echo $y | sed "s/.///g"`
    done

    for x in *
    do
    ln -s ~/Maildir/$x ~/mymail
    done

    Then, just add these lines to your .muttrc file:
    set folder="~/mymail"
    set spoolfile="~/mymail"

Any questions?

A Comic Not Everyone Will “Get”

randomplay 0.60 released

Today I released version 0.60 of randomplay, my command-line shuffle-recall-swiss-army-knife music player. It will never make Winamp users happy, but it’s a good substitution for complex combinations of find/grep/xargs/sort that people sometimes use to pick tracks to play. If you can’t see why you’d use it, you probably don’t need it.

The latest version adds two new command-line options, —older-than and —newer-than. These can be used to limit the songs included in the shuffle on the basis of the file modification date. The syntax is fairly flexible, and resembles that used by rdiff-backup for restoration commands. For example:

Randomly play music under the ~/music directory that were added in the past week:

randomplay --newer-than 1W ~/music

Play in order music that is from before this year:

randomplay --norandom --older-than '1/1/2006'

Give a list of filenames of music that were added in the past 6 months, but haven’t been played in the last three months:

randomplay --names-only --newer-than 6M --days 3M

Play, but don’t record in the playing history, music added in the first three months of 2004:

randomplay --noremember --newer-than '1/1/2004' --older-than '4/1/2004'

Unfortunately, this new feature is pretty slow, because it stats each file individually on the initial spidering of the directories to be played. In fact, the startup is always fairly slow if you are searching a large directory hierarchy, since randomplay does not preserve any file index but checks anew on each execution. If you are searching tens of thousands of tracks over NFS (as I do), this can take a minute or so. Suggestions for improving the perfomance of the file modification time detection or of the whole startup are welcome. At some point, I will probably implement an indexing feature, but I like the simplicity of it now where it works basically like the shell find command.

Version 0.60 should show up in Debian unstable shortly.