Christian Heilmann

Author Archive

Building quick web applications by using YQL and YUI as building blocks

Thursday, February 4th, 2010

This is a talk I gave two days ago in the Sunnyvale office of Yahoo explaining how I built some of the sites you might have seen like Keywordfinder, GeoMaker, GooHooBi or UK House Prices.

There is actually no magic to it – I am not a superhuman developer. The main trick to build products like that really fast is to use building blocks that work, separate concerns of the application (APIs for the backend returning HTML, JavaScript for behaviour and Ajax and CSS for look and feel).

Without further ado, here is the slide deck for you to go through:

The audio recording

The audio of the talk is available on archive.org

The preview in the slides

One new demo I built for the talk was Flickr Collector which allows you to quickly collect photos from flickr and get the source code for them easily add them to blog posts and articles.

Flickr collector by  you.

The source codes

The talk was filmed and will be available on the YUI Theater soon.

Adding map links and a small map to any text using JavaScript – addmap.js

Friday, January 29th, 2010

As part of a larger article, I am currently building some tools that use geographical information. The first one is a pure JavaScript solution to link locations in a text to Google Maps and to show a small map under the text. You can see it in action by clicking the screenshot below.

Analyse text and add a map with its locations in pure JavaScript by  you.

All you need to do to use the script is get your own Google Maps key and embed the script in the page you want to analyse, giving it the ID of the main text element as a parameter:


You can customise the look and feel by writing your own CSS for the generated HTML and setting the addmap.config.width and addmap.config.height properties to resize the map.

Under the hood here is what happens:

The code of addmap.js is available on GitHub.

TTMMHTM: Book pirates, Cabinet Office, Socks of Win and browser stats

Wednesday, January 27th, 2010

TTMMHTM: Meaning of love, Windows 3.11, geeky decor and my dates in the valley so far

Monday, January 25th, 2010

Things that made me happy this morning:

Finding the current location by IP and with the W3C Geo API

Monday, January 25th, 2010

I was always fascinated by those ads that show you “hot contacts in {city}” not because of the hot contacts, but because they always changed to where I was at the time.

I was also quite interested in the fact that they were always a bit off (again, the city, not the contacts). As I like to find things out, here’s a demo of just how far the location of these ads can be off:

The difference between IP location and Geo location by  you.

You can see your results by visiting the demo page and allowing it to get your location if you use a browser that supports the W3C geo location API.

Here’s how this works:

You can guess the location of a user by their IP and Rasmus Lerdorf wrote a nice API to do that at http://geoip.pidgets.com/. Using that, you can read the IP in PHP and call the API with cURL:

if ($_SERVER['HTTP_X_FORWARD_FOR']) {
$ip = $_SERVER['HTTP_X_FORWARD_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$url = 'http://geoip.pidgets.com/?ip='.$ip.'&format=json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$data = json_decode($output);
$lat = $data->latitude;
$lon = $data->longitude;

This API is only a wrapper for the Maxmind API and for some reason rounds the latitude and longitude from time to time. You can get more accurate results using the Javascript Web Service of Maxmind directly:


The most detailed data can be obtained with the W3C Geo API though:

if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(position){
var lat = position.coords.latitude;
var lon = position.coords.longitude
});
}

And that is all there is to it :)