August 28, 2007

Global Positioning


Since I don't have a car in Taiwan I didn't really have any need for the fancy PDA+GPS combos with the fancy screen and full route-finding functionality. I was intrigued by the concept of geotagging photos with location data, though. I tried adding location data to my Flickr photos by hand via TripperMap in conjunction with Google Earth. But that's not practical to do for all my photos, and even just doing the Flickr uploads was becoming tedious.

A quick search found that a basic bluetooth/USB capable GPS receiver had fallen well below $100, well into impulse-purchase territory. Had to go to Germany on short notice, so I picked up a little GPS receiver unit with built-in trail-recording function just in time for the trip.

The setup consisted of Mobile Trail Explorer running on my SE W810i phone, connected via bluetooth to the Wintec WBT-201 G-Rays2 GPS receiver. The WBT-201 has built-in memory to record track data, but the Java program on the phone has a nicer interface. Took the picture of the GPS readout to synchronize the clocks between the GPS and the camera.

Directly download the tracks from the phone via Bluetooth file transfer, or grab it from the WBT using HoudahGPS. Put the GPS data into the photos with GPS Photo Linker.

Thankfully the new iPhoto 7.0 in iLife '08 finally fixed GPS data handling so editing the photo won't screw up the coordinates in the edited file. And Flickr can directly read the EXIF geotags to place them on the map, which can be exported as a GeoRSS or KML feed to be read in Google Maps or Google Earth.

Posted by mikewang on 08:40 AM

August 19, 2007

Flickr Counting

Vanity is necessarily involved in uploading photos to a publicly viewable site, and Flickr indulges that vanity by keeping count of views, favorites, and even compute some artificial version of your pictures' Interestingness. For the hot chicks, it's easy to draw tons of admirers to your online photo albums. Not so much when it's just me and my random snaps and vacation shots with the SO (although she's drawn some attention, too).

Nevertheless, through the accumulation of family members' cursory interest, strangers' random clicks, and persistent whoring out pictures to Flickr Groups, I've managed to build up some respectable numbers of photo views. Flickr tells you a total number of Views on the front page, but that's only the views of the Photostream page itself, not counting views coming from other click-throughs like blog links or group photo-pools. So there's no single stat summing up all the actual views of the pictures themselves.

Now, being one of the pioneers of so-called Web 2.0, Flickr offers a complete array of programming APIs for any competent programmer to access stats, photos, etc. via SOAP, XML-RPC, JSON, using whatever programming language or web-app one may desire. Note the qualification of "competent" and "programmer" of which I am neither. I have done my share of data-munging back in the day, though. So it was old-school, brute-force, screen-scraping action for me.

  1. Use curl to download all the photo thumbnail pages, from 1 to however many (28 so far). Use the -b option and borrowing the cookies file from Camino/Firefox for login in order to make the photo views' stat visible on the page.

    curl -O -b cookies.txt "http://www.flickr.com/photos/myusername/page[1-28]"

  2. Filter out the actual number of views for each picture with

    grep -h "</b> views" page* | egrep -o "[0-9]+" > views.txt

  3. Actually add up the big list of numbers in views.txt and output totals and averages, using awk. The actual program is trivial and left as an exercise for the reader. Folks with a clue may use perl and real men can use Python or whatever, but really awk is all you need.

No need to tell me what a pathetically unstable and inelegant hack the above method is.The script took less a minute to run and got the job done. Averaging 24.15 views per photo for 504 pictures as of today. Sweet.

Posted by mikewang on 08:12 PM

August 15, 2007

Mathematical Certainty

It isn't often that facts regarding male-female relationships can be reduced to a concrete mathematical proof. Kudos to the NYT to bringing up one such example.

In study after study and in country after country, men report more, often many more, sexual partners than women...

But there is just one problem, mathematicians say. It is logically impossible for heterosexual men to have more partners on average than heterosexual women. Those survey results cannot be correct.

Duh. I've been as culturally brainwashed as the rest of the sheep and took male promiscuity for granted. All those guys have gotta be boinking somebody so the total number of partners must be equal for both sides.

So in the end, the only conclusion one can really derive from such surveys is that men brag more about sexual promiscuity and women tend to hide it. Which drags us back to the sociological quagmire of cultural uncertainty. Who knew the reflexive theorem could get so complicated?

Posted by mikewang on 06:15 PM

August 01, 2007

Bill Walsh, RIP

Sad to see the great coach passed away after a long illness with leukemia. He and his 49ers teams made me an American sports fan. As the Niners juggernaut rolled through the '84 season on the way to crushing the Dolphins in the SuperBowl I was drawn into the strange American game. Borrowed a couple of books from the library to learn the rules and after that it was every given Sunday. The man was The Genius not just on the field or in the playbook, but also with his work to bring in minority coaches. Besides, how many other football coaches would be qualified for a Stanford teaching gig?

And by the way, Ingmar Bergman also died recently. Also an artistic genius, but there's no emotional attachment there. Shows you where I lie on the culture-vulture scale, I guess.

Posted by mikewang on 02:42 PM