They may forget what you said, but they will never forget how you made them feel. – Carl W. Buechner

February 21, 2008

Last week I decided I was going to have a quiet weekend, so before I left the office on friday I took a look at our communial bookshelf and picked up a new book. This time it was the turn of “The art and science of javascript“. The book is pretty good,  it piqued my interest in the subject. I’ve written a bit of javascript in the past, all client side validation, prettyness, nothing great. I certainly hadnt done any real AJAX. The thing with calling it AJAX is that it suggests its some sort of framework, AJAX sounds scary. Its not, to be honest “AJAX” is actually so, so simple. Take a look at the wikipedia page… just jump straight to the code example,

In the back of the book there is a mash-up of flickr and google maps. I decided to do a mashup of twitter and google maps. Im well aware of twittervision, but the problem with it is that its the public-time line, not your friends, sooo… i decided to mash-up your friends updates with google maps in a twittervision style.

Heres how I got on (abridged):

Iteration 1 : Get one thing working. Got api key from google maps, displayed a simple map

Iteration 2: Put the parts together. I put some ajax code (like that on the wikipedia page) and tried to get the results of calling the endpoint – It didnt work.. then i realised i needed to provide http basic auth credentials.. still didnt work. (I should note i used firebug to debug the javascript.. best tool out there)

Then i realised… cross site scripting problems. Basically this means you cant go from one website to another and get data, through the browser. IE and firefox will thing you are trying to be naughty and stop you. There are several work arounds

Iteration 3: Keep the pace by keeping it working. One work around is to send the request not from website a to website b,  but from website a, to website a… which then sends it to website b on the server side and returns the response to the client. I wrote an 8 line c# http server so if you submitted a request to http://localhost/proxy.html?url=, it will proxy the request. That worked fine. So i linked the twitter data with the google maps data and everything worked

Iteration 4: Refactor, refactor . I wanted to get rid of the server side proxy as I wanted it totally client side. Enter this little gem Twitter Undocumented Hacks (!!!!) . The bit i used was the Dynamic script tag.

Let me explain how this works. Its another work around to the cross-site-scripting problem. You dynamically (i.e get javascript, when the page loads, to) write a javascript <script> tag, with a url of 816092.json?callback=statusCallback (statusCallback being the name of a javascript function you’ve already written), this then returns you some data to the fucntion specified, this data is in json format.. you can the do what you please with it. I iterated over it and displayed it on the google map, with pauses.

 subnote: JSON, when dealing in javascript is the weapon of choice, xml is tricky to play with in javascript, its more like string manipluation.

Iteration 5: Polish. Theres a few notations in twitters that people use, one is L:Whereami, e.g. l:canning town, london. So, i wrote some logic in javascript to parse this out, and if its there, display the twiiter as that location on the map, if not, default to the location they put in when they registered on twitter. The google geocoding (turning words and letters into lat/long co-ordinates) does all the hardwork.

Anyways, check it out, as soon as the page loads you’ll be asked for your twitter credentials, type them in and see what you think.

Over the next few weeks ill see how I can jazz it up!


No one has ever become poor by giving – Anne Frank

February 13, 2008


I’ve always admired the quotes of Anne Frank, for several reasons. Firstly, even through translation her brevity and clarity are hard to match in any form of literature I’ve ever read. The quote “I must uphold my ideals, for perhaps the time will come when I shall be able to carry them out“, particularly resonates with me, after all, time is toughest test of all, and Im slowly learning the lesson that Anne conveys here.

Another reason for admiring her writing is the context. Remember that she wrote into a diary, that to all extents should have been destroyed, there was certainly no way she could have know anyone else would read it. This means that much of what she writes is completely untainted by any human emotion, its sincerity is deafening, this is backed further by the line “I soothe my conscience now with the thought that it is better for hard words to be on paper than that Mummy should carry them in her heart.” (In fact she wrote several times in her diary that no-one was ever to read her thoughts.)

Finally, reading some of the quotes you will see that Anne has some amazing qualities, simply astounding when you think of the facts. She says “Despite everything, I believe that people are really good at heart.” . Putting this in the context of Nazi Germany potentially the most evil regime the modern world has ever seen, certainly make me think of the qualities she possessed that I clearly lack.

Anne Frank was a 15 years old when she died of typhus at Belsen concentration camp.