links for 2007-04-29

Testing TextMate-generated code and styles

Like all the best geek tools, TextMate will gladly do anything you want it to do, and a lot more. One interesting prospect for the programmy blogger is the ability (in the TextMate bundle) to generate HTML from code, and also generate a stylesheet from the theme you’re using. Let’s see how that works:

#!/usr/bin/env ruby

myPoem = ENV['TM_SELECTED_TEXT']

newPoem = "<div class=\\"poem\\">\\n<div class=\\"stanza\\">\\n"
betweenStanzas = "</div>\\n\\n<div class=\\"stanza\\">\\n"
myPoem.each do |line|
  if line =~ /(^ +)\\S/
    indent = $1.length
    if [2,4,6,8,10,12,14].include?(indent)
      classing = "<p class=\"i#{indent.to_s}\\">"
    else
      classing = "<p class=\\"FIXME\\">"
    end
    newPoem += line.chomp.sub(/^ +/,classing) + "</p>\\n"
  elsif line =~ /^( *)$/
    newPoem += betweenStanzas
  else
    newPoem += "<p>" + line.chomp + "</p>n"
  end
end
newPoem += "</div>\\n</div>"

print newPoem

It does go, but some observations: The code sucks (okay, it was just the first Ruby I had on hand). The backslashes need to be escaped for some reason: either MarsEdit or WordPress? There’s still that annoying tendency all browsers have, to let <pre> markup get too big for its bounding box.

Sayings for almost every day

“When life gives you lemons, make sidecars.”

“In the land of the blind, the one-eyed man should keep his goddamned mouth shut. These canes can leave a mark, you know.”

“Why shouldn’t I expect you to know everything?” [prominently displayed on my desk, and office door, in days long gone. Nobody ever understood that it wasn't a rhetorical question at all. Maybe you will, if you're prepared for it....]

“…[j]ust a tempest in a molehill.”

Those are mine, at least those of which I have been reminded on this sunny April day. You have others?

Potentially useful for manuscript reviews

Approximately due to Chet Hendrickson, heavily edited and somewhat enhanced in transcription, and to date not used in an actual review of technical work. So it’s available!

If you want to move beyond this recent tendency towards intellectual masturbation, you might consider intellectual autoerotic asphyxiation as an alternative.

But it could be the interlocutor might take this in a negative light. So use advisedly.