I’ve recently started doing something that I’ve coined ‘LifeOps’. LifeOps is all about measuring, quantifying, tracking and alerting for things in my life. It’s my take on personal experimentation and improvement and what makes it different is the degree of software and automation involved.

I think the easiest way to explain LifeOps is with some concrete examples the first of which is fitness related. There are a lot of ways to measure fitness most of which are quite manual (recording lifts etc.) I’ve used a few different methods in the past but I always keep coming back to my weight as a sanity check. For me I know my fitness/health is starting to slip if I’m losing weight (I realize this is opposite of most people) so I decided to do something about it. I didn’t even own a home scale before so I went and purchased a FitBit Aria with a plan in mind.

I setup my Aria scale and then added a recipe to IFTTT to sync my weight and BMI data to a Google Spreadsheet. Here is where the Ops comes in. I wrote the following scripts to track and alert based on my data:

No Data Alert:

  function alertNoData() {
    var lastEntry = getLastEntry();
    var rawDateStr = lastEntry[0];
    var dateStr = rawDateStr
      .replace(' at', '')
      .replace('AM', ' AM')
      .replace('PM', ' PM');

    var date = new Date(dateStr);
    var today = new Date();
    var diff = dateDiff(date, today);
    var threshold = 2;

    if(diff > threshold) {
      var message = "Last entry was made on: " + rawDateStr
      MailApp.sendEmail(alertEmail, '[Alert][Weight Logs] - No Data', message);

Negative Trend Alert:

  function alertTrend() {
    var n = 8;
    var weights = getLastNWeights(n);

    var X = range(1, n);
    var Y = [];

    for(i=0; i < weights.length; ++i) {
      Y.push( weights[i][0] );

    var ret = {};
    var f = leastSquares(X, Y, true, ret);
    var slope = ret.m;

    if(slope < 0) {
      message = "Weights: " + Y.join(', ');
      MailApp.sendEmail(alertEmail, '[Alert][Weight Logs] - Negative Trend', message);

Both these scripts run daily using triggers (essentially cron tasks). The results are pretty cool - I get an alert if my weight starts to trend negatively and I can make adjustments to stay on course. Weight is usually a pretty poor metric of health/fitness but I think with this setup the quantity of data will make up for the quality.

The next LifeOps script I made uses IFTTT to log connections and disconnections from my work WiFi network to another Google Spreadsheet. At the end of the week I rollup all the rows to count how many hours I spent at the office. Again - time spent at work isn’t a great metric but with this setup it’s so easy to measure I figured why not?

  function rollupToWeek() {
    var entries = getEntries();

    var week = parseDate(entries[0][1]).getWeek()

    // assumes:
    // a) the first row is always a 'connected to'
    // b) the rows always alternate from 'connected_to' to 'disconnected_from'
    var time = 0;
    for(i=0; i < entries.length; i+=2 ) {
      var inTime = parseTime( entries[i][1] );
      var outTime = parseTime( entries[i+1][1] );
      time += outTime - inTime;

    var hours = time / (3600 * 1000)

    // save the rolled up data
    var sheet = SpreadsheetApp.openById('...').getSheetByName('WorkHours');
    sheet.appendRow([week, hours]);

    // clear raw data
    var sheet = SpreadsheetApp.openById('...').getSheetByName('Sheet1');

    // email results
    message = hours + " spent at the office this past week. Remember to clear the spreadsheet manually for next week";
    MailApp.sendEmail("", '[Report][Work Hours]', message);

I’m excited to keep expanding on what I do with LifeOps. I’ve found this combo of IFTTT and Google AppScript to be quite powerful. IFTTT on its own isn’t very interesting in my opinion but combined with AppScript you can do some cool things. I’ve really come to re-accept Spreadsheets and AppScript as a great solution for small problems (the software engineer in me is always a bit wary of spreadsheets). Got any cool LifeOps of your own? Let me know about them in the comments!

read more

The Average That 70's Show

tl;dr I averaged every episode of That 70’s Show into a single video

A couple of weeks ago I was hanging out with my buddy and we were going to watch some TV. I was making a pitch for my new favorite show Rick & Morty which we couldn’t find using the PS3 internet browser. We did however find excellent video syncing Rick and Morty clips with Eminem’s Rap God.

One good YouTube find is never enough though so as soon as the video finished we eagerly checked the user’s other videos and thats when we stumbled upon this gem:

After watching a bit too much of ‘Every episode of Friends simultaneously’ I went looking for two things of which I found neither. Maybe I live in too much of a software bubble but I was genuinely surprised when I couldn’t find a link to the code used to make the video. I was equally surprised that this was the only video of its kind that I could find.

And thats how this project got started - I set out to create a script that would let me average all the episodes of any show into a new video. I wrote a script in python and opencv to do the work and then I picked That 70’s Show as my first test (I would have preferred Seinfeld but I don’t have it). That 70’s Show is a pretty good candidate - my main hypothesis at was shows that re-use the same locations a lot will be more interesting.

I am pretty pleased with the results! It’s pretty fun to watch and you can definitely pick out distinct patterns in how they frame shots and recognize scenes like the car from the opening credits (at ~2 minutes in). If I’d ever taken a course in film I’m sure I’d have something more intelligent things to say.

I also made this video where I ramp up to the average adding a new episode every 30 frames or around 1 second. So for the first second you’re only watching 1 episode then 2, 3 etc:

read more

ENJEsight Interview

A couple of weeks ago I got an exciting email from an old colleague Dima who is starting a new online venture to provide insights and inspiration to young engineers - he wanted to interview me about my career as a source of inspiration for others! bit of a wow moment for me really. Of course I agreed and a couple weeks later I was interviewed on skype for the first episode of the podcast. I think it went really well and I was really impressed how prepared Dima was for the interview. You can give it a listen here:


He also posted a couple of my quotes directly to twitter! Pretty cool:


read more