Journaling on estrip is easy and free. sign up here

Zobar's Journal

zobar
My Podcast Link

05/26/2006 18:19 #37328

call me
Category: javascript
This post is extremely nerdy, so for those of you who don't care about Javascript's object model, have a good weekend, you may skip the rest of the post.

OK, so now that I'm talking to the nerds, here's some neat Javascript voodoo. I really like monkeying around with runtimes, and one reason that I like Python so much is that it lets you do all kinds of perverse things to the runtime with some very elegant effects. One thing it lets you do is define "callable" objects - objects that you can call like any plain old function. Classes, eg, are callable; this invokes the constructor and returns a new instance of the class. This maintains a similar syntax to other languages, except it's cleaner:

myInstance = MyClass() # python
var myInstance = new MyClass(); // Javascript
MyClass* myInstance = new MyClass(); // C++
MyClass* myInstance = [[[MyClass alloc] init] autorelease]; // Objective-C

This also makes for very elegant RPC calls. You can, eg, create a callable instance that you can use like a regular function, but takes care of all the grotty marshalling and connection management behind the scenes. Once you set it up, you can use the instance like any other function:

import xmlrpclib
server = xmlrpclib.ServerProxy('http://time.xmlrpc.com/RPC2')
print server.currentTime.getCurrentTime()

I'm writing a Javascript XML-RPC client library for work and I really wanted to be able to do something that elegant, like:

getCurrentTime = XMLRPCMethod('http://time.xmlrpc.com/RPC2', 'currentTime.getCurrentTime');
alert(getCurrentTime());

But in Javascript, you can only call things that are actual functions. However, since functions are first-class objects, you can bind your own attributes to them like any other object. You can access them from inside the body of the function by using the special variable arguments.callee:

function Greeter(yourName) {
    var result = function(timeOfDay) {
        alert('Good ' + timeOfDay + ', ' + arguments.callee.yourName);
    };

    result.yourName = yourName;
    return result;
}

greetZ = Greeter('Zobar');
greetP = Greeter('Paul');

greetZ('afternoon'); // 'Good afternoon, Zobar'
greetZ('evening'); // 'Good evening, Zobar'
greetP('evening'); // 'Good evening, Paul'

When I figured this out it blew my mind, and while I doubt its day-to-day practicality, I thought it's a handy tool for Javascripters to have. I also plan to make the XML-RPC library public, once I clean it up a bit, test it in MSIE, and finish the documentation.

- Z
carolinian - 05/27/06 18:38
In the past, I've tried to design complex OO stuff in JavaScript, spent a lot of time doing it, had it not work, and wished that netscape had instead made python the standard language of web page scripting.

Considering the number of people who are having success with OO javascript, perhaps I should try things again and give the language one last chance to redeem itself.

paul - 05/27/06 10:39
I responded to this again on my journal (e:paul), 4370 so that I could include larger code samples. It includes some objects instantiation inside of prototypes.
paul - 05/27/06 00:15
I responded to this on my journal (e:paul,4369) because the response was too long to fit in a comment. I also added the new [box] style for displaying code.

05/23/2006 22:34 #37326

w00+
Category: computer
So my computer's been pretty good to me, but lately just weird little crappy things have been going wrong with it. The CD/DVD drive, I think, was a lemon that kind of worked when I first got it, but lately doesn't do jack. Batteries, of course, get old and eventually can't keep a charge. The Airport [11Mbps] card started acting funny and now doesn't really work at all.

So today, I sucked it up and bought a new black 13" MacBook . I haven't even finished installing the updates on it but let me tell you this shit is hot. Now I just gotta get moved in.

- Z
jason - 05/24/06 12:44
Josh and I were SUPER IMPRESSED by the new MacBooks. I see one in my future.
carolinian - 05/24/06 01:16

[zobarsCurrentLaptop autorelease];
zobarsCurrentLaptop = [sexyNewMacBook retain];

NSLog(@"Damn I envy Zobar.");
jenks - 05/23/06 23:04
yeah keep us posted... I've been scoping 'em out, but figured maybe I'd wait for the second generation of intel chips.
joshua - 05/23/06 22:34
The new Macs are hawt - congrats.

05/20/2006 10:46 #37325

idiocy or genius
Category: marketing
OK, so a socially-conscious hip hop act [The Black Eyed Peas ] goes on tour, underwritten by a major Japanese auto manufacturer [Honda ]. Of course they need an over-the-top promotion.

Since they are a hip-hop act, it would seem to follow that they should give away a custom Civic. But since they're socially-conscious, it would seem to follow that they should give away one of Honda's alternative-fuel vehicles. And thus was begat the Black Eyed Peas Riced Out Honda Civic Hybrid Tour

(e:dragonlady7) imagines a discussion in Marketing where one manager says, 'why don't we give away a custom Civic?' and another manager says, 'make that a Civic Hybrid' and the other manager says, 'done,' and all the underlings groan and make fun of them at the water cooler for having no idea.

I guess I have more faith in the human condition than that. I imagine the ad exec coming in and saying, 'Dude. We gotta give away a riced-out Civic Hybrid. How awesome would that be?' and the manager goes, 'no that's ridiculous,' and the ad exec spells it out real slow, like 'Dude. Riced - out - Civic - Hybrid,' and the manager goes 'yeah, ok, that would be pretty sweet.'

- Z

[New journal music: The Skatalites/James Bond Theme gather:0481374001148138769 ]

05/18/2006 16:02 #37324

mystery of el greco christ revealed
Category: news
I picked up a copy of 'Kepa 3 Gallery News,' v1n1 at lunch today. Very amusing. It is a one-page, front-and-back, 11"x17" xeroxed paper, written and illustrated entirely in laundry marker. I liked the following two articles, which were necessarily short due to the medium:

Mystery of El Greco Christ Revealed

Prado, Madrid- Officials find "trimmed" portion from middle section confirms tighty whitey prototype theory.



Casino to promote fine art using Vegas style. Is it possible to believe that big dollars will finally promote local fine art!? Past mayor Tony said Friday that this and pulled pork are win wins for our city.



It gave me an interesting idea for a concept newspaper: find a dozen interesting people and give them each a page. Content, photos, graphics, design are entirely their responsibility. Use InDesign, Word, paste-up, typewriter, marker, MS Paint, whatever. Collect and publish regularly.

- Z
zobar - 05/19/06 12:52

what qualifies a person as interesting?



I don't know. Would you read their page?

I think almost everybody's interesting if you talk to them long enough. I love reading, eg, McSweeney's 'Interviews with People Who Have Interesting or Unusual Jobs' :::link::: .

If I were running the paper, I would think of it as more of an experimental social art project than as a Serious Publication, so I would do what I could to run everything I got.

- Z
libertad - 05/19/06 11:19
what qualifies a person as interesting?
dragonlady7 - 05/19/06 09:17
isn't that this site?

only without laundry marker. This site needs more laundry marker.

05/25/2006 07:56 #37327

i throw it a scrap and it hums
Category: computer

My computer and me are both brief in this world, both foolish, and we have earthly fates.



Yes, it's dorky to eulogize a computer, but I am a computer geek and one tends to get attached to these things . So please, a brief moment of silence for my old computer, which has served me honorably and well deserves its retirement.

...

ENOUGH! Now, we drink! We feast! We spit on the face of death for another day! BAH!

Here's my first and second impressions of the new MacBook:

The MacBook and MacBook Pro are much closer to each other than the iBook and PowerBook ever were . Both come standard with a built-in iSight camera that can be used for taking dorky pictures of yourself; both have AirPort Extreme and Bluetooth standard, and at 6 hours, the MacBook has better battery life and lower power consumption than the MacBook Pro. In fact, almost everything in the MacBook can be upgraded to bring it in line with the MacBook Pro. <geeky>The MacBook has an integrated video card which, I guess, is bad if you're playing 3D action games. Since the video card mooches off main memory I would recommend a RAM upgrade, but other than that I wouldn't sweat it. The MacBook also lacks a PCMCIA port, but I never used mine on my old computer.</geeky>

The black MacBook costs $150 more than an equally-outfitted white MacBook. I admit it, I paid the Vanity Tax. Much like the Stella , it's less about how fast it is than about how you look when you're pushing it home. Although you can't tell from the pictures , it is finished in a matte black plastic that looks like a post-WallStreet, pre-TiBook prototype, and is very classy in an understated, Little Black Dress kind of way.

The monitor is the perfect size; there are as many pixels as I am used to [1280x800] but they are made to fit on a 13.3" monitor rather than the 15" of my previous laptop. I think this is the ideal size- large enough to use, but small enough to carry around. Much has been made of the glossy, high-saturation [and presumably high-glare] screen coating, as opposed to the traditional matte, low-glare [and presumably low-saturation] screen coating. The colors are, indeed, very deep and saturated. As for the glare, I have not had a problem yet. Yesterday morning, (e:dragonlady7) was using it in a sunny window and, with the brightness turned all the way up, could still read it.

Apple finally put in a widescreen trackpad to go along with the widescreen monitor. They may have gone a little overboard, though, 'cause this thing is enormous. It still only has one button, because Apple are stubborn fucks, but it compares favorably even to the five-button + nub + trackpad that we have on the ThinkPad at work . The new trackpads accept two-fingered input, so a two-fingered tap is like the right button, and a two-fingered drag is like a two-dimensional scrollwheel. If you're used to tapping, this feels very organic and works really well.

I gotta go get ready for work now - more updates as they become available!

- Z