Sep
23
2009

rockets pt deux

столове

Share/Save

Sep
23
2009

league

Share/Save

Sep
23
2009

Grizzlies

Share/Save

Apr
21
2009

testing embedding

Share/Save

Apr
13
2009

or, A Bulleted List of Funny Things About a License Plate I Saw In The Parking Lot At Whole Foods

You aint Gangsta you dont even know one

  • Nothing says “gangsta” like “prestige tag”
  • Nothing says “gangsta” like “shopping at Whole Foods”
  • Life is full of Hard Knox in Virginia, but the fall foliage can be pretty spectacular
  • Only a true Gangsta is hard enough to display their gangstaness on the back of a white Pontiac
  • The Shenendoah Valley has been woefully underrepresented in the whole EastCoast / WestCoast Bout

Share/Save

Feb
18
2009

Be Careful parsing your URL string with Javascript

…so I know you’ve looked around the net for a good method to parse URL variables with javascript, and I’m sure that you’ve found some elegant method that looks something like:

function parseLocation() {
	var turl = window.location.search;
	ar = turl.split('&');
	var b = {};

	for (var i = 0; i < ar.length; i++) {
		var c = ar[i].split('=');
		b[c[0]] = c[1];
	}
	return b;
}

and you’ve thought, “oh, look how nice and compact that is. I shall use it post-haste!” Well, let me, as Mr. Guy Who’s Gotten Plenty Of Grumpy Complaints About This, light a candle rather than curse your darkness.

It is a good method, don’t get me wrong. It works great in theory. The problem is, say you copy/paste you url into, say, your Blogging Software of choice*. It might then re-interpret your url from:

http://post-hipster.com/parsey.html?var1=hey&var2=mambo&var3=fagabefe

into

http://post-hipster.com/parsey.html?var1=hey&amp;var2=mambo&amp;var3=fagabefe

and, on some browsers*, no amount of encode() or decode() will make that go away, which, in essence, changes your parsed variable names int “amp;var2″ and “amp;var3″

My solution, however inelegant, is to make the function explicitly look for the variables in question:

function parseLocation() {
	var turl = window.location.search;
	ar = turl.split('&');
	var b = {var1:'default_for_var1', var2:''};

	for (var i = 0; i < ar.length; i++) {
		var c = ar[i].split('=');
		if (c[0].indexOf('var1') > -1) {
			b['var1'] = c[1];
		} else if (c[0].indexOf('var2') > -1) {
			b['var2'] = c[1];
		} else if (c[0].indexOf('var3') > -1) {
			b['var3'] = c[1];
		}
	}
	return b;
}

I know, I coulda just RegEx’ed the ‘amp;’ away, but this way prevents any other encoding mishaps. If this was a global function, across a buncha different pages, I probably would just look for and get rid of the ‘amp;’

So there you go. Unfortunately, URL parsing isn’t always as nice as we want it  to be.

* unfortunately I can’t be more specific than this, because I haven’t yet been able to duplicate the error on any browser / os combination I’ve tried, but I’ve gotten enough complaints about it to know that it exists.

Share/Save

Feb
02
2009

This one fires on pretty much all cylinders for me:

  • Music Nerd
  • Programming Nerd
  • Irony Nerd
  • Economics Nerd
  • Net Humor Nerd
  • Stats Nerd
  • Charts & Graphs Nerd
  • Liberal Political Value System Nerd

Share/Save

Jan
20
2009

More mildly amusing stuff from work

Arsonists

The video capture is not, in fact, the Arsonists Caught on Tape, but of the ad that preceded the video of the aforementioned arsonists, in which this guy burns all his luggage cause now he’s got gotomeeting and is going to Do More while Travelling Less, and apparently never go on vacation again. I’d qualify this more as a ‘hah’ than a ‘lol’.

Share/Save

Jan
19
2009

Here on Captain Santa Island

Yo-Ho-Ho-Ho and a dead man's chest

15 men on a dead man’s chest / Yo-Ho-Ho-Ho and a bottle of rum!

Share/Save

Jan
18
2009

Skull Pancake

Found while making pancakes this morning

Share/Save

 
Powered by Wordpress and MySQL. Theme by openark.org