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. Its 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 this 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 its 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 on isn’t very interesting in my opinion but combined with AppScript and 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!

Kevin Hughes's Picture

About Kevin Hughes

Kevin is a Developer @Shopify, Ultimate Player, and Traveller

Ottawa, Canada