Jay McGavren's Journal

2007-03-19

Shameless e-mail copy-paste!

> We’ve been encommunicado for a while, so just wanted to let > everyone know we’re doing well… > > Jeremy is growing at an amazing (alarming?) rate, > approaching 9 pounds now. The difference from the delivery > pictures is noticeable. (I’ll get new ones posted soon.) > He’s been pulling himself up on his arms to look around > since almost day one, something he’s not supposed to be > able to do for a couple months. (Still kinda wobbly, > though.) > > Sleep is still a rare commodity at the house, with Diana > losing the most thanks to feedings. She’s been a real > trooper, though, and of course I try to pitch in with the > bottle when I’m not at work. Every now and then the baby > will sleep 4 or 5 hours at a stretch, which is a welcome > respite. Mom and Dad have each made trips here, and both > have been huge helps, as has Judy. > > Anyway, that’s us. How are all of you? News from the > outside world would be nice, as we don’t get to see it that > often these days. :)

Read more...
2007-03-16

Ruby yield is cool.

Before:

	#Find playlist by name and add to list.
	if config.has_key?('playlist')
		config['playlist'].each do |name|
			playlists.push(interface.LibrarySource.Playlists.ItemByName(name))
		end
	end
	#Create playlist and add to list.  [Note the near-identical code.]
	if config.has_key?('create-playlist')
		config['create-playlist'].each do |name|
			playlists.push(interface.CreatePlaylist(name))
		end
	end
	#...etc.

After:

	#Invoke a block with each of the values for the given option in the given configuration.
	def with_option_values (key, config)
		if config.has_key?(key)
			config[key].each do |value|
				yield value
			end
		end
	end
	#Find playlist by name and add to list.
	with_option_values('playlist', config) do |name|
		playlists.push(interface.LibrarySource.Playlists.ItemByName(name))
	end
	#Create playlist and add to list.
	with_option_values('create-playlist', config) do |name|
		playlists.push(interface.CreatePlaylist(name))
	end

…Two completely different operations, but with yield and blocks, I’m able to remove the boilerplate around them. Multiply that across a dozen similar sections of code, and you start to see real readability improvements.

Read more...
2007-03-16

Gee, thanks for the info.

1) Failure: test_delete_playlists(TestItch) [src/test/ruby/test_itch.rb:128]: <false> is not true.

Read more...
2007-03-09

Wow. My inbox at work is actually empty. Considering I’m a David Allen acolyte, this should be an everyday occurrence, but it hasn’t been for months.

It really is a relief, though. Maybe this will motivate me to do the same at home.

Read more...
2007-03-09

Got the XBox 360… Not only have I not purchased any games on an actual disc yet, I don’t really care. Everything I’m playing has been downloaded to the hard drive (some actually purchased, some just demos).

I’m actually annoyed at the prospect of having to go pop a disc in once we buy something bigger. Downloads are definitely the future.

Read more...