Archive for July, 2008

jQuery serializeArray: Why Not An Associative Array?

7

I’m trying to examine and modify form variables from jQuery by catching the submit event. jQuery has a serializeArray method that hands you the form variables in a nice array. For example:


	$('#someform').submit( function() {
		$.post("/some/url/", $(this).serializeArray(),
			function(data){
			    console.log(data);
			}, "json");
		return false;
	 } );

This is great, but the result of serializeArray is an integer indexed array whose values are (key,value) pairs. Eg.


	var data = $(this).serializeArray(),
	console.log( data[0] );
>> output: Object name=somename value=537

I’m wondering why the array looks like this, instead of being a dictionary (associate array, hash, or whatever you want to call it) such that the keys are “name”s and values are “value”s. Eg.


	var data = $(this).serializeArray(),
	console.log( data.somename );
>> output: 537

Anybody know the answer?

Shopping For Broadband Access Card / Service

0

Cell Tower

I just cancelled my Verizon broadband account, mainly because the card was no longer working in my PC and the mac doesn’t take PC cards. I was surprised at how little effort Verizon put in to keeping me; I’ve been paying the $80 per month for almost 2 years now, and they let me go without giving me much incentive to stay.

I’m hoping the new 3G iPhone will be able to act as a modem; I could possibly stomach paying the outrageous monthly fees if it replaces my extra broadband card. I’m pretty sure it’ll be able to, through legitimate or hacked means, shortly after release.

Anyway, I do need wireless broadband service, so I’m going to get a new card and service. If you have a card / cell phone / service you use let me know what you like and dislike about it.

Photo by joneser005.

Black Nerds

0

Interesting essay from David Adewumi on Why Black Nerds Are Unpopular. My observation on nerdism and popularity, based on going to school in three different continents, is that “nerds” are an American invention. Popularity, or lack thereof, is of course universal, but being a social outcast due to intelligence is mostly American.

In Iran, for example, I’d say it was much closer to “winners” and “losers”. The smartest kids were often also the popular kids, and they also often participated in sports. My main arch-nemesis in school (later my best friend) was not only one of the top students, but also our best athlete. Being smart was not a detriment to popularity.

In England I remember learning the concept of “nerd” from America sitcoms, and being mostly puzzled. I only went to school for three years there and even that in a private school, so I can’t vouch for general public schools, but I don’t think the concept of nerd is very strong there either. Being popular or unpopular certainly exists, but intelligence doesn’t carry the kind of stigma it does in the US.

Cross-Language Data Serialization and Exchange

0

Interesting new open source release from Google called Protocol Buffers. Language neutral data serialization and exchange via protocol definition and generated code for C++, Java, and Python.

Apparently Protocol Buffers are heavily used inside Google, so they look to be a robust implementation. Should be a good format for wire protocols.

They compare it to XML and tout its size and speed advantages. In a client/server implementation, however, JSON is the more likely alternative. I wonder how the size and speed compare.

In Bruges: Not Too Bad

0

Watched In Bruges. Really not too bad. The British do good gangster movies – not shy about violence, but also layers of introspection and classical tragedy elements. I recommend it, worth seeing.

Javascript Is The Guy With The Thing

2

Man with ShovelIn most programming languages (Java, C, Python, Perl) I’m generally thinking “I’ll put this thing on this shelf here, then I’ll do x, then I’ll pick up that thing, do some work on it, put the result over here,” and so forth.

With Javascript, particularly when used correctly, which for me means in the Way Of JQuery, the thought process is more like “When some event happens, this guy will wake up and he’ll know what to do. He’ll remember his name, what he was supposed to work on, and he’ll be carrying his own tools. He might get blocked at some point, but then he’ll just wait around and when he’s ready to go he’ll remember who he is, what he was doing, and how far along doing it he was. And when he’s done he’ll go away and along with him will go his tools and any other mess he made”.

Javascript is a lot more “guy with the thing” thinking instead of “what’s on this shelf here?” thinking. I guess that’s called closures, or something like that. Anyway, I’m liking it.

Photo by St-Even.

Put A Queue In Your Standard Toolkit

2

Kids Queue

A friend forwarded me an email about yet another group using a database to implement what’s really a queue. Not surprisingly, performance is an issue.

Queues are still not part of the average developer’s standard set of tools. At least the Java world has a standard API and several good implementations to pick from. The scripting world is a hodge-podge, and I still haven’t found a great choice despite a good bit of looking.

I’m looking forward to a simple, commonly used queue interface / implementation that people can wrap their heads around and employ widely. Use of queues is one of the basic techniques for achieving scale, and we’re still lacking the basic tools to use it.

Photo by Sean Dreilinger.

Stereotyping Germany

1

Watching the Euro 2008 games. Yes, many days late.

The Germany-Turkey game was an interesting one. The entire time watching I was reminded of our European trip, oh, about 10 years ago.

We spent a lot of time sharing trains with lots of people from lots of countries. Twice with Germans.

The first was with 2 excellent, lovely guys who were traveling the world riding roller coasters. They were very excited when they found out we were from California, apparently home to some of the world’s best. They really turned out to be nice guys and we spent a long time chatting.

They made a point of talking about the changes in Germany; the fall of the wall, the changes in attitudes, and the new-found tolerance. It seemed the shadow of the Nazi legacy weighed on their minds and it was important for them to erase it.

Fair enough. I know a number of people living in Germany, both natives and foreigners, and they all seem to like it. A good friend of mine, of Iranian descent, found his soul in Heidelberg. Anyway, I had no trouble believing what they had to say.

Then, some time later, the discussion turned to the Turks.

It turned out the Turks were the cause of all evils in Germany, usurping German jobs, dealing drugs, stealing, and generally not being very neighbourly.

I didn’t think much of it; every country has a group they blame for everything.

And then they said something like “… and we have to round them all up and burn them”.

Huh.

The second German we spent time with was a female DJ touring Europe, apparently a well known one. The pattern of conversation was similar – the tolerance and changes, followed by a clear, although much less harsh condemnation of the Turks.

A few weeks ago I met a young man from Germany. I asked him where he was from, and he told me he was Turkish. I asked where he was born, and he said Germany. “Then you’re German”, I said. “No”, was his simple reply, and his expression told the whole story.

Obviously a sample size of two doesn’t mean anything, but it’s come to flavor my impression of Germany. I hope to increase my sample size and dispel this impression.

Anyway, I was rooting for Turkey.

« Previous Page