Wednesday, February 14, 2007

Valentine's Day Treats


I found the bag of treats on my doorknob when I got back today. I don't know who it's from.

Sunday, February 11, 2007

Getting Nickel and Dimed - Literally


After eating Pho on the Ave at a place that only accepts cash with my friend Kevin, I find out that he is a bit short on cash. The total comes to $11.24 so I ask Kevin if he has a quarter on him. Unfortunately he doesn't, so I hand the cashier 12 dollars. What I get back is a handful of nickels and dimes. Thinking that it must be some kind of mistake, I ask for three quarters. The cashier informs me that they're out of quarters.

Next time I eat there, I'm paying with nickels and dimes.

Wednesday, February 7, 2007

Hot Showers

About a week ago, something changed in my dorm: the water in the our showers got dramatically hotter. Before the change I would turn the shower knob all the way in the hot direction, only to be disappointed by mildly warm water. Not even a constant stream of mildly warm water - no, this unpredictable stream of water would fluctuate in temperature from from an uncomfortable mildly warm to an unbearable icy cold.

All that has changed though. I now only have to turn the knob 1/4 of the way, and I have steaming hot water. In fact, if I turn it any further, it becomes uncomfortably hot. The length of my showers has increased from 2 minutes to 15 minutes. I no longer wait until the wee hours of the morning to take showers in an attempt to maximize the availability of hot water. In fact I've started taking two showers a day now, one in the morning and one at night.

I find hot showers to be very useful. Whenever I'm having trouble thinking about an algorithm or whenever I'm getting bored with coding, I can take a nice hot shower, and I'll be relaxed and refreshed. I also get many great ideas while taking a hot shower. It's really helped my productivity.

Monday, February 5, 2007

Analyzing Polyhedral Scenes


I recently read about a neat algorithm for determining the geometry of polyhedral scenes (an assembly of solids each of which is bounded by plane faces) in The New Turing Omnibus. The algorithm assumes that lines can only meet in a few ways, and each meeting has only a few possible labelings for the component lines. The algorithm starts by labeling the lines for one meeting and tries to make consistent labelings for its neighbors and so on. Usually, the algorithm will end up with one consistent labeling for the whole scene, with maybe a few ambiguities.

If the description is confusing, don't worry, I hope to make something soon that will make it all clear.

Sunday, February 4, 2007

Bawls Mints


Eat them for their tangy tongue-tingling flavor and not for their caffeine content. Since at 5mg a mint, eating the whole tin (75 pieces) would only be the caffeine equivalent of consuming a Starbucks Grande Coffee.

Saturday, February 3, 2007

Regular Expressions in Java

One of the cool things about Perl, Ruby, and other scripting langauges is how easy it is to do some very complicated things. For example, Ruby has the =~ operator, which lets you easily match a string against a regular expression. It returns the position that the match starts or nil if there is no match.

"sector 19" =~ /\d/    # Returns 7

Another cool thing you can do in Ruby is String.scan - this iterates though a string, matching against a regular expression and returns an array with all the matches.

# Returns all the <item> tags
text.scan(/<item>.*?</item>/)

If you know the right Java APIs though, these operations are almost as easy. The following Java code does the same thing as the above Ruby code:

ArrayList<String> tagList = new ArrayList<String>();
Matcher matcher =
Pattern.compile("<item>.*?</item>").matcher(text);
while(matcher.find()) {
String match = feedString.substring(matcher.start(),
matcher.end());
tagList.add(match);
}

A Matcher object is returned by Pattern.matcher - it basically remembers a string, a regular expression to match against, and the last matched position. Matcher.find returns true if there's another match. Matcher.start, and Matcher.end returns the start and end indexes of the previous match.

I'll admit that the code is a bit longer than the Ruby version, but it's still quite easy.

Friday, February 2, 2007

10 Days to Do 2 Projects

I have two major group projects, both due in ten days.

One project is to complete the backend for Infomush, a totally awesome way to get news. My team has access to a large cluster of machines, which will be useful given the massive amounts of data that we will be processing.

The other project is to create an interactive prototype for Don't Forget, a system for reminding people of forgotten items. Although my team has been working on designing the system for the last few months, we haven't been asked to write any code for it. Now, we have ten days to take all our design prototypes and turn them into something more functional.