Archives for June 2008

So long svn

For the last several weeks Alan and I have been working on using git-svn. This is a hack that allows a developer to maintain a Git repository that commits back to an upstream Subversion repository. This gave us the most of the nifty benefits of Git without replumbing both our repository and deployment processes.

But like all hacks there are downsides. git-svn is clever but, for example, last night I had a nasty merge following by Segmentation fault and Bus error messages as git-svn dcommit was doing its work (they turned out to be problems in libsvn related to it's DAV support). That I was able to recover and continue is a testament to Git's robustness but it was just a reminder that what we were doing was basically evil.

So last night I took EY up on their very generous offer to all customers of a free Github account and following Simplistic Complexities guide migrated our Subversion repository, all 1000+ commits of it, over to Github.

I'm now sharpening up my Git knowledge by reading Scott Chacon's peecode book on Git internals, Travis Swicegood's pragprog Git beta-book, and anything else I can lay my hands on.

My outline strategy is to have a single repository with us pushing & pulling from it, rather than forking. And to have origin/staging and origin/production for deployment to respective EY environments.

My thinking behind having two branches is that it allows for a cleaner separation of what's on staging and what's on production with a specific action required to change production. It also promotes cherry-picking of changes deployed to staging (e.g. hot-fixes) without pulling across a bunch of other stuff that might be less well tested.

I'm not sure though, still feeling my way. Any advice on best practice would be welcomed.

30/06/2008 10:54 by Matt Mower | Permalink | comments:

Jump into Kiva

As I've mentioned before I have been loaning to small businesses via Kiva for a couple of years now. A few days ago I made my 17th loan which was to a group of women in Uganda trying to raise $1,825.

The way Kiva works they expire any loan that doesn't reach it's target inside 30 days (refunding the credit to the Kiva lenders). There are 5 more days in which lenders can pledge the last $300 of their loan.

If you've ever wanted to try Kiva out now might be a good opportunity. I loaned them $25, maybe you'll give it a try too.

BTW: My record is:

17 loans, 6 repaid, 2 refunded, 7 repaying, 2 raising funds

You can see more info at my lender page

28/06/2008 12:23 by Matt Mower | Permalink | comments:
More about:

Hard going

I've spent about an hour this evening looking at the Apple developer documentation trying to figure out how to play music. By that I mean how to play musical notes through the (presumed) software synthesizer. I did this quite easily a few years ago with JavaSound but I'm not making much headway here. Even by Apple standards the documentation is terse and opaque.

Just to clarify that last statement I don't mean to suggest that Apple docs are especially bad but they're often little more than a thin wrapper around method and argument names, there is often little in the way of context or example usage. Unless you more or less know what you're doing it's often tough to figure it out from the Apple docs.

In this case I guess I want to use Core Midi with a software instrument. Maybe. Apparently I should have a (or maybe several) sound bank in /Library/Audio/Sounds/Banks/ but my cupboard is bare.

Nevertheless Apple supplies one example that appears to be headed in the right direction: PlaySoftMIDI. Bizarrely in these days of Cocoa marching foreward this is a C++ program and.. Carbon? I dunno. It's definitely not friendly Objective-C and Cocoa.

Also my heart did not sing as I read the opening comments:

// This is a simple test case of making an simple graph with a DLSSynth, Limiter and Ouput unit
// we're going to use a graph because its easier for it to just handle the setup and connections, etc...

You what now?

If anyone knows of any good Cocoa based examples of using CoreAudio or CoreMidi to generate music (i.e. playing notes, not playing MP3 files) I'd be very interested.

26/06/2008 23:17 by Matt Mower | Permalink | comments:

Only murder: so that's okay then

I was reading a piece about some stupid law-suit over whether GTA SA had some sex scenes in it and these comments popped out at me:

"I'm aware that there is killing in the game," Ms. Stanhouse said in the deposition. "I wasn't aware of the stealing."


"Well, I think he does have games with violence," Ms. Stanhouse said, adding that she would "possibly" buy such a game - though not one that contained sex scenes like those in San Andreas.

So it's okay for her kid to murder virtual-people but not to steal from or have sex with them?

Poor kid.

25/06/2008 11:06 by Matt Mower | Permalink | comments:
More about:

That just about sums them up

Don't ask me how but I ended up, through a long chain of associations, watching Steve Balmers wonderfully predictive reaction to the iphone:

In it he scoffs at the iPhone then starts talking about Windows Mobile and the Motorola Q-phone and says:

"You can get err a Motorola Q phone now for 99 dollars. It's a very capable machine. It'll do music. It'll do internet. It'll do email. It'll do instant messaging. So I kind of look at that and I say 'Well. I like our strategy. I like it a lot.'"

Those words "capable", "machine", "it'll do" strike a note of entrenched mediocrity to me. Compare that to the excited and playful way Steve Jobs talks about Apple products and their design. I can't ever imagine teh Steve saying "Good enough."

It's not hard to understand why I love Apple and feel only bleuch when I think of Microsoft.

24/06/2008 23:12 by Matt Mower | Permalink | comments:

Why I won't be using FF3 for Mac

Google Mail - Compose Mail -
Uploaded with plasq's Skitch!
23/06/2008 18:57 by Matt Mower | Permalink | comments:
More about:

On Ruby Metaprogramming

I have just finished the 5th and (presently) last installment of Dave Thomas series of screencasts on The Ruby Object Model and Metaprogramming.

Here is my capsule summary:

If you write even moderately complicated Ruby programs and you are not Josh Susser or Ryan Davis then you should rush out and buy these videos.

I consider myself a reasonably seasoned Ruby programmer who has done some metaprogramming before and yet I found much to like about each episode where it either taught me something new or refined my understanding of the underlying principles.

Each video is well presented, well paced, about 30 minutes long, has no fluff and Dave's speaking voice is clear and easy to listen to. For $5 a pop I definitely consider these a worthwhile investment.

I'm looking forward to a continuation of the series.

22/06/2008 13:29 by Matt Mower | Permalink | comments:

Our society is doomed

I think, as a measure of the advancement of society, we could look at the perceived requirement for (and tolerance of) coercion:

As Harry Binswanger says so memorably, the symbol of political power is the gun. The symbol of economic power is the dollar.

The only power a business has to induce customers to give it money is the value of its products. If a business started to produce an inferior product, it would eventually lose its customers. By contrast, the only power that the government has to offer is a threat: "We'll dictate what businessmen can and cannot do - and businessmen better toe the line or we'll throw them in jail."

Blurring the distinction between the dollar and the gun is a favourite ploy of statists, who use this equivocation to justify the curbing of economic freedom through the extension of political controls. "There is no difference between being dictated to by a politician and by a businessman," fudges the statist, "so what harm is done by giving more to the politician and less to the businessman?" Answer - immeasurable.

I came across that quote while looking for this quote from Ayn Rand:

"When the productive have to ask permission from the unproductive in order to produce," said author Ayn Rand, "then you may know that your society is doomed."

The problem with economic power is not markets but unfair markets. Where can we look for reasons why our markets are so unfair? Well political power (for example the grant of monopolies either legally or illegally) seems a pretty fair bet.

All this supports what I have come to believe: the future is not star trek.

22/06/2008 11:09 by Matt Mower | Permalink | comments:

Why software patents shouldn't be allowed... #110

This kind of ass-hattery is a good start:


[0007]The present invention provides a system and method for dynamically generating a privacy summary. In a method according to one embodiment of the invention, a profile for a user is generated. One or more privacy setting selections are received from the user associated with the profile. The profile associated with the user is updated to incorporate the one or more privacy setting selections. A privacy summary is then generated for the profile based on the one or more privacy setting selections.

Yes that is an actual quote from United States Patent Application 20080046976 where Mark Zuckerberg claims a patent on a database-backed form containing privacy settings.

He must be so proud.

I'm off to patent my cat.

21/06/2008 00:18 by Matt Mower | Permalink | comments:
More about:


My delicious tags as a word cloud courtesy of Wordle:

Wordle - Create
Uploaded with plasq's Skitch!

with thanks to Scott for the find.

20/06/2008 10:32 by Matt Mower | Permalink | comments:

Zeppelin dreams

One of my dreams, should I ever make it to fabulously wealthy, is to start a Zeppelin company. Who cares about making a profit... I just want to glide majestically into New York aboard a huge airship.

19/06/2008 17:36 by Matt Mower | Permalink | comments:
More about:

Ruby Functor

Dan Yoder has been messing with something that looks very interesting indeed::

fib = do
  given( 0 ) { 0 }
  given( 1 ) { 1 }
  given( lambda { |n| n > 1 } ) { |n| n - 1 ) + n - 2 ) }

I'm not clear just how close to a pattern matching style Functor's given gets us but guarded evaluation with lambda's is a pretty neat trick. Here it is used in Dan's framework Waves:

class View
  include Functor::Method
  def initialize( response ) ; @response = response ; end
  functor( :render, String ) { |s| @response.write(s) }
  functor( :render, Proc ) { |p| render( ) }
  functor( :render, Object ) { |k| render( k.to_s ) }
  functor( :render, Object, Hash ) { |k,h| @response.headers.merge!( h ); render(k) }

# these two lines do more or less the same thing ...
view.render( "hello" )
View.functors[:render].apply( view, "hello" )

# The big difference is that the render method will actually call super for
# you if nothing matches, just in     case render is also implemented in
# base class. If no match is found (either in the derived or base class) an
# ArgumentError will be raised. So you wouldn’t normally want use the second technique.

We've overloaded the render method to handle various different types of objects. They've all been implemented recursively, with the terminal condition being a simple string input. We've even added an optional hash to write the headers. We could easily extend this approach to handle status codes (overloading on Exception for example) or any number of other variations.

Very neat.

18/06/2008 08:54 by Matt Mower | Permalink | comments:

Not my thing

Just deleted my twitter account.

I only ever used it sporadically and, although I subscribed to a few people, I never found myself gravitating towards reading it.

Twitter just isn't my cup of tea.

15/06/2008 13:41 by Matt Mower | Permalink | comments:
More about:

Why vote a ticket?

I was thinking. In America today you have presidential candidates who take along with them a vice-president. It's interesting to me that you can't vote for the vice-president separately to the president.

In the Roman republic when there was a vote for the two consuls for the year the vote was a popular vote. There wasn't a vote for "senior" and "junior" consul. However the consul who topped the poll was the senior and had greater powers. It seems to me that there is something to like about this system.

For example if you have a popular candidate with some weakness (perceived or actual) you could imagine a complementary candidate receiving enough of the poll to take the second chair. It could also serve to break down the party barriers since it wouldn't mean an insistence on both President and Vice-President being from the same party.

Such a system would require some re-working of the current system of government but that, it seems to me, might be no bad thing. You don't have to look at the current US executive too hard to think change could be positive.

I wonder how and why America ended up with the present system.

14/06/2008 14:28 by Matt Mower | Permalink | comments:
More about:

War has not changed

To keep some part of my brain free of the issues of ruby, rails, prototype, jquery, and all that jazz I am reading Pompey the Great by John Leach pub 1978 (although the sources are 2000 years older).

Ever since I first saw I Claudius) about which I have written before I've been fascinated by the history of the Roman republic.

It's not the easiest book to follow because there are so many names and because the author assumes a more detailed understanding of the workings of the politics of the republic than I presently possess. Nevertheless it's fascinating to read Pompey's rise. I'm at the point where Julius Caesar is beginning to be referenced as one of Pompey's supporters.

But to this point the book has largely been a history of Pompey's, and Rome's, military campaigns. And this is what has struck me:

The consul Lucius Licinius Lucullus had been fighting for 8 years against the forces of Mithridates the Great. It was a war he was, although he came close, not destined to win. Being undermined by his troops and the politics of Rome. But he'd been fighting a foreign war for 8 years.

Some 2000 years later you can look at our own wars, both in Afghanistan and Iraq, and you can see the same thing. The nature of the fighting has been changed by technology, the nature of the reporting also, but not the nature of war itself. We've been in Afghanistan for 7 years and Iraq a little less.

In 2000 years the nature of fighting a war does not seem to have changed. Instead what has changed is our culture, our expectation of what war is, how it is fought, and how it should be won. Something can be news for a day, maybe for a week, but then people want to quickly move on. News should know it's place.

14/06/2008 11:18 by Matt Mower | Permalink | comments:

Pop ruby quiz

I have a couple of posts about my experience with moving to Rails 2.1 that I should write but, you know, the whole topic wasn't much fun. Now you may think "not much fun" is the underlying theme around here and, i guess, you could be right. But I try not to wallow too much.

Anyway pop quiz. So:

Array( 1 ) == Array( [1] ) == [1]


f( { :a => true } ) == f( [ { :a => true } ] ) == [ { :a => true } ]

but, and here's the question, what is f?

Array() went and let me down and really don't want to have to start writing code with .class == Array in it. So, is there an f already out there?

Pop answer: from John Barnette (jbarnette) and David Black (dblack):


this works because I have no inner arrays to worry about being over-flattened. Neat. Thanks guys.

09/06/2008 16:11 by Matt Mower | Permalink | comments:
More about:

SystemStackError with Rails 2.1

One of the changes introduced in Rails 2.1 validates the has_one association when a model is saved. This is fine until it hits a self-referential model, in my example this is a Relationship which has an inverse Relationship, i.e.

class Relationship < ActiveRecord::Base
  has_one :inverse, :class_name => 'Relationship', :foreign_key => 'inverse_id', :dependent => :nullify

When such a model (where it has an inverse model in place) gets saved you get a rather ugly SystemStackError "Stack level too deep".

Once you understand the patch from the commit I linked above and you plod through the stack trace for a bit you realise that was is happening is that the call to valid? on the first model follows the has_one association to the second model. It calls valid? on the second model which leads back across the has_one to the first model again. Where it calls valid?. Pretty soon you have yourself a stack related mishap.

Rails contributer Jan De Poorter came up with a neat work-around for my situation which is to stub out the association validating method that has_one is creating for my inverse relationship, i.e. defining:

def validate_associated_records_for_inverse

in my model breaks the circular valid? call chain over this association. In the case of a Relationship model it has no validations of it's own so it's not a problem not validating it.

There was some talk in #rails-contrib about the reason for this change (apparently to conform to what already happens with has_many), it seems it was already attempted on belongs_to and backed out because of problems there also. Jan has also contributed a change to allow specifying :validate => false on associations to suppress the new validation of associations behaviour in a less implicit way.

So if you come here via Google because of SystemStackError "Message: "stack level too deep" error related to a has_one or perhaps has_many relationship, check out the linked ticket and patch and see if this workaround helps you too.

My thanks again to Jan De Poorter for spotting such an easy work-around which lets me get on with the business of writing!

03/06/2008 11:25 by Matt Mower | Permalink | comments:
More about:

The best thing about Maglev

I'm reading quite a few gushing articles about Gemstones new VM for Ruby: Maglev. Now it's only 3 months old (and heaven knows how complete) but it's already doing enough to impress people with how fast it is. That's great news.

Not because I necessarily expect I will ever use Gemstone. I mean, I might, at some point in the future, who knows? But it's not something to think about right now.

Yet I'm still very pleased to hear this because it means that a fast Ruby VM is possible. Which means that the Rubinius guys are short only time and, maybe, experience to get the job done right. But just knowing that it's possible to run fast, even if you don't know how yet, can be a great motivator.

Yep the best thing about Maglev right now is that it gives me hope for Rubinius.

01/06/2008 17:44 by Matt Mower | Permalink | comments:

The colour purple

Today I've had my 5th kyu, "purple belt", grading in Shotokan karate. Each grading is, unsurprisingly enough, harder than the last but this one felt especially demanding both physically but also technically in terms of the combinations of basic moves you have to learn. I felt marginal about my ability and pushed hard so I was very grateful to pass it!

I've been learning karate for 15 months now. Time flies when you're having fun. Watching the white belts during their lesson today it was easy to remember myself back there wondering if I would ever be able to pass that first grading.

I remain grateful to my Sensei, Richard Hughes, for his teaching and encouragement. I'm looking forward to wearing my new purple belt and learning all the new things that go with it.

01/06/2008 17:37 by Matt Mower | Permalink | comments:
More about: