God, grant me the serenity to accept the things I cannot change, the courage to change the things I can, and the wisdom to know the difference.— Reinhold Niebuhr
Esperanto?
I don’t know why I thought this was a good idea, but I’ve started playing around with learning Esperanto. There are a surprising number of programmers that are involved in the community surrounding the language. Kind of cool
After hearing Matt Damon’s brilliant comparison of a Sarah Palin presidency to a bad Disney movie, I called up Sam and said “Let’s make a trailer for what that movie would look like.” Within hours, Dan and Amir were writing it, Ben and the CHTV crew were casting and producing it, and two weeks later, here it is.
Digg?
I’ve extended this (with limited testing) to allow for validation of a string. If you have a model that is generation templates (as I am) then getting a AC::Response is not really desirable.
REXML wrapping and rcov
I recently ran in to some problems trying to get Rcov to run on a new code base I’m working with. Admittedtly a few of the files are far longer that I’d like, but a standard xml library should deal with such things gracefully. Unfortunately, REXML will throw all sorts of nastiness on pretty.rb:131. The problem is that the wrap function: a) doesn’t handle a few corner cases when spaces show up in weird spots, and b) since its a tail-recursive function if the string is long enough the interpreter will throw a Stack-level too deep error.
Fortunately the corner cases can be dealt with and as we all know tail-recursion can be eliminated and converted to a loop quite easily. The patch looks like this (I’ll try and package it up properly at some point as a patch to core):
def wrap(string, width)
out = nil
# Recursively wrap string at width.
while true
return [out, string].compact.join("\n") if string.length <= width
place = string.rindex(' ', width) # Position in string with last ' ' before cutoff
start = 0
if place.nil? || place == 0
start = width
place = width
else
start = place + 1
end
out = [out, string[0,place]].compact.join("\n")
string = string[start..-1]
end
end
I’m getting excited about this. Finally, an opportunity for sane leadership. America, don’t disappoint me again.
