Sam Loutzenheiser

By watching television one should be able to guess that no matter how old you get, the same bullshit is always waiting to haunt you… but for whatever reason I reasoned that problems, no matter how complex, are in someway bound and finite. And in that reasoning, I came to the subconscience conclusion that if I work all of the existing ones out, I could actually live in peace… Sadly, this assumption was clearly wrong.

No comments · Written by Nathan at 12:38 pm · Tags


Me: I didn’t program multitasking support in revolve ball
Me: cos I’m lazy Ed: you didnt ‘ganbaru’ M

Me: I didn’t program multitasking support in revolve ball
Me: cos I’m lazy
Ed: you didnt ‘ganbaru’
Me: oh shit! you’re right

No comments · Written by Nathan at 12:21 pm · Tags


Populate a form with a
serialized data string using jQuery

OK, so you know about the great jQuery utility method serialize(), which, when applied to a jQuery object that represents a form, will turn all the form data into a key/value serialized string. Randomly, I was asked if it was possible to do the reverse. jQuery doesn’t have a method like that baked in, so here’s my implementation.

function loadSerializedData(formId, data)
{
	var tmp = data.split('&'), dataObj = {};

	// Bust apart the serialized data string into an obj
	for (var i = 0; i < tmp.length; i++)
	{
		var keyValPair = tmp[i].split('=');
		dataObj[keyValPair[0]] = keyValPair[1];
	}

	// Loop thru form and assign each HTML tag the appropriate value
	$('#' + formId + ' :input').each(function(index, element) {
		if (dataObj[$(this).attr('name')])
			$(this).val(dataObj[$(this).attr('name')]);
	});
}

Is there a better way to do this? Let me know in the comments.

1 comment · Written by Nathan at 2:50 pm · Tags


Here’s your obfuscated Javascript
for the day

function startsWithVowel(word)
{
return [‘a’, ‘e’, ‘i’, ‘o’, ‘u’].indexOf(word[0]) != -1;
}

No comments · Written by Nathan at 2:54 pm · Tags


pixelstyle: Mega Man 2, NES – 1989

pixelstyle:

Mega Man 2, NES – 1989

No comments · Written by Nathan at 10:08 am · Tags


Older Posts →