Wednesday, December 12, 2007

Word of the Year: 2008

As every geek should know by now, the Merriam-Webster 2007 Word of the Year (hereafter known in geek-lingo as WotY) is w00t. Now, I'm a huge fan of the WotY - truthiness by far my favorite. But apparently the wordanistas are a little behind the times. I suggested the 2008 WotY should be "jiggy", since it's ever newer than their decade-plus word of choice - but I find my next idea even more apropos. I now announce the 2008 Word of the Year in dedication to the folks at Merriam-Webster: n00b.

Monday, December 10, 2007

Code Te Ching - Verse 41

When a great man hears of the Code
    He understands its true depth.
When an average man hears of the Code
    He confuses its finger for the moon.
When a fool hears of the Code
    He laughs at its stupidity.
Without the laughter, Code would not be what it is.

The efficient code seems complex.
The simple code looks fast.

This is how it has been.

But what is beyond simple or efficient?
What is more and less than what it seems?
What is beyond math and beyond the mind?

Here is where the great men dwell.

Monday, December 3, 2007

Cheap Tricks XIV - Dates are Ranges

Apparently, Date objects are valid Range elements in Ruby. I love this, because I am often given a start and end date, and must iterate through the list. To iterate through every day of the previous week is trivial:
start_date = Date.today - 6
end_date = Date.today

(start_date..end_date).each do |date|
puts date
end

# Outputs:
# 2007-11-27
# 2007-11-28
# ...
# 2007-12-03
Of course, this can be a one-liner, too
(Date.today-6..Date.today).each{|date| puts date}
That's what I call keeping it simple. Can you imagine something similar in Java? I can, and it gives me nightmares:
import org.apache.commons.lang.time.DateUtils;
import java.util.*;
...
for(Date date : DateUtils.iterator(new Date(), DateUtils.RANGE_WEEK_RELATIVE)) {
System.out.println(date);
}
Blech. And that's me being nice - showing Java at it's best.