The Code Kitchen

Is your local hardware store owner on the no-fly list?

 In the process of remodeling our basement, we found part a March 1959 issue of the Deseret News and Telegraph stuffed up in the ceiling. I could go on and on about some of the fascinating parallels with content you'd find in any major newspaper of 2008 -- some things really never change. But this hilarious post-McCarthy-era comic took the cake for me:

Nancy comic from March 1959

The late '50s also appears to be one of those periods when everybody wanted good mileage from their vehicles -- most every car ad prominently displayed a MPG rating. Did you know that the 1958 Renault 4-door sedan got 40 MPG?

delicate arch in arches national park, utah

Delicate Arch (aka "the schoolmarm's bloomers")

#

wildflower in foreground, mountains and clouds in background

 On Desolation Trail, near Salt Lake City. We saw the biggest rattlesnake I've ever seen, I'm kicking myself for not getting a photo before it got out of view.

#

#

#

le chef

Greek Iced Coffee (Frappe)

prep time: 2 minutes
 
 
yummm
ingredients:
2 tsp Nescafé instant coffee granules
1 tsp sugar
1/2 cup milk

directions:

Put some ice cubes in a glass and pour in the milk, you can use more or less milk and mix with cold water to taste.
 
Mix the instant coffee, sugar, and 1/4 cup water in a drink shaker or cup. Cover and shake like crazy, the more you shake the foamier it'll get. Pour the coffee mixture over the ice, stir with a straw or chopstick, and enjoy.

comments:

Apparently this has become something of a national drink in Greece over the last 50 years. I was skeptical about using instant coffee, but it works really well in this recipe. You wouldn't get the same kind of foam on top with normal coffee grounds. It's a great summer alternative to iced latte if you don't have an espresso machine. My next experiment will be to pick up some irish creme or vanilla flavoring and try adding that.

cool shyguy wall decoration

Each of those pixels is a 2-inch square of heavy paper, cut out by hand. We apparently have way too much free time.

#

Cool looking spider sitting on our backyard hose

Colleen took this awesome picture in our back yard.

#

In The Beginning There Was: Pong

Requires Mac OS X 10.5 (Leopard) and Apple Safari. Yeah.

Download Source

Hard-coding the velocities and limiting the animation rate to 30 frames per second has not worked all that well (not surprising, locking the logic rate to the rendering frame rate is always asking for trouble). You can see how the speed of the ball and paddles isn't consistent. So fixed rate logic is out. Delta-based animation is in for the next project.

Kenta Cho's Mu-cade for OS X

An awesome snake-like shooter, now for Mac OS X 10.4.

Mu-cade for OS X.

The Physics Centipede Invasion.
Smashup waggly shmup, 'Mu-cade'.

(download)

patch file if anybody wants to build it themselves.

Update: I tried the game on a PowerPC Mac, and while it loads and runs just fine, it's not playable. There's probably some endian issues in the game's internal data structures. If I get some time I'll look into it, but for now this release is Intel-only. :'(

Mozy Deathmatch II

Further #to_proc Abuse

Everybody loves to abuse #to_proc. The Symbol#to_proc extension has even been baked in to Ruby 1.9.

Why not continue the duck typing abuse? Let's build a cheap ActiveRecord knock-off for Enumerable:

my_peeps.find_all(&{:last_name => "Palmer"})  appointments.find_all(&{:description => /billable/i, :time => (start_time..end_time)})  my_socks.any?(&{:status => 'washed'}) 

The implementation is simple.

class Hash; def to_proc   proc { |obj| self.inject(true) { |m,(k,v)| m && v === obj.send(k) } } end; end 

Of course, I wouldn't try to argue that it's as useful as Symbol#to_proc. Fun to play with, though. I'm using it in a RubyOSA script that I'm building for Colleen. For completeness, this version performs a little better if the hash has many terms and a lot of records will be filtered out:

class Hash; def to_proc     proc { |obj| self.inject(nil) { |_,(k,v)| v === obj.send(k) || (break false) } } end; end 

Comments? Feedback? Drop me a line.

The Code Kitchen is a software consulting business run by me, Brian Palmer. But this site is really about whatever catches my interest.

Questions or Feedback? Email Brian.

Macadamia Cookies

cookiesLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

go to recipe