07.18.06
Liff for your lives!
Another entry brought to you by the LGFT (Little Gems For TextMate) project. This is to spice up your email signatures, or perhaps blog posts, by definitions from The Meaning Of Liff. If you don’t know what that is, go and find out.
Anyway, back to our main feature, suppose you have already gone to the above address and gotten hold of the aforementioned list of words, and you have formated it so that entries appear like this:
*BRECON (n. anatomical trem)*
That part of the toenail which is designed to snag on nylon sheets.
*SCRAPTOFT (n.)*
The absurd flap of hair a vain and balding man grows long above one ear
to comb it to the other ear.
I.e. there the title line has stars marking it, and each definition is separated from the next by at least one empty line. Then the following little script will bring up a random definition from the file:
#!/usr/bin/env ruby File.open(”/Users/haris/Documents/TMoL.txt”) {|f| @data = f.read } list = @data.scan(/*[^]+*\n(?:.|\n)?\n\n/) print list[rand(list.length)].gsub(”*”,”")
I am afraid those backslashes in the regular expression won’t make it, so to clarify all asterisks except the one before the question mark has a backslash in front of them, as do all the n’s.
Simple and effective, and so easy to use. I gave it a tab trigger of liff. To get the output to align properly if you have indent, set its output to “Insert as Snippet”.
Now I just need to figure out how to tell Mail.app to add these things always, or at least easily, as part of the signature. And here is a bit more spicing up of this post:
PITSLIGO (n.) Part of traditional mating rite. During the first hot day of spring, all the men in the tube start giving up their seats to ladies and straphanging. The purpose of pitsligo is for them to demonstrate their manhood by displaying the wet patches under their arms.
Later