Tag: code

2013 with Fitbits

2013 is near its end and it’s time to see what happened during the last 360 days or so. Many things happened (graduated from MBA, new house, holidays, ill a few days, …) but I wanted to know if one could quantify these changes and how these changes would impact my daily physical activity.

For that purpose I bought a Fitbit One in March 2013. I chose Fitbit over other devices available because of the price (99 USD at the time) and because it was available in Europe (via a Dutch vendor). At that time the Jawbone Up was unavailable (even in the USA) and the Nike Fuelband couldn’t track my sleep.

Basically the One is a pedometer (it tracks the number of steps you make per day) but also the number of floors climbed and the time asleep. Note you have to tell your device when you go to sleep and when you wake up ; it will substract automatically the times you were awake. The rest of the data presented are taken from these few observed variables: distance traveled, calories burnt, … The Fitbit website also categorizes your activity from ‘sedentary’ to ‘very active’.

Of course there is an app (for both iOS and Android) where you can also enter what you eat (it automatically calculate the number of calories ingested) and your weight (unless you buy a wifi scale from them). You can set goals on the website and then it tells you how many steps you have to make per day. All this data is stored on a Fitbit server and you can access it via your personal dashboard (yes your data is kept away from you but there are ways to get it …).

Fitbit dashboard beta

I liked the Fitbit One mainly because it is easy to use: you take it and forget it, it works in the pocket. There is a nice, easy to use web interface – great for immediate consumption (not really for long trend analysis). It is quite cheap to acquire the device (well, it is quite small anyway). It works with desktop software as well as mobile app (incl. synchronisation). The One can easily be forgot in a pocket (gives peace of mind) but it doesn’t work when you don’t have pockets (shower, pyjama, changing clothes, … ; I didn’t use the clip/holder at the waist).

That leads me to its disadvantages …

  • First it’s a proprietary system: you need to pay 50USD in order to get the data you generate, to get your data. Although it makes perfect sense from a business perspective, the device then costs 150USD (and not only 99USD for acquisition alone).
  • Then it also uses a proprietary interface to charge the device. This is problematic when you move house (the cable is somewhere in a box) or simply when the cable is lost (see messages on Twitter asking for such cable when lost). Most mobile phone manufacturers understood that and provide regular USB interface (for charging and syncing btw). I guess the small form factor has a price to pay.
  • Tracking of other activities than movement is tedious, especially the need for an internet connection in order to enter food eaten in the app (but otherwise that’s the drawback of logging: auto-vs-manual in general).
  • Then tracking is sometimes not practical. e.g. between wake up and dressed up or shower. So is there always some under-reporting? Probably there is as I don’t wear it when changing or in pyjama (no pocket). Of course the One comes with an armband-holder but I guess it records data differently.

But the last and main disadvantage that comes to my mind is linked with its advantage: it is so easy to use and to forget (in the washing machine), it can fall and you won’t notice it.

So of course I lost it. It was in a business trip in South-East Asia. I thought I put it in my suitcase when changing pants but I couldn’t find it anymore. So after a few hesitations I chose to get a Fitbit Flex.

Fitbit Flex with charger and armband

The Flex comes in another format: it’s like a small pill that you put in a plastic armband-holder. Therefore it is closer to the body (but not legs, to count steps) and therefore you don’t need pockets. However it doesn’t give time (if you have a watch you’ll have 2 devices at your left wrist? Fitbit now sell an evolution of the Flex – the Force – with LEDs displaying time a.o.). As it is always in its armband I feel it is less likely to be forgotten. And you don’t need pockets, it’s like a bracelet you receive at some concerts. The battery autonomy is approximately the same: around 7 days. You can read here another comparison of the two.

So, what about 2013?

In order to dig the past I could:

  1. use the Fitbit dashboard (see first picture of this post) and visually track what I did, making screenshots as I want to keep some results offline ;
  2. shelve 50USD for the Premium reports that can be downloaded and use whatever software to look at the data – note that you get more than just reports for that ;
  3. use the Fitbit API and figure out how to get my data out it.

Of course I chose the third option. It is a bit more complicated but helped with one of Ben Sidders’post I started coding my “app” in R, the statistical language. As there is a bit more than Ben is explaining I posted all my code on the Github repository of my app, jepsfitbitapp.

The first thing I wanted to see is the most obvious one: my steps. As you can see in the figure below I started to collect data in March 2013 (with the One), I stopped collecting data around October 2013 (when I lost the One) and I re-started later on (with the Flex). I usually walk between 5,000 and 10,000 steps per day, with a maximum on July 1st (the day we moved). 10,000 steps is the daily goal Fitbit gave me. There is a significant difference in the number of steps measured by the One (before October) and the Flex (after October): I cannot really say if it is due to the change in tracking device (and their different location on the body) or if I kind of reduced my physical activity (mainly because of more work, sitting in the office).

Fitbit steps over time - 2013

As always, I’ll promise to add some physical activity on top of this baseline as a New Year resolution. We’ll see next year how things evolve. In the meantime I’ll explore more what I can extract from my Fitbits in the following posts. Stay tuned!

Comment your code

QR codeIt doesn’t matter if you write proprietary or open source code, comments in your code are very important (somehow even more important than readability and functional correspondence to the client’s needs). This is especially true if someone else is supposed or will, one day, look at your code, re-use your code and/or build upon your code.

For example, despite the fact that this source code header explained what the whole source is doing, you can’t tell what processing is done in this paragraph:

           MOVE SPACES TO IDTCLO-L1 OF ACXB01
                          IDTCLO-L2 OF ACXB01
                          IDTCLO-L3 OF ACXB01.
           @ZOBLIG, IDTCLO OF ACXB01, IDTCLO-V OF ACXB01-V.
           @CLR1, "01", "**", IDTCLO OF ACXB01, "3", "Y", "Y", "N",, \
                  IDTCLO-V OF ACXB01-V.
           MOVE IDTCLO    OF CLR1   TO IDTCLO    OF ACXB01.
           MOVE IDTCLO-L1 OF CLR1   TO IDTCLO-L1 OF ACXB01.
           MOVE IDTCLO-L2 OF CLR1   TO IDTCLO-L2 OF ACXB01.
           MOVE IDTCLO-L3 OF CLR1   TO IDTCLO-L3 OF ACXB01.
           MOVE NUMCLO OF CLD01-01  TO NUMCLO    OF TS-INTE.
           INITIALIZE ACD0B-01.
           MOVE NUMCLO OF TS-INTE TO NUMCLO OF ACD0B-01.
           MOVE REFACE OF ACXB01   TO REFACE OF ACD0B-01.
           @READ, "1", ACD0B-01, XX.
           IF ACCESS-OK
              @ERREUR, IDTCLI-V OF ACXB01-V, "ACXX0001"
           END-IF.

This code is definitely not readable. It first uses a standard nomenclature for variables, it uses macros with a good number of unknown variables, we don’t exactly know what can cause an error while accessing the table in the last lines, etc. This is only an example ; you can find this behaviour in many other programming languages.

That’s a reason why I really like tools to auto-generate comments and documentation (like Javadoc, pydoc, etc.). The documentation is in the code and it usually doesn’t block code reading while adequately describing what a section/paragraph/function does. And the tools can generate properly formatted documentation in a lightweight format (usually HTML+CSS, not heavy MS-Word documents). One nice thing: you don’t need to send the code and the documentation for review or upgrade: just send the code and your addressee will automatically get the documentation (s/he will be able to automatically generate it). And, in 2 years, people will still understand what you wrote and they won’t need a specialist to reverse-engineer your code.

By spending a little bit of your precious time to comment your code, others will get a better understanding of what you did and your project, as a whole, will save an impressive amount of time (time that you can spend on a terrace with a refreshing drinks).

Photo: “quote” by Bonnie Peirce (CC-by-nc)

A voté !

As every Belgian citizen, I voted today for our legislative bodies (Chambre et Sénat). As always, I was confronted to the same problem: electronic voting. Technically, I’ve no problem to understand and use the system: it’s an ethical problem. I don’t know if my vote is correctly written on the card, even with all the given guarantees and technical details (you can test such a voting machine here or watch a demo of the Belgian system, both in French). Personally, I saw two problems:

  • Source code is not available to any citizen, even if they promised to release it on the day of the polling (see the official website and screenshot below). I don’t think I have enough computer security knowledge to review those sources in detail but I think they have to make them available because 1) it allows a democratic control and 2) they promised it. I usually do not believe in conspiracy theories but … 😉 See update below
  • The old lady in the voting booth next to mine was “helped” by someone she doesn’t know from the polling station. I clearly was able to hear technical instructions but one doesn’t know the exact meaning when the person told her “to point there“. Don’t be mistaken: hopefully this person was there to help her, otherwise the old lady wouldn’t have been able to vote. What I’m criticizing is the fact that all Belgians are not equal in front of the voting machine (although they are all supposed to be equal in front of the law).

I was very happy to see that all the French-speaking political parties presidents were against electronic voting (with some nuances for the MR party). Let’s see how they will act during the next legislature …


(bigger version here)

Update: at 17.00 (5.00pm) files were finally online (here and here, personal copies here and here). I guess they were not able before 15.00 (end of voting time) to avoid code substitution on some machines by hackers, like it happens with the Nedap machines in the Netherlands.