Archive for the ‘Ideas’ Category

Converting IP addresses to lat / lng and plotting them on a map with php / ajax

Monday, August 30th, 2010

I love google analytics but the data is quite “slow” meaning you can not get real time updates, so I decided to set up my own tracking service for the sites I maintain. But I did not want to just keep track of my visitors I also wanted to see where the come from.

The setup / What you need

A map – Its important to know that you have to use a mercator projection – otherwise the latitude and longitude do not convert correctly to x and y values on the map

A copy of the free GEO Ip database – there are two versions, an Apache module and a CSV version. I used the csv one and imported it into a sql database note:The sql version is much slower, but easier to set up.

How to use the GEO IP Database

Setting up the GEO IP database

I used sqlpro alongside this guide to import the csv file in a sql database. This is pretty straight forward.

Converting an IP address to lat / lng

function ip_to_lat_lng($ip){

$sql="SELECT * FROM geo_locations WHERE locId = (SELECT location_id FROM geo_blocks WHERE INET_ATON('".$ip."') BETWEEN ip_start AND ip_end)";

$result= mysql_query($sql) or die(mysql_error());

return mysql_fetch_object($result);


this sql statement takes an IP adress and returns a php object which has a latitude and longitude property

Mapping lat / lng to x and y on a 2D map

so not that we have our lat and long we need to map the on the 2d coordinate system on our map.

This is wrong:


This is right:

function lat_to_y(lat){return 180/Math.PI * Math.log(Math.tan(Math.PI/4+lat*(Math.PI/180)/2));}

shift_x= 0 // depending on your map, you might have to move the entire projection a bit
x=map_width/2+map_width/360*lng +shift_x

Its important to account for the distortion from projecting a spherical map on a 2d flat surface. The function lat_to_y takes care of that. If you are interested in the math behind it take a look at this wikipedia article.

Red & Blue

Friday, August 14th, 2009

little actionscript experiment I did during a break.

download the code: Red-Blue

Philips USB rechargeable Power Pack – SCE4420

Thursday, May 28th, 2009


Update 28.6.2009: I just got my iPhone 3GS and Iplugged it in and nothing happend. It appears that apple changed something on the power management so the iPhone 3GS can not be charged with it. Crap!

Today I received my external USB Power pack from Amzon. I got it because my phones battery is crap and the iPod Touch does not get through a day of wifi and gaming either. I am currently charging it for the first time so I can not report on the devices performance, but I read in reviews that it is capable of completely recharging an iPhone up to 2 times. The charging it self takes a qutie while. I have it hooked up to my computer for about 4 hours now and it is still not done, but I guess that this kind of charging will increase the overall lifetime of the battery inside. I find this kind of powerpack more convenient that the ones specifically made for the iphone and Ipod Touch since I can charge every gadget that takes power via usb and most other cellphones as well.


  • small form factor
  • looks quite nice – I generally like the appearance of philips products
  • low price 24? at amazon, the kensington one costs about 40?
  • comes with a ton of adapters ( Nokia,Samsung, Motorola, Nintendo DS, Sony Ericsson,Blackberry and mini USB)
  • has 2 ports, one for charging the device and one standard USB jack to plug in your gadgets
  • is advertised with 30 hours of battery life( I will test that and post)
  • Retractable cable, no additional cable clutter !!!!
  • for simple LEDs indicate the level of charge
  • comes with a small black cloth bag to keep verything together


  • charging takes quite some time
  • nothing else really

Update 3.6.2009 – Battery performance

the battery works really well. I was able to charge my ipod touch 2 times with one charge. I could charge my girlfriends ipod nano without even noticing a decline in charge.

Actionscript 3 3D with Flash CS4

Wednesday, November 26th, 2008

I finally got a copy of adobe flash cs4. In addition to the great new user interface flash cs4 can compile flashplayer 10 content which enables the new actionscript 3 3D methods. with only the three simply rotationX, rotationY and rotationZ properties one can quickly create really nice 3D animations. This is my first test.

here are the few lines of code it took to make this thing spin:

import flash.display.*
 import flash.geom.*
 import flash.display.*
 var panes:MovieClip=new MovieClip()

for(var i:Number=0;i<18;i++){
 var pane:MovieClip=new MovieClip(),0xffffff,0.5),0.3),0,100,100)





function movePanes(e:Event){

Choosing a mass data storage solution for a mac household

Sunday, October 12th, 2008

I am replacing my old server / htpc with a mac mini – hopefully with a new model if they appear on 14.10.2008.

I am looking for a external mass data storage solution that offers me at least two terabytes of storage distributed among 2 or more drives in order to achieve a secure and redundant storage capacity of 1 terabyte without data loss in case of the inevitable hard disc failure.

I am looking for he following features – ordered by importance

1. Security through redundancy. I want to have all my data stored twice on two separate drives. Raid or regular back up software are both fine. I do not want to pay for backup software, there is enough free software to get the job done. It has to be automatic.

2. Noise – the system will be in my living room and I don’t want loud fans without running the risk of overheating. This is one of the main reasons I am dumpping my current pc.

3. Power management – I want the system to have some sort of idle state where the discs spin down on order to cut noise an usage of the discs. This should be automatic. I do not want to turn the drives of manually.

4. Accessability through out the entire network and over the internet – FTP is a big plus. I have a gigabit lan airport extreme base station and the mac mini that will always be on plus I also consider NAS an option.

5. replacability and expand ability. In case of a broken drive I want to be able to buy a new drive in a local compute store in install it. Even more important is that even though 1 terabyte is an insane amount of storage the day might come soon where I want to add more storage to the system without having to repurchase the entire setup.

6. Warranty - it should have decent warranty on the drives from the manufacturer.

8. Speed – I did a lot of reading and I think for my purposes of backup and media storage / streaming USB 2.0 and faster are good enough. FireWire would be nice since I have macs.

Things that ate not important.

1. Design – I can hide it all in a tv table so it does not have to be pretty.

2 .Many connectivity options – the system should be connected to my network only at one point – AEBS ,mac mini or via Ethernet.

3. right now I have two fairly new 500 gb SATA hard drives I would like to reuse but it’s not a must. I am willing to drop cash on new terabyte drives.

Most importantly the pricepoint. I figure I can get the 2 terabyte drives + enclosures for arround 350 euros which is about what I want to spend. But since this should be a longterm investment I could be convinced to spend a bit more.

These are the options I have in mind right now.

1. Buying two terabyte drives and putting them in decent enclosures, although I would not know which enclosures, and just hooking them up to the mini on 2 usb ports. –>probably the cheapest and can easily upgraded but problemantic in terms of noise and power management.

2. Getting a two bay raid enabled enclosure like the LaCie Big Disk Extreme+ Dual –> quite expensive – but excellent quality and feature rich. Are there cheaper options?
3. Getting a nas device like the dlink DNS 323. since I actually already have a mac mini always running or the airport extreme basestation I am not sure if its a good idea to bring in another stand alone device.

Please tell me what you suggest and about solutions you use for your self.

windows vista – my experience

Friday, August 22nd, 2008

since my laptop broke down i had to use one of my dads computers which happens to run windows vista. at first I thought about just wiping the drive and put on windows xp right away, but I gave it a shot and I must say I am quite surprised.

Internet connection:

i took the computer to my room pluged it in and there was no internet connection. grr, but i turned out that there was just an old configuration still in place and it took two mouse clicks to geht this machine online. so bassically not more difficult than on my mac.


vista is crazy about permissions, and so it took me quite a while to figure out how to share a folder on another computer in order to copy some stuff to this computer. In windows defense I must say that I had file permission problems as well when sharing files between my girlfriends mac and my own.

installing software:

no problems there. just downloaded the couple of programs that I use and after one hour i was ready to contiune working on the same website i was working on my macbook pro befor it crashed. if could even install xampp without any trouble

the notoriouse cancle or allow question:

well it comes up once in a while but stays within acceptable

mozconcept – file management in online applications

Monday, August 11th, 2008

More and more web 2.0 applications reach a level of sophistication usually only found in native desktop apps. One of the biggest topics right now is cloud computing and cloud storage. So I got my docs in google docs and I got my pictures in flickr and so on. Many apps by now already offer the possibility to import files from your local computer and some even are capable of taking stuff from other 2.0 web apps. The problem with this development is that each web app offers an API to make use of the data stored with the service. Now that would mean that every web app that wants to allow the user to user data from other web apps would have to implement all the APIs of each of those web apps. It is obvious that this will lead to chaos, poor connectivity and poor performance.

each line represents a API connection between a web service

each line represents a API connection between a web service

A possible solution:

The next generation browser becomes a hub for all this data APIs. The APIs are implemented within the browser and the browser can then provide the data to web apps as if they were either stored locally or via a unified API. Lets take the simple example of pictures. I have a picasaweb account with google and a flickr account. boot use the same type of data – Image Data – but they are not compatible. both flickr und picasa offer the ability to upload local files. If the browser knows this as well he could then take the picture from my picasa account using the given API and then present it to the flickr account as if it was a local file. This is the most simple implementation of this idea.

The dream would be that all Web apps offer an API that fulfills predefined standards for different types of data. If I then have a webapp like google docs or this wordpress blog and I am asked to upload a picture I do not only get to browse my local pictures but also all the pictures from all of my webservices like google and flickr.

each webservice my use their own API for sending data but will recieve data from the browser if it were local

each webservice may use their own API for sending data but will receive data from the browser if it were local

advantages of this concept:

  • so all the APIs only need to be implemented once in the browser and not by every webserice
  • future APIs can be built directly to this framework which will increase connectivity even more
  • the cloud becomes real as it really does not matter any more where the data is stored

Actionscript 3 visual experiment

Thursday, March 6th, 2008

 I am currently moving from AS2 to AS3. This animation was one of the results while playing around with AS3



Simple Flash Actionscript 2 XML Navigation Concept

Saturday, January 26th, 2008


This is a small navigation concept I did using Flash and XML. Its about a hundred lines of code but shows really well how easy it is to use xml data in flash. The code is free to download.

Download: Fla


My imagniary all in one gadget

Monday, January 14th, 2008

General thoughts

Having watched hours of CES 2008 coverage without being really thrilled about any of the products I have seen, I want to make up a piece of tech that would actually get me excited to buy it. So lets start off by looking at the stuff I already have. I currently carry a mp3 player (ipod G5 30GB), a cellphone (Nokia E65) and a digital camera (Canon IXUS 40). These three devices together have pretty much all the features one may ask for, but one without the other is simply not enough. My intention is to come up with a list of features that, if combined in one device would make me buy it, and most importantly then not think about any compromise I hade to make by choosing the device over another. Anyhow everything written after this line is just my wild imagination and I am sure I have not though about every aspect.


The OS that is running the device should finally start to behave like an OS. A basic platform that offers and open API for software to use the gadgets features and then stop. It does not need to do anything more really. For everything else I want to have an application that is running as an application and is not deeply stuck within the OS. So for example contacts: I am a mac user I will have a Adressbook mini app that’s running on my device and then sync with my mac. If I have a pc, want a app that is designed to work with outlook. Anyhow I want to choose like on my laptop which software I use to perform a certain task. Hearing my self write it kind of sounds like android from Google. Well we haven’t really seen much of it yet but maybe it will make my wish come true.

User Interface

I believe there is no way but using a touchscreen. I wrote above I want many different programs to work for me, but that means a basically different UI for every single app, which would probably result in the worst user experience every with exception of my first cellphone. So one more thing the OS should to is to provide a set of UI elements to be used in the programs. I am thinking about the component library from Flash. Those are not the best UI elements out there but they would allow a cohesive User experience, that can then be customized with themes.

Filemanagement & Memory

I want this device to have one piece of storage that will be used by all apps and that is accesable by all apps using a file management application of my choice. So If a want to attach a picture I just took to an email, the email app calls the file app to show up and let me select a file, without browsing in some proprietary gallery that is different for each filetype.

Browsing & Mobile Office 

It need a  web browsing app – the safari on the iphone is the best thing I have seen so far but since the system is open anyone can come up with a better app. As for the mobile office stuff I guess these apps already exist, so I only have to download them to my device which brings me to my next point.

Carrier provided Content and apps

My cellphones are packed with stuff from you carrier. For the most part these are just as annoying as the ones you get your PC with, when you buy a new one. If the carrier offers special services they should have them as web services I can access using the browser app, if I would like to do so.  

Music playback:

Being a mac user I am a big fan of the Ipod + Itunes concept with only one point of criticism and that is DRM. Like I said above I want this to be done by certain apps, so I could imagine a little mini itunes(never gonna happen since apple wont let their superglued couple be torn apart) that does all my media and then syncs with my mac. Many people dont like itunes, so they should be able to use a different app. But both apps share the resources of the devices audio capabilities

Video playback:

I want a big screen( touch screen, but I will talk about that when it comes to user interface). Today I got to play with an ipod touch of a friend of mine and found this screen to be perfect. Its big enough to watch video but its not as big as other PMPs or mini Pcs that make it impossible to fit this device into your pocket. My ipod offers only limited support for video playback since I have to import and convert everything into itunes in order to view it on my ipod. Like I said for the music, its got to be open AND that would also mean for Itunes to support more video file types.


  • Taking Pictures: In order to get a decent picture taken you neet two things, a camera with more than 3 megapixels and a lightsource(flash). Many mobile devices still don’t offer 3 megapixels, and most of them perform very poorly in the dark. But looking at the Nokia N95, the new LG viewety or some sony-ericsson cybershot phones we see that it is possible to pack all this tech into a small gadget.
  • Viewing Pictures: This is not a very hard task. I am personally satisfied with my ipods picture viewer, and looking at the ipod touch I think there is not that much potential for innovation. Of course as this little gadgets become more and more powerfull computers photo editing is an issue. But personally I never felt the need for editing a picture right on my cellphone or camera. The screen is to small anyways.
  • Managing Pictures: In my eyes the most crucial factor. I just recently switched from simply folder storage to Iphoto which I think is also great solution but only works for the few people that own a mac. So in order for the device to be really good it should behave like a simple digital camera, that mounts as a drive, and would therefor be usable across all platforms. Most of the software that comes with these cameras and cellphones is really bad and I don’t see why companies insist on creating software if their strength really is to build electronic devices.


Well I guess its pretty simple on this one. GSM,GPRS,UMTS,HSDPA,WiFi,Bluetooth,USB, IRD … did I miss one? 


I developed my ideas more or less while writing the text and the further I got the more I realized I described a personal computer or tablet pc with the size of an Ipod. And thats what it should be. Give me a small computer that is simply not as powerful as my mac but fits in my pocket and does everything a pc does just on a smaller scale. I dont want a walkman phone or a nokia busniess phone with a crapy camera. Make it a small computer that can do calls, sms, mms and data with a decent camera, and by installing certain apps I decide what it exactly is.