Lifelogging: Private Location Tracking

So, I have started toying with location tracking as one function of a suite of lifelogging tools I’m crafting. I’m not comfortable trusting my location with companies whose business models are tied to collecting and using that information somehow, so rolling my own solution seems like a reasonable idea. Fortunately, the new HTML5 geolocation functionality makes web-based geolocation very, very easy.

My current setup is about 1 day old, so it certainly isn’t perfect (or 100% transparent, another main goal), but it logs my location to a webserver that I control, not one that someone else packages and sells.

It is a two-part solution: part 1 is a Chrome extension that triggers whenever a new page is loaded. Here are the main components of the extension:

// Required
"name": "Lifelogging for Logan",
"version": "0.1",
"manifest_version": 2,
// End Required

// Recommended
“description”: “Periodically logs info to my database.”,
“icons”: {
“16”: “icon16.png”,
“48”: “icon48.png”,
“128”: “icon128.png” },
// Pick one (or none)
“browser_action”: {
“default_icon”: “icon48.png”,
“default_title”: “Lifelogging for Logan”,
“default_popup”: “options.html”},
// Add any of these that you need
“background”: {},
“chrome_url_overrides”: {},
“content_scripts”: [
“matches”: [“http://*/*”],
“js”: [“jquery-1.7.2.js”, “lifelogging.js”]
“content_security_policy”: “script-src ‘self’; object-src ‘self'”,
“file_browser_handlers”: [],
“homepage_url”: “http://YOUR.DOMAIN.COM/”,
“incognito”: “split”,
“intents”: {},
“minimum_chrome_version”: “21.0.1180.79”,
“nacl_modules”: [],
“offline_enabled”: false,
“options_page”: “options.html”,
“permissions”: [
“geolocation”, // to query without user permission each time
“background”, // to let the extension run even if a Chrome window isn’t open
“plugins”: [],
“requirements”: {},
“web_accessible_resources”: [
“sandbox”: []

and lifelogging.js (note the whitespaces to break the commands down from working live.)
$('body').ap pend('>ifr ame s rc="http://YOUR.DOMAIN.COM/chrome-extension-iframe.html" frameborder="0" id="Lifelogging_iFrame"></iframe>');

The plugin inserts and loads chrome-extension-iframe.html, which in turn receives the geolocation data and writes it to your private web database with PHP and MYSQL.


<script src="jquery-1.7.2.js">
<script type="text/javascript"> 
if (navigator.geolocation) { 
//alert("Geolocation permission secured, initiating request."); 
navigator.geolocation.getCurrentPosition( function (position) { 
// success callback 
$.post( "http://YOUR.DOMAIN.COM/geolocate.php" , { 
// post attribute:value pairs list 
my_latitude: position.coords.latitude, 
my_longitude: position.coords.longitude, 
my_accuracy: position.coords.accuracy, 
my_altitude: position.coords.altitude, 
my_altitude_accuracy: position.coords.altitudeAccuracy, 
my_heading: position.coords.heading, 
my_speed: position.coords.speed, 
function( data ) { 
// Callback to process response from URL 
//alert("Response from geolocation server: "+data); 
} ); 
// Did we get the position correctly? 
//alert ("Geolocation allowed, did it work? lat: " + position.coords.latitude); 
// To see everything available in the position.coords array: 
//for (key in position.coords) {alert(key)} }, 
// next function is the error callback function (error) {
 myLatitude = 8; switch(error.code) { 
case error.TIMEOUT: alert ('Geolocation Timeout'); 
case error.POSITION_UNAVAILABLE: alert ('Geolocation Position unavailable'); 
case error.PERMISSION_DENIED: alert ('Geolocation Permission denied'); 
case error.UNKNOWN_ERROR: alert ('Geolocation: Unknown error'); 
} ,{timeout:10000});
} else { 
// Permission not granted to record geodata alert("Refused geolocation permission.");
} </script> 

As you can see, this HTML file gathers the browser’s reported geolocation data and squirts it over to geolocate.php for writing to the database. I’m posting a stripped down version of geolocate.php as it is a security risk to show the whole thing. Needless to say, scrub the input for malicious data:


//insert new record into log
$sql = “INSERT INTO lifelog_table_name (id, userid, event_type, value_1_name, value_1, value_2_name, value_2, value_3_name, value_3, value_4_name, value_4, value_5_name, value_5, value_6_name, value_6, value_7_name, value_7)
VALUES(‘$id’, ‘$userid’, ‘geo’, ‘latitude’, ‘$latitude’, ‘longitude’, ‘$longitude’, ‘accuracy’, ‘$accuracy’, ‘altitude’, ‘$altitude’, ‘altitude accuracy’, ‘$altitude_accuracy’, ‘heading’, ‘$heading’, ‘speed’, ‘$speed’)”;

$query = mysql_query($sql)
or die($_SERVER[‘PHP_SELF’]
. “: Was not able to geolog this event.”
. ” email SONANDSO about it.”
. mysql_error());

There you go! Location tracked every time you load a webpage. It is a good idea to encrypt the geodata before sending it to your server, which I’m not showing here. Think about using tools like blowfish, SHA512, MD5, etc. to protect yourself.

Lifelogging Made Easy: Automated Screenshot Capture and Private Upload Using OSX Automator

Hey You!  If you like this app, write a comment and suggest how it can be improved.

In my quest to become a more effective worker and husband, I have been paying a lot of attention lately to websites like David Allen’s Getting Thing Done (for workflow management), LifeHacker (tips and tricks), and more recently Quantified Self.  The latter is a gathering point for lifelogging enthusiasts.

One primary task of lifelogging is to capture data about oneself and one’s surroundings as:

  • detailed as possible
  • often as possible
  • easily as possible.

The first two are fairly easy for me, with dual backgrounds in physiographic research (trained to make detailed, reliable, repeatable, meaningful statistical measures) and web application development (heck, we can log interesting things as often as we want with cellular, PHP, MySQL, and statistical software like R/SPSS/SAS).  The third– ease of capturing data– is very difficult to get right for a busy guy like me.

This post details my first attempt at automating screenshot capture and saving it to a private online archive.   Continue reading Lifelogging Made Easy: Automated Screenshot Capture and Private Upload Using OSX Automator

Japan Videos

Videos are linked, below.

Near Asakusa, we stumbled into a very cool street performance of Taiko drumming.  It mixes elements of percussion music, martial arts, dance, and a hefty dollop of old fashioned stage presence.

Oh yeah, a few days ago we got to sit in on a kindergarten kid’s taiko lesson.  The cuteness level was over 9000.


In Narita, we got to check out a gion street festival.  The Japanese are very hard workers, but they also have more holidays than we enjoy in the States.  So, they do stuff like haul these shrine-on-a-cart things (“mikoshi”) around and stop for a drink every hour or so.  It all starts out very disciplined and by the end of the day they’re pretty smashed.


Aaaaand one more, from the Tokyo National Museum of Natural History (equivalent to our Smithsonian Institutions in DC).  Wait for it…

Japan Trip Photos

The translations here are pretty wild. Here at Minakami train station, I found “Bourbon Fettucine Gummi” snacks. Delicious…?
In a train station bakery, we found these DELICIOUS red bean paste-filled biscuits. They’re branded with cute pandas. Approved.
It is really odd to see Western things present in Japan, or at least it seems odd to me. Hollywood ad dollars cross the Pacific just fine, though.
In Tokyo, it is apparently pretty difficult to find a landlord that allows pets, and land for your own house would be prohibitively expensive. So, cat lovers can go to “Cat Cafes” where 20 cats are running around. You pay about $12 (1000 yen) for a coffee and one hour to pet the cats.
They’re very particular that you wash your hands, remove your shoes, etc. Can’t have those cats getting sick in close quarters with each other!
There was a young couple on a date together there. Very cute.
Robots (“mecha”) are one of many popular themes in Japanese entertainment for the younger crowd. Logan approves.
Apparently Hayashi is a fairly common name in Japan. We’ve met several so far… Everyone here is extremely polite. It comes off as a cross between southern hospitality and English formality.
The rooms are tiny here! Ceilings tend to be lower, doors narrower, portion sizes are more sane. The toilets are completely wild. Think robotic controls.
Another Hayashi! This one a politician.
In many of the soup/noodle (“soba”) shops, you order by buying tickets from a vending machine that specifies the selection and prices. You take the ticket to the short order cook who hollers things–very politely– then you have a seat and wait.
Silly, always silly.
Flying business class for 13 hour trips is a very, very good idea. Half the price of first class with 90% of the amenity. Free noise-canceling headphones (ours were Bose, amazing).

Japan Trip 2012 – Fox Canyon Photos and Videos

Hello family and friends! A few photos and videos of our trip so far–

Canyoning [Canyoneering] in Fox Canyon, Minakami, Japan.

Click photos for full-size version, click text links for videos…

This is about as tame as canyoneering gets…


Logan superman slides like an otter into a whitewater pool

Aya jumps into whitewater pool

Emi jumps

Logan and Emi hug in Fox canyon
She is one pretty lady, in a wetsuit or in a sun dress!

into a whitewater pool

Everyone still alive after superman slide

Aya jumps 6m into whitewater

Emi jumps 6m into whitewater

Logan jumps 6m into whitewater

Logan jumps backwards into canyon

Emi and Aya jump into a cool canyon pool

Aya musters her courage and plunges into whitewater

Emi drops backwards into swirling canyon pool

Logan forward flips into canyon pool