Sabbatical Progress Sept. 14th

Today’s project is to extend my understanding of classes, methods, constructors, and inheritance by creating a new class based on aggregating, sequencing, and then parsing properties of a variable-length set of input classes.

This would be very analogous to establishing a Minecraft-style crafting system where sets of ingredients conditionally determine the crafting output’s characteristics (properties) and quantities (instances count).

Also, worked over the weekend to get to this point.

Sabbatical Progress Sept 10th

Today I jump into event listeners and callback functions to make a UI responsive to user inputs. Last night’s processing of Social Security Administration datafiles into workable data tables (about 2.5 million records) went very well, although it did overwhelm Excel completely. Will switch to line-by-line parsing in PHP or similar as that has no practical limit on datafile size.

Sabbatical Progress Sept. 9th

Continued learning about recursive programming (OO and functional styles) with extending yesterday’s hierarchical model of the universe with procedural name generation by entity type. For example, planets are named according to specific rules and the outputs should look credible and distinct from how we name people on those planets.

Sabbatical progress Sept. 3rd

Today I began teaching myself proper ways to hook the MVC (Model View Controller) paradigm parts together. Previous days’ work on the model portion (classes, data structures, methods, etc. in pure Javascript) started getting tied meaningfully into a user interface/frontend driven by jQuery’s powerful libraries. Very satisfying stuff knowing that the mechanics ‘under the hood’ are working cleanly and as they should, not cobbled-together. Today was the first day were I really got a sense of that old saying ‘code is poetry.’

Sabbatical progress Aug. 25th

Today’s goal: work from here to there mindfully and with a close eye for insight.

Streak: 1 day


  • regexes in Javascript have their own methods. Brilliant and handy for debugging purposes.
  • Javascript hoists (moves them to the top of the scope) declarations but not assignments. I can see that causing bugs in various places…

Accomplished: began coding an object-oriented discrete event stochastic simulation in JavaScript to shift into the good habit of OOP for the first time. Not an easy transition.

Other goal: turn in receipts to Laura.

Sabbatical Progress Aug. 24th

Today was the first official day of progress on my Fall semester sabbatical. Unofficially, I started in on my plans late in the summer after finishing teaching summer camp and an online course.

My primary goal for the sabbatical is to sharpen the spearpoint on my cobbled-together-over-the-years scripting/coding/programming/automation skills. Until now, I’ve dabbled in HTML, CSS, PHP, MySQL, LSL, Javascript, Python, VBasic (haha), bash scripting, and C#. Today I now have the time and space to unlearn my bad coding habits and hammer in smarter ones. I know that only NASA writes perfect code. But, *any* code is better than the almost completely analog skills I and my peers use for our research.

Today’s goal: the What
Today’s task was to read through W3Schools course content on Javascript from here to here with a close eye for detail and correctness.

The Why
I chose javascript on purpose as a non-heavy lifter language so that I’d learn best practices without focusing on the quirks of any particular language.

The How
Went through start to finish. Worked the simple little interactive exercises. Pleased to find I actually found a few new-to-me things. Mostly the data and time handling, but that’ll be pretty handy on simulation modeling.

Then I skipped ahead and delved into HTML5 multithreading (web workers) and built a simple little dynamic stochastic discrete event simulation model replicating a game scenario running in my browser. It worked beautifully multithreading up to 4 threads, managing their spawning, and running simple monovariate statistics on their results across a thousand model runs. In the Real World, I’ll use a more science-appropriate language like Python and its endless handy extensions like SciPy and NumPy.

Tomorrow I’ll go back and work properly through JS arrays and objects. I can already see they’re going to be incredibly useful when used properly instead of the shoehorning I’ve done so far.

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