links for 2007-​​04-​​30

links for 2007-​​04-​​29

Testing TextMate-​​generated code and styles

Like all the best geek tools, Text­Mate will gladly do any­thing you want it to do, and a lot more. One inter­est­ing prospect for the pro­grammy blog­ger is the abil­ity (in the Text­Mate bun­dle) to gen­er­ate HTML from code, and also gen­er­ate 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 obser­va­tions: The code sucks (okay, it was just the first Ruby I had on hand). The back­slashes need to be escaped for some rea­son: either MarsEdit or Word­Press? There’s still that annoy­ing ten­dency all browsers have, to let <pre> markup get too big for its bound­ing 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 god­damned mouth shut. These canes can leave a mark, you know.”

Why shouldn’t I expect you to know every­thing?” [promi­nently dis­played on my desk, and office door, in days long gone. Nobody ever under­stood that it wasn’t a rhetor­i­cal ques­tion at all. Maybe you will, if you’re pre­pared for it.…]

…[j]ust a tem­pest 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

Approx­i­mately due to Chet Hen­drick­son, heav­ily edited and some­what enhanced in tran­scrip­tion, and to date not used in an actual review of tech­ni­cal work. So it’s available!

If you want to move beyond this recent ten­dency towards intel­lec­tual mas­tur­ba­tion, you might con­sider intel­lec­tual auto­erotic asphyx­i­a­tion as an alternative.

But it could be the inter­locu­tor might take this in a neg­a­tive light. So use advisedly.