Posted by Tom Moertel
Tue, 14 Nov 2006 06:45:00 GMT
Sorry I haven’t been posting much lately. But I have a good
excuse.
This weekend I baked myself an apple pie.
I have the proof right here:

(Yeah, that’s an all-butter crust. Thank you, Sherry Yard.)
So you can see the problem. Whenever I have an amazing idea that
simply must be shared on the blog and I start typing it up, it’s
only a few minutes before I realize that instead of
typing, I could be eating pie. And then, of course, the typing stops.
Then, when I’m eating the pie, I think to myself,
Eating pie really is better than typing stuff up. No comparison,
really. I mean, none at all. So, if I’m being perfectly
honest with you, until the pie is gone the blog will suffer.
But I’m down to the final slice, so posting should resume shortly.
Thank you for your understanding.
Posted in food
Tags food, humor, life, pie, yeah_baby_its_pie
5 comments
no trackbacks

Posted by Tom Moertel
Sat, 04 Nov 2006 21:31:00 GMT
I was roaming through some old files today and stumbled upon a copy
of my first web site, called, laughably enough, “The TomZone.”
I am not kidding.
You think I’m making this stuff up? Well, feast your eyes
on this:
As if that wasn’t bad enough, I scrolled down to the footer and saw
this: “Revised: 22 Feb 1996“:
1996! That’s nuts! I’ve been bringing down the quality of the Web
for over a decade? It doesn’t seem possible. And yet it’s true:
this crap was unleashed upon unsuspecting Web “surfers”
ten years ago.
And it’s been going downhill since.
Posted in humor
Tags funny, history, im_old, scary
1 comment
no trackbacks

Posted by Tom Moertel
Sat, 04 Nov 2006 19:48:00 GMT
I’m going through some of my older posts and adding tags to them. I’m also colorizing source-code snippets when I find them. Both changes will cause articles to be updated, so if you’re subscribed to one of my feeds, you may be seeing some old content again. Sorry about that.
Posted in site news
2 comments
no trackbacks

Posted by Tom Moertel
Wed, 01 Nov 2006 22:01:00 GMT
Last night on #haskell, Don
Stewart asked if I had seen
HsColour
for rendering syntax-highlighted Haskell in HTML. He had
used it recently, he noted in passing, to add syntax highlighting to planet.haskell.org.
Now, I can’t be certain about this, but I suspect that Don’s question
was cleverly designed to instill in me a subtle case of
syntax-highlighting envy. For on my blog, Haskell code snippets
were rendered in dreadfully boring uncolored text.
But on his blog, the
snippets dance in joyous polychromatic splendor.
Thus I was compelled to add Haskell syntax-highlighting to my blog.
Adding Haskell syntax-highlighting to Typo
My blog runs on the Ruby-on-Rails-powered Typo
system, which allows for plug-in text filters. One of the included filters, in fact, is a syntax-highlighting filter for snippets of Ruby, XML, and YAML code. This filter is built upon the Ruby Syntax module, which wasn’t exactly designed for Haskell syntax analysis. So I set out to create a new plug-in filter based upon HsColour.
This task turned out to be easy. All I did was duplicate
Typo’s existing syntax-highlighting filter and swap out its filtering
code for the following:
IO.popen("HsColour -css", "r+") do |f|
pid = fork { f.write text; f.close; exit! 0 }
f.close_write
text = f.read
Process.waitpid pid
end
I also tweaked the post-processing regular expressions so that they
would whittle away the HTML filler before and after the
syntax-highlighted output of HsColour:
text.gsub!(/.*<p()re>/m, ...)
text.gsub!(/<\/pre>.*/m, ...)
A few more tweaks and I was done.
Now I can wrap my Haskell code in <typo:haskell> tags and it, too, will
dance in joyous polychromatic splendor:
constructTable tspecs = do
ecolspecs <- during "argument evaluation" $ do
toNvps . concat =<< mapM splice tspecs
let names = map fst ecolspecs
let evecs = map snd ecolspecs
vecs <- argof nm $ mapM evalVector evecs
let vlens = map vlen vecs
if length (group vlens) == 1
then return . VTable $ mkTable (zip names vecs)
else throwError $
"table columns must be non-empty vectors of equal length"
where
nm = "table(...) constructor"
splice (TCol envp) = return [envp]
splice (TSplice e) = do
val <- eval e
case val of
VTable t ->
return $ zipWith mkNVP (tcnames t) (elems (tvecs t))
VList gl ->
liftM (zipWith mkNVP (map name . elems $ glnames gl)) $
mapM asVectorNull (elems $ glvals gl)
_ -> throwError $
"can't construct table columns from (" ++
show val ++ ")"
mkNVP n vec = NVP n (mkNoPosExpr . EVal $ VVector vec)
name "" = "NA"
name n = n
If you want the filter code, here it is: haskell_controller.rb. Just drop it into components/plugins/textfilters and restart Typo. The corresponding CSS styles can be found in my user-styles.css.
Posted in haskell, ruby, typo
Tags haskell, hscolour, ruby, typo
no comments
no trackbacks
