Steve Jobs says Apple would love DRM-free music
Wow. Steve Jobs has posted an open letter on Apple's website essentially calling for the big four music companies to abolish their restriction that music sold through iTunes be done with DRM. This combined with hints from Bill Gates that he'd love to see DRM dropped as well, may actually move the discussion to the right players - the music companies themselves. (After all, not only have they pushed for DRM, they actually blackmailed Microsoft into giving them money for every Zune sold!)
It's nice to see the big technology companies are starting to push for the right thing - even if it is because the hassle of keeping up the DRM and recent court battles have pushed them into this position.
RDT gets Refactoring support
Well the cat is out of the bag: Mirko Stocker and his cohorts have committed their refactoring support to RDT's Subversion repository.
This means we'll be able to roll out 0.9.0 with this support. Right now we're working to get it integrated into the build process, so that it will begin showing up in our new builds. I'm pretty excited myself, because I've had little chance to try out their work.
This refactoring support joins other recent work in RDT which allows us to do some occurence marking of variables, code completion and other exciting features (thanks Jason!). There's certainly a long way yet to go to get the tools polished - for instance we still have a hard time doing code completion (or much else) on a file which is being edited while the syntax is temporarily incorrect (the JRuby parser is great, but not so forgiving) - but we're constantly marching forward.
Look for 0.9.0 to come out sometime this month (we're aiming for the 15th)!
Rosie our cleaner
So, I was lucky enough to get a Roomba Discovery for Christmas from my parents. My wife and I both love her and we've decided she'd be named Rosie.
My father also grabbed a strange TV remote alarm, which is supposed to learn your remote's infrared signals for turning the TV on and off and then send that signal when the alarm goes off (thereby waking you up by turning your TV on). It also should be able to learn the Roomba power/clean command.
But it won't.
Or at least it says it's got it by flashing it's little red lights, and when the alarm goes off those wonderful little lights go off again - but no movement from Rosie. I can't get it to actually learn the TV remote control either, so I guess it's no fault of Rosie.
So, dear lazyweb, are there any other cheap solutions for setting Rosie up on a timed schedule to clean my house while I'm away? Or do I have to buy some accessories from iRobot (which will be more expensive)?
Patterns in Ruby: Decorator revisited
A while back I wrote an article describing some possible ways to implement a
Decorator pattern in Ruby.
I've stumbled across several mentions of
yet another idiom used so often in the Rails codebase that they've extracted
it into the latest ActiveSupport. That idiom is
alias_method_chain,
and it's a good example of a decorator implementation.
This idiom is a codified example of using the alias approach I briefly mentioned in the earlier article. In that article we aliased the original implementation with anew name, and set up a new implementation of our method (often delegating to the original) with the original's name. A quick example makes this clear:
class Window
def draw
# do some drawing here...
end
# some code...
# creates a 'copy' of draw method, but gives it
# the name/selector 'original_draw'
alias :original_draw :draw
def draw
draw_vertical_scrollbar
original_draw
end
endalias_method_chain
In Rails 1.2 (ActiveSupport specifically), the Rails core team found many instances of this pattern
and codified a new method on the class Module, alias_method_chain. This class-level method encapsulates this
pattern of wrapping existing methods with additional behavior.
Here's a specific example, showing how they would wrap rendering with layouts:
alias_method :render_with_no_layout, :render
alias_method :render, :render_with_a_layoutIn this small code snippet, they are creating a small chain of methods to wrap the existing render behavior.
Now calls to render will be routed to render_with_a_layout and then on to the original render implementation
(which is now aliased to render_with_no_layout). So they coded up alias_method_chain which simply does
the wrapping for them (using naming conventions):
class Module
# Encapsulates the common pattern of:
#
# alias_method :foo_without_feature, :foo
# alias_method :foo, :foo_with_feature
#
# With this, you simply do:
#
# alias_method_chain :foo, :feature
#
# And both aliases are set up for you.
def alias_method_chain(target, feature)
alias_method "#{target}_without_#{feature}", target
alias_method target, "#{target}_with_#{feature}"
end
endPlease note that if they were to replace their existing two calls to alias_method above, they would need to tweak the naming a little
(the methods would become render_without_layout and render_with_layout as opposed to
render_with_no_layout and render_with_a_layout respectively).