May 27, 2008

celebrities in scala

Ola niƱos. Hope you recover from the shock of seeing a new entry on this blog. Haven't been here in a while. Looks like this is all still up and running. I'm surprised I still remember my mt password.

So why this entry ? Well, I've done another thing I haven't done in a while: I wrote yet another note in LaTeX solving some simple problem in a pompous way. I used Scala to implement the solution. Scala is coming along nicely, it feels natural to me and it has some powerful abstractions and features. There's definitely a buzz about it. A book on it is now available, the Eclipse plugin behaves well and there are open source projects that use it.

Posted by Uwe Hoffmann at 02:41 PM

October 01, 2007

hawk on lamp post

This handsome fellow landed on the lamp post next to our house and waited patiently until I got my camera.


Posted by Uwe Hoffmann at 10:24 PM

August 24, 2007

shoreline birds

I took my new camera (Nikon D40x) for a spin to shoot some bird photos at Shoreline Park in Mountain View.

Photoshoot at Shoreline, Mountain View
Posted by Uwe Hoffmann at 11:56 AM

March 25, 2007

points on a circle

Before I get completely rusty with LaTeX, here's another one in the series of absurdly trivial papers: this one derives a program that establishes if there are 4 points from a set of points on a circle that form a rectangle.

Posted by Uwe Hoffmann at 11:20 PM

March 02, 2007

bridge hands in ruby

A little while ago I started looking at Ruby and Ruby on Rails. So far I like what I see. I'm doing a little address book app to try rails and for the ruby side I'm solving pretty much random finger exercises like this one: bridge hands.
#!/usr/local/bin/ruby -w

require "enumerator"

Card = Struct.new(:suit, :face)

IS_PLAYER = /^[SWNE]$/
IS_CARDS = /^([CDSH][2-9TJQKA])+$/

PLAYERS = %w{S W N E}
SUITS = %w{C D S H}
FACES = %w{2 3 4 5 6 7 8 9 T J Q K A}

deck = nil
dealer = 0

ARGF.each_line() do |line|
  line.chomp!
  next if line.empty?
  case line
  when IS_PLAYER
    deck = Array.new
    dealer = PLAYERS.index(line)
  when IS_CARDS   
    deck.concat( 
       line.enum_for(:each_byte).enum_slice(2).map do |sf|
           Card.new(sf[0], sf[1])
       end)
    if deck.size == 52 then
      # process deck
      hands = PLAYERS.inject(Hash.new) do |map, player| 
        map[player]= Array.new
        map
      end
      deck.enum_slice(4).each do |round|
        (0...4).each do |num| 
          hands[PLAYERS[(dealer + num + 1) % 4]] << round[num]
        end  
      end 
      PLAYERS.each do |player| 
        hands[player] = hands[player].sort_by do |card|
          SUITS.index(card.suit.chr) * FACES.size + 
             FACES.index(card.face.chr)
        end  
        puts hands[player].inject(player + ":") { |string, card|
           string + " " + card.suit.chr + card.face.chr
        }    
      end          
    end
  when "\#"
    Kernel.exit(0)
  else
    Kernel.exit(1)
  end    
end  


I'm still new in this ruby world so if you see some ruby idiom I'm missing or some awkward antipattern that I use feel free to correct me in comments.
Posted by Uwe Hoffmann at 05:05 PM

December 25, 2006

visiting sf for xmas

My wife's nephew, Guo Ao Sky, is staying with us for his winter break, so we thought to show him San Francisco. We did the usual touristy stops but this time we wanted to do them with a twist. I wanted to visit every location from the wwdc 06 conference ad campaign, where they show famous mac developers at famous SF locations. Instead of holding a mac I wanted to hold Nadia at each location.

Of course we got lazy, got out of bed too late, only had half a day in SF, had Nadia to take care of, so we didn't succeed to get to all locations. We started with the "Painted Ladies" in Alamo Square. Nadia was still taking a nap in the car there so no Nadia at the first location.

sf xmas
Posted by Uwe Hoffmann at 02:00 PM | Comments (1)

December 03, 2006

catching up

Let's see:

We went to Europe in October for three weeks. We let my parents enjoy Nadia, while we first went to my x number of years (where x is the smallest abundant number that is not a multiple of 3) high school reunion. Was kind of weird to see vaguely familiar faces. Made me feel like an amnesia patient slowly regaining his memory. We then drove around Germany and Switzerland (some pictures of Zuerich here). We were supposed to go to Italy too but I was too lazy driving so we stayed at my parents place in Karlsruhe most of the time, swimming and doing bicycle tours.

I have to mention one little anecdote here from our trip (my wife insists): we went to the movies one night in Karlsruhe. We picked a newish movie theater in a fancy modern building that hosts the center for arts too. The movies were mostly mainstream american and at that time of night the selection wasn't that great. So we chose The Guardian. First surprise: tickets had seat assignments. We go to our seats and it's fancy, comfortable love chairs. They serve beer. Cool. Then the commercials start. It goes for a while. Pretty blend commercials that you see on TV too. Interesting they have cigarette commercials too. Didn't think I would see the Marlboro man again. So commercials still playing. We're hitting 30 min since we sat down. We both show signs of impatience. Then finally movie starts. First scene: a man and a woman have an argument in the kitchen. He insults her verbally and she hits him over the head with a frying pan. Hm. The Guardian ? Well, turns out we're in the wrong movie. The guy at the register misunderstood me. We had to walk out because both of us cannot stomach horror movies. So our night out in Karlsruhe was 45 min of commercials followed by a guy smacked by his wife with a frying pan.

What else ?

For some reason I haven't mentioned my 5 min of geek fame yet. I was the original author of a tool that became open source a while back. Cool stuff. I probably peaked back then. These days I do little puzzle snacks.

Oh, and one more thing: sometimes babies have it hard too .

Posted by Uwe Hoffmann at 10:13 PM | Comments (4)

October 15, 2006

one year

one.jpg one.jpg one.jpg one.jpg one.jpg

one.jpg one.jpg one.jpg one.jpg

one.jpg one.jpg one.jpg

Posted by Uwe Hoffmann at 02:16 PM

October 04, 2006

links, links, links

Cool free math books:

Fascinating New Yorker article about the people involved in the solution to the Poincare conjecture. And in case you want to know more about the Poincare conjecture, you can follow James Tauber on his Poincare Project.

A coworker gave me this link to Eliezer S. Yudkowsky's home page with some great pieces to read. My favorite is his Intuitive Explanation of Bayesian Reasoning.

Posted by Uwe Hoffmann at 10:24 AM

September 26, 2006

icu regex in cocoa

I do java server code for a living. It's my bread and butter. At home when I do my silly little math notes I play with haskell. That's my chocolate dessert. But sometimes I get a craving for something completely different. So in the last couple of weeks I've been hacking a cocoa app: my spicy Thai dish. I don't do it often but it's very tasty when I try it.

I needed a regex lib in this little cocoa app. There are regex packages available for cocoa (see CocoaDev). It seems though that Apple is using icu internally (you can guess that from the Predicates Programming Guide for example). I wanted to use that too. libicucore.dylib is on the system, compiled and ready to use. Unfortunately Apple doesn't provide the headers because the icu API is not final yet and Apple understandably doesn't want to commit to it yet.

So I downloaded the icu package that Apple uses and wrote my own obj-c wrappers for now until Apple officially exposes theirs. You can get the wrappers and a small how-to readme file from here. Use at your own risk.

Posted by Uwe Hoffmann at 02:05 PM