Category: javascript
05/26/06 06:19 - 65ºF - ID#37328
call me
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
Permalink: call_me.html
Words: 391
Location: Buffalo, NY
Category: computer
05/25/06 07:56 - 56ºF - ID#37327
i throw it a scrap and it hums
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
Permalink: i_throw_it_a_scrap_and_it_hums.html
Words: 571
Location: Buffalo, NY
Category: computer
05/23/06 10:34 - 51ºF - ID#37326
w00+
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
Permalink: w00_.html
Words: 115
Location: Buffalo, NY
Category: marketing
05/20/06 10:46 - 50ºF - ID#37325
idiocy or genius
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 ]
Permalink: idiocy_or_genius.html
Words: 242
Location: Buffalo, NY
Category: news
05/18/06 04:02 - 53ºF - ID#37324
mystery of el greco christ revealed
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
Permalink: mystery_of_el_greco_christ_revealed.html
Words: 153
Location: Buffalo, NY
Category: defiance
05/17/06 08:13 - 56ºF - ID#37323
best ugly local website award
So in that spirit, I thrust both middle fingers skyward and wave them defiantly in the direction of the art department and propose: The Best Ugly Local Website Award. Substitute 'utilitarian' if you must, but you know exactly what I'm talking about. It's that one website that was designed in Netscape Navigator Gold 3.04 about ten years ago that lives in some god-forsaken frameset at greyskull.someancientbbs.net/~skeletor79/Great%20Stuff/default.htm that you still visit all the time because it's the best damn website around. So let's fire up Lynx and get this party started!
At the risk of creating enemies, I nominate Bill Rapaport's ***** INTERACTIVE ***** BUFFALO RESTAURANT GUIDE , which has existed in one form or another since 1988. This guy is a motherfucking machine. Dude's got more restaurants listed than I have any hope of ever going to, and he does it all in HTML3.2. No Quicktime, Flash, AJAX, Javascript, or even CSS, just a huge wealth of information - the World Wide Web as pure as Tim intended *.
So let's hear it! What ugly websites are in your bookmarks?
- Z
_______________
- 'Storage of ASCII text, and display on 24x80 screens, is in the short term sufficient, and essential. Addition of graphics would be an optional extra with very much less penetration for the moment.'
Permalink: best_ugly_local_website_award.html
Words: 273
Location: Buffalo, NY
Category: optimism
05/17/06 06:16 - 58ºF - ID#37322
'hey dave look at this website'
good mechanics under the hood .....but it looks like an absolute bore....
which then went on to compare our site to another extremely popular and more brightly-colored local website. So I said that
The popularity of a website has less to do with how many colors it uses than with what it has to offer readers.
and explained that if one wants people to visit a site more often than once a week, it had better have fresh content more often than once a week.
Yesterday I was told by someone else that there were going to be professional web consultants critiquing websites at an upcoming conference and would I like to volunteer our site? So yeah, I said of course, it would be great to have an actual professional look it over. She said great, but clear it with the boss first. So I emailed him and he replied that we'd better hurry because
they may not accept us if they are looking for more primitive newspaper sites that are really bad
So in a way, I'm actually really relieved that while our site is pretty bad, there are some out there that can be considered really bad. Go me!!
- Z
Permalink: _hey_dave_look_at_this_website_.html
Words: 337
Location: Buffalo, NY
Category: server
05/16/06 04:25 - 59ºF - ID#37321
network out[r]age
One of our lines remains up, the other remains down, and Verizon has been notified. More updates when available and possible. Sorry guys.
- Z
Permalink: network_out_r_age.html
Words: 75
Location: Buffalo, NY
Category: potpourri
05/15/06 08:20 - 53ºF - ID#37320
a man like putin
On a trip to Pakistan after this song became popular, Pres. Musharraf said to Pres. Putin: 'So I hear they even write songs about you,' to which Putin replied, 'Yes, I have to put up with everything.'
My boyfriend is in trouble again.
He got in a fight and got stoned on something nasty.
I've had enough, and I chased him away,
and now I want a man like Putin.
A man like Putin, full of energy.
A man like Putin, who doesn't drink.
A man like Putin, who wouldn't hurt me.
A man like Putin, who won't run away.
I saw him on the news last night
He was saying the world was at a crossroads.
It's easy with a man like him at home or out on the town,
and now I want a man like Putin.
gather:0314877001147695425
- Z
Permalink: a_man_like_putin.html
Words: 192
Location: Buffalo, NY
Author Info
Date Cloud
- 10/11
- 08/10
- 07/10
- 06/10
- 05/10
- 04/10
- 03/10
- 02/10
- 01/10
- 12/09
- 11/09
- 10/09
- 09/09
- 08/09
- 07/09
- 06/09
- 05/09
- 04/09
- 03/09
- 02/09
- 01/09
- 12/08
- 11/08
- 10/08
- 09/08
- 08/08
- 07/08
- 06/08
- 05/08
- 04/08
- 03/08
- 02/08
- 01/08
- 12/07
- 11/07
- 10/07
- 09/07
- 08/07
- 07/07
- 06/07
- 05/07
- 04/07
- 03/07
- 02/07
- 01/07
- 12/06
- 11/06
- 10/06
- 09/06
- 08/06
- 07/06
- 06/06
- 05/06
- 04/06
- 03/06
- 02/06
Category Cloud
More Entries
My Fav Posts
- This user has zero favorite blogs selected ;(