QotD: The Best Blend

the blue bottle americano

What’s your favorite blend or brand of coffee or tea?

Coffee: Blue Bottle. Is there anything else?

For tea, I’m torn between PG Tips, Mighty Leaf Darjeeling, or my local favorite teahouse Samovar.

Originally posted to ydnar.vox.com in February 2007.

No Weight!

Via Gizmodo: Eggcarton bathroom scale. Rock!

Originally posted to ydnar.vox.com in February 2007.

Farewell, Aquacam

Olympus Stylus 725 SW

The Aquacam died a horrible salty death this weekend. Ensconced in the back pocket of my jersey, it absorbed a little too much salty moisture over 200 miles even for it to handle. Farewell, you were a great camera.

Dear Google: What is a good water-resistant camera for a sporting fellow?

Google: The Olympus Stylus 725 SW!

DPReview: Not for sale in the US.

Doh.

Edit: Yay! Hopefully ships in time for my birthday…

Originally posted to ydnar.vox.com in February 2007.

Vox Hunt: Overdubbed

Grace

Audio: If you could sing like anyone, living or dead, who would you choose to sound like? Share a song of theirs. Submitted by aa.

Jeff Buckley. No contest.

Originally posted to ydnar.vox.com in February 2007.

The voices in my head

Ratatat

So Nick and I were talking on IM about Ratatat today:

ydnar: So we’re riding up back from LA, listening to Ratatat ydnar: and I could have sworn it had lyrics. ydnar: Tina commented that it didn’t. I swore I’d heard some ydnar: Guess the song form is trad rock, so I was imagining them.

Nick O’Neill: It has some samples in it.

ydnar: Right.

Nick O’Neill: I definitely would expect it to have lyrics as well.

ydnar: So we started making shit up. Not lyrics per se, but stuff like “this song totally has a brit pop vocalist whining about his ex-girlfriend.”

Nick O’Neill: And I’m sure it would be true if either of those guys could sing.

Originally posted to ydnar.vox.com in February 2007.

A Double

In a little over an hour, Tina and I will be heading down to SoCal for the Butterfield Double Century. I’m keeping my fingers crossed the Sixaflu that attacked me earlier this week will have been drubbed out of my system by tomorrow morning. I feel well enough to drive, I hope that upward trend continues. Here’s to vitamin C!

Originally posted to ydnar.vox.com in February 2007.

Non-Sucky Bluetooth Headphones

Motorola Bluetooth Headphone Sex

Finally, fercrissake (via Gizmodo).

Originally posted to ydnar.vox.com in February 2007.

The Vox Phone

HTC Vox

HTC Vox officially unveiled (via Engadget). Hah!

Originally posted to ydnar.vox.com in February 2007.

A Rainy Saturday Morning

que?

On Saturday, Pista got to run in Alamo Square with Stella in a brief window when it stopped raining. Noshed with Jen and Jay at BlueJay Cafe. Bacon, eggs & blueberry pancakes = teh win. Earlier Pista and I went to the Potrero Sports Basement, and after brunch we went to the Presidio store. Pista had snacked on my black shell jacket (the fifth one if you’re counting) and it was time to get more fodder for the Maw. Hoping for a week’s worth of jacket usage this time.

Spent no money at the 2nd SB visit (yes!) but did drop a lot of coin putting together my costume for Misty’s ever-awesome annual Procrastinator’s New Year’s Eve party. I was the Math Avenger, mild-mannered math professor by day, and smacktalking, derivative-calculating, vigilante superhero by night. Will post more about this in a bit…

Ducati 1098

Before the trip to Clothes by the Pound, I hit Munroe Motors for the Ducati 1098 launch. They had a single 1098S (apparently the S stands for sold), sandwiches and posters to give away. Most people ignored all of that and just lusted after the new bike. It looks better in person than in pictures. Really, drool.

Edit: Realized this post doesn’t contain any mention of cycling or rock-climbing. I went cycling today with Tina (we rocked a modified combined Fairfax + Paradise loop for a solid 68 miles or so. Did it on the fixie because I’m badass like that the road bike’s in the shop. Sunday weather totally made up for the shitty Saturday. Tyson at American insists my bike will be ready by Tuesday for our double next weekend. Excited!

Edit: Rock climbing!

Originally posted to ydnar.vox.com in February 2007.

Refining Superclass Method Calls in JavaScript

Last week I was revisiting the always fun problem of implementing “classical” inheritance in JavaScript. I’d taken a few stabs at it, and had gotten it to a reasonably good state that borrowed some good ideas from Doug Crockford, Sam Stephenson, and Dean Edwards. Joshua Gertzen wrote a good post about various methods on his blog.

I’ve never been terribly thrilled with the form Class.superClass.method.apply( this, arguments ). It was redundant: replicating both the class and method names. Copy & paste of code could lead to subtle errors, and it’s annoying to type that much. But the alternatives were worse: Recompiling the function to generate a “magic” lexical for the superclass or wrapper methods. So the Class object basically sat untouched for a year and a half.

Back to last week…It occurred to me that in all the JavaScript we’d built for Vox, we almost never shared a method between two objects, except via inheritance. There were a couple exceptions, but they could be rewritten (it turned out to be a good idea anyway). Second, functions are objects like everything else, and can have arbitrary properties. Third, arguments.callee is available in every function call in JavaScript. I realized then that storing the superclass was not as useful as just storing the supermethod.

For any given method in a class, store its supermethod as a property of the method: method.__super. Instead of the unwieldy construct above, any method could simply use arguments.callee.__super.apply( this, arguments ).

The Class constructor from Core.js:

Class = function( sc ) {
    var c = function( s ) {
        this.constructor = arguments.callee;
        if( s === __SUBCLASS__ )
            return;
        this.init.apply( this, arguments );
    };

    c.override( Class );
    sc = sc || Object;
    c.override( sc );
    c.__super = sc;
    c.superClass = sc.prototype;

    c.prototype = sc === Object ? new sc() : new sc( __SUBCLASS__ );
    c.prototype.extend( Class.prototype );
    var a = arguments;
    for( var i = 1; i < a.length; i++ )
        c.prototype.override( a[ i ] );

    for( var p in c.prototype ) {
        var m = c.prototype[ p ];
        if( typeof m != "function" || defined( m.__super ) )
            continue;
        m.__super = null;
        var pr = sc.prototype;
        while( pr ) {
            if( defined( pr[ p ] ) ) {
                m.__super = pr[ p ];
                break;
            }
            if( pr === pr.constructor.prototype )
                break;
            pr = pr.constructor.prototype;
        }
    }

    return c;
}

arguments.callee was useful in the constructor too: Instead of creating a circular reference by overriding the constructor like this: constructor.prototype.constructor = constructor, the constructor itself can just set it on the this object when the constructor is called: this.constructor = arguments.callee.

Calling a supermethod can be simplified further, to arguments.callee.applySuper( this, arguments ) via a little sugar:

Function.prototype.extend( {
    applySuper: function( o, args ) {
        return this.__super.apply( o, args );
    },

    callSuper: function( o ) {
        var args = [];
        for( var i = 1; i < arguments.length; i++ )
            args.push( arguments[ i ] );
        return this.__super.apply( o, args );
    }
} );

Originally posted to ydnar.vox.com in February 2007.