Sunday, 13 November 2016

Polar M400 repair

It was almost too good to be true.  I was using [my Polar M400](http://blog.chukhang.com/2016/01/review-polar-m400-and-flow-as-activity.html) every day and it was doing almost everything I had wanted it to do.

However, the convenient micro-USB charger port turned out also to be its Achilles's heel.  After a few months, the port started getting finnicky and the watch refused to charge without some "jiggling" of the USB cable.  Over time it got worse to the point where I could not reliably charge the watch at all.

I sent it back to Polar for service.  It was hard to let go of a watch that I'd been wearing almost 24h per day for nearly a year.  Fortunately, Polar service turned it around reasonably quickly: it took 8 days from when I shipped it (USPS Priority Service) to when I received it again.

The repair summary was `Oxidation in Connector`.  After a bit of Googling, it appears that this is a common problem with this model of watch.  The problem affects the early models (including mine) which had a rubber cover for the charge port.  Sweat would get under the cover and the cover prevents it from fully drying.  Over time, the sweat corrodes the port.

The repair replaced the port and removed the rubber cover.  [Supposedly the port is already waterproof and the newer versions do not have this rubber cover.](http://support.polar.com/us-en/support/maintenance_of_your_m400)  In fact, there are some people who recommend removing the rubber cover if your version has it.

So overall, it wasn't a bad experience.  It was annoying to be without the watch for about a week.  It was also annoying to have to pay $6.80 USPS shipping to send it back.  However, at least they not only repaired the watch but they also addressed the root cause of the problem (the rubber cover).

Monday, 11 January 2016

Review: Polar M400 and Flow as an Activity Tracker

Okay, I have a confession.  I am a nerd who loves measuring things.

For workouts, I started with a Polar FT7.  It's a basic training "computer" with heart rate monitor and it did (what it could do) quite well.

For steps, I started with a Fitbit Flex.  For a while I was obsessed with how many steps I made each day and on some days even tried to fit in a few more steps just to make my daily goal.  I also use the Flex to track the quality and amount of sleep.

Most recently, I got the Polar M400.  It's a training computer, like the FT7 (albeit with far more features), and also an activity tracker (including steps and sleep), like the Flex.  My two obsessions of tracking workouts and activity can now be served by one gadget!

It's been a couple of weeks now and I think I can comment on the Activity tracking aspects of the new gadget.  (I might write about the workout features later.)

To give a bit more background, as well as Fitbit, I have also dabbled with Android Wear (in the form of a Moto 360) and Google Fit.  The Moto 360 worked okay but the battery life was a huge issue; at best I could get 16h out of one charge.  That made it passable for counting steps but essentially ruled it out for sleep tracking.  The other problem is that it's a big watch; it sits really high off the wrist.


## The Watch

The M400 is pretty big but looks okay on my wrist, which is probably on the small size.  (I can wear the small Fitbit Flex straps using the last two notches.)  However, there's a photo from one of the Amazon.com reviews where it looks comically big on a small person's wrist.  (That review gave the M400 a low score.)

The design is definitely "sporty".  I work in a tech company with a bunch of geeks so I can wear it everyday and I think it looks fine.  I wouldn't wear it with a suit; that would look stupid, IMHO.

The screen is a bit disappointing.  It's a monochrome dot matrix LCD (rather than segmented), so it's a little more sophisticated than Casio and Timex watches from the 90s.  It seems prehistoric compared to the colourful touch screens on Android Wear watches such as the Moto 360.  It only has four watch faces showing

   - day, date, time and daily target completion
   - analogue time with day of month
   - super large hour and minutes
   - day, date, time and my name.

The last watch face doesn't make any sense to me; maybe Polar was worried I might forget my name.  I find the resolution of the screen to be too low for the analogue face to look good (whereas there are some beautiful analogue faces on the Moto 360).  The small number of options is definitely a disappointment compared to the many customisable watch faces in Android Wear.

The battery life is very good.  Officially it can last 24 days per charge if used only as an activity tracker and that seems very plausible from what I have seen so far.  Battery life is reduced if using the other features such as pairing with a heart rate monitor or its built-in GPS.  I've used it with a heart rate monitor for about 3-4 hours per week and the battery still comfortably lasts the week.  Better still, when I do need to charge, I can use a standard micro USB charger.  (Supposedly Polar designed a special waterproof micro USB connector for this watch.)

It has built-in GPS but it can only be used when I start a training mode.  It can measure heart rate with a Bluetooth Smart (aka 4.0 or LE) heart rate monitor strap such as Polar's HR7.  It doesn't have a built-in heart rate monitor (like the Fitbit Charge HR which I also considered) so though it's fine for workouts there's no way to get 24/7 heart rate readings.  (Not even with future firmware upgrades.)


## Software

Fitbit uses the Fitbit app and Moto 360 uses the Google Fit app.  The M400 uses the Polar Flow app.  The watch syncs to Polar Flow in the cloud via the Polar Flow app on the phone.

Getting started was a bit annoying because I had to install Polar Flow Sync software on my Windows desktop.  Polar Flow Sync was required to register the M400 with my Polar web account.  Once the watch was registered, I could pair the watch with the app on my phone and thereafter I can sync with just the phone.  I wish there were a way to sync directly with the app without installing any software on my Windows machine; I guess there's no way to use the watch with Flow if all you have are Chrome OS, Android and Linux devices.

Also, the Polar Flow Sync software is required to install firmware updates on the watch.  The Flow app doesn't support firmware updates unlike Fitbit's app or Android Wear.

Compared with Fitbit and Google Fit, the first difference I found was that Flow doesn't have separate daily targets for different activity measures.  In Fitbit I set daily goals for steps and in Google Fit I set daily goals for either steps, active time, calories or distance.  In Flow, I just pick one of three levels of daily target (not very creatively named 1, 2 and 3).  Flow takes a combination of Low, Medium and High intensity activity and counts them towards my daily goal.  It's not exactly clear how the different activities are combined, however, I have found that I can reach my daily goal even though I don't reach 10k steps as long as I did some other activity, such as resistance exercises in the gym.  I think this makes sense.  Sometimes I had felt short-changed when Fitbit or Google Fit didn't acknowledge my "achievements" because I didn't make 10k steps even though I had put in a really hard workout in the gym.  Flow will count the workout towards my daily goal.

The other difference is that Flow has a finer-grained measure of Activity level.  Whereas Fitbit and Google Fit both give two counters for "Not Active time" and "Active time", Flow breaks this down into five counters, which based on the icons are approximately "reclining/sleeping", "sitting", "standing", "walking" and "running".

After I have accumulated 10h of activity in a day, Flow will give feedback on the day such as "you're a slacker, you should be more active _but at least you didn't sit around for too long_" or "good job man, you were active and did some exercise" (paraphrased by me).  Maybe I am simple, but the feedback actually makes me feel good.

Overall, I like this combined measure of activity.  I guess I would since it's easier to achieve my daily goals but I like to think that this combined approach is a more accurate measure of the health benefits of daily activy.

Fitbit and Google Fit measure activity and goals day by day; I either reach it or miss it each day.  Flow, on the other hand, can average my activity across multiple days.  In the week or month view on the Flow website, it shows me what percentage of my activity goal I achieved over that period.  This way, if I had an inactive day, I can make it up on subsequent days and still meet the target over the week.

Another useful feature is that Flow can sync its data to Google Fit.  This means that my daily step counts (and some other data) get sent to Google Fit and Google Fit uses this data to fill in those step count gaps when I've been walking without my phone.  In this sense, it does the same as what the Moto 360 did... but much better because of the better battery life.  The nice thing about Google Fit is that it uses the location data from my phone and can use it to infer when I've been travelling by bike.  Sometimes it has sufficient location resolution to allow it to draw the track of the route I walked or biked.

Those are the differences that I think Flow does better.  On the negative side, the M400 doesn't support automatically syncing like with Fitbit or Android Wear.  I have to press a button on the watch to explicitly initiate a sync, and it seems to take _forever_.  Also, at least on a couple of occasions the sync failed: in one case I could rectify it by turning bluetooth off/on on the phone but in the other case I had to unpair and repair the watch with the phone.  I'm hoping the syncing issues are just bugs that will be ironed out and that continuous syncing will be supported in the future.

Of the three, Fitbit still has the best social features.  Neither Flow nor Google Fit allow me to stalk my friends' daily activity nor brag to my friends (assuming they even care) about how many steps I have walked today.  There's also no option to challenge them with competitions as to who can put in the most steps per day.  (Did I mention that I can be competitive?)  I don't think it's really that important but it does make Fitbit that little bit more fun.


## Conclusion

I think overall the M400 with Flow works really well as an activity tracker.

   - Positives:
      - Combines different activities for daily goals.
      - The Flow website can average activity and goal completion by week and by month as well as by day.
      - The same app (and website) shows stats from workouts together with activity.
   - Negatives:
      - Hardly any social features.  Fitbit is more fun.

So what am I using right now?  I wear the M400 and Flex together!  The Flex is small and unobtrusive enough for me to wear it as well, just for the social features.

Sunday, 7 July 2013

My thoughts about the Sony NEX6

In mid 2012, Sony announced the RX100: a compact camera competing in size against the Panasonic LX5 and Canon S105 yet trumping them both in picture quality with a larger, 1-inch sensor.  A few months later, they followed up with the announcement of the RX1: a "pocketable" camera with a high quality fixed focal length lens and a full-frame sensor.  Unfortunately for me, its premium build and optics are matched by its equally premium price tag.

At the same time, Sony also announced the NEX6, a compact 16-50mm zoom *and* an ultra wide-angle 10-18mm zoom.  At last, Sony's NEX system had matured into something meeting essentially all the criteria for my perfect camera system: a compact body with a high quality sensor and an ultra wide-angle zoom.  As an added bonus, the NEX6 even has a view finder.

At that point, it suddenly occurred to me that Sony really "gets" enthusiast photographers.

Early this year, I could resist no more and using a European trip as the excuse, I ordered a NEX6 kit with 16-50mm lens and a 10-18mm ultra wide-angle.  It's been a few months now and I have had the opportunity to give it a few workouts and can write down some of my thoughts.

My main reference point is the Nikon D90.  I have been using the D90 with 16-85mm and 10-24mm Nikkor lenses for a few years now.  The D90 was and still is an immensely competent camera.  A whole five years after its introduction, its sensor captures pictures whose quality is still respectable even compared to those from current generation DSLRs.  It is responsive enough that there is virtually no perceivable delay from pressing the shutter button to taking the photo.

In comparison, the NEX6 is far smaller and lighter.  The NEX6 and 16-50mm together weigh less than just the Nikkor 10-24mm lens alone.  When packing for a trip, the Nikon system takes up 2/3 of my carry-on luggage.  The Sony takes up only a fraction of the space required for the Nikon.

Better still, it would appear that Sony have achieved this miniaturisation feat while making very few compromises.  The sensor produces beautiful pictures.  It is definitely no worse than what I would have expected from the Nikon and very likely better.  I don't notice many ergonomic compromises either.  The grip is comfortable and the important buttons fall within easy reach of my fingers and thumb.  It even beats the Nikon with its tilting rear screen which makes it possible to see the screen whether I am taking a photo from near the ground or high above my head.

There are a few things I miss from the Nikon though.  I prefer the two control dials split between the forefinger and the thumb.  The Sony has both its dials on the back and on many occasions they have the same function.  However, ergonomically I find little else to complain about.

The Sony on-camera software features feel light years ahead of the Nikon.  It has a selection of cute modes including in-camera HDR, multi-shot noise reduction for low-light and stitched panoramas.  Having an electronic view finder also means that you get to preview some of the filter effects before you take the photo.  This is useful for black and white.

Yet there are some niggling annoyances about the Sony software.  I often find that it takes too many button clicks and dial twirls to navigate through the layers of menus in order to do simple things such as "format SD card" or "set exposure bracketing".  Also, I still do not understand why there are separate "stills playback" and "video playback" modes and why I have to manually switch between them.

Perhaps what annoys me the most about the software is that many of the fun in-camera processing features do not work with RAW files.  You get to choose to record RAW files *or* use the in-camera processing feature, but not both.  This means that if you find that an HDR photo did not come out as well as you expected, there is no way to recover the original three exposures.  As an enthusiast, I hate having to make this "processing before or after" choice.

Finally, I would say that the 16-50mm and 10-18mm lenses are a huge step towards an enthusiast friendly system but they are still lacking compared to the Nikkor equivalents.  I found that the extra zoom reach of the Nikkor 10-24mm was extremely convenient compared to the more limiting 10-18mm of the Sony.  At 24mm, the perspective looks almost normal whereas at 18mm the perspective is still decidedly wide.

The 16-50mm zoom is compact because of its motorised folding and unfolding but this comes at the expense of responsiveness.  When you switch on the camera, it takes an extra half second to unfold the lens.  Also, when the camera sleeps to save power, the lens folds in, and when you wake it, the lens will unfold but only back to its widest zoom setting.  It effectively loses whatever zoom setting you had carefully chosen before.

Conclusion: I would say that Sony definitely "gets" the *features* that enthusiast photographers want, however, Nikon still understands better how enthusiast photographers really *use* their cameras.

Sunday, 4 September 2011

Markdown in Blogger

I'd been avoiding blogger for while because I like neither wysiwyg
editors nor raw HTML.  I find wysiwyg annoying because I never know
what the editor is doing and what sort of weird codes it is inserting
which will come back and bite me later.  I find HTML has a horrible
authoring user experience: it is way too easy to forget to close some
tags and end up with non-conforming HTML.

I have been a fan of
[Markdown](http://daringfireball.net/projects/markdown/) for many
years. I find its light weight mark up to be very good for authoring
content.  Wordpress has long supported markdown but it wasn't right
for me: the free hosted wordpress.com service couldn't support vanity
domains properly (and doesn't include the markdown plug in); I don't
write enough in my blog to justify paying for hosted Wordpress; and I
didn't fancy running my own web server with Wordpress (and its
security updates).  What I really wanted was Markdown support in
Blogger which offered free hosted blogs with support for vanity
domains.

My investigations into existing options found solutions which only
really solved the problem for post creation rather than authoring in
general which includes editing.  Typically, they were along the lines
of

  1. write blog post in markdown
  2. convert (and save) as HTML
  3. publish.

The problem now is that the post is in its converted form which means
you cannot edit the post in its original markdown syntax any more.

Instead, I decided to "roll my own" (well, reuse what exists out there
to do it my way).  The basic idea is:

   1. write and save post in markdown syntax between `pre` tags
   2. convert markdown syntax on the client-side using a javascript
      markdown implementation.

Now, if you happened to be using a browser that doesn't support
javascript, at worst you'd have an unrendered post in markdown syntax
which thankfully is quite readable already.

Fortunately, most of the hard work had already been done by
[showdown](http://softwaremaniacs.org/playground/showdown-highlight/)
which is a javascript port of a markdown.  I just took showdown and
plumbed it together with some more javascript which

   1. finds `pre` elements marked with `class='markdown'`
   2. call showdown to convert their contents into html and inject
      that back into the post inside a `div`.

It was a actually a bit trickier than I had first thought.  I'd had to
fight to check it worked in a reasonably recent version of IE which
always seemed to behave differently from the other browsers (Chrome,
Safari and Firefox).  I also fell into some weird javascript holes
(yeah, my javascript-fu mostly sucks).

The result is a .js file which you use by adding one `script` tag to
your Blog template.  It's still work in progress so I'll hold off
sharing the code (properly) until I think it's ready.

There is one major caveat.  Though I am now freed from the tyranny of
angle brackets and matching open and close tags, I still have to make
sure I escape special characters such as <, > and
& since the content of the `pre` tag still has to be html.

This article is written in markdown.  What do you think?

I hate capslock

Update 4.ix.2011: I'd originally written this in April 2006 but it
appears the following instructions still work in Windows 7.

The standard UK and US 102-ish keyboard layouts annoy me: the capslock
is in the wrong place.

I used to swap the capslock and the left control key, but this usually
caused problems whenever someone else tried to use my computer,
because they'd inevitably hit the key labelled "Ctrl" and end up
turning on capslock.  Eventually, I finally accepted that I _never_
use capslock (well, maybe once a year - max!) and now use three
control keys (i.e. the two standard ones, plus the key which is marked
"capslock").  Note: don't do this if you're a FORTRAN77 programmer AND
PROGRAM EXCLUSIVELY IN CAPITALS.

In Windows 2000 and XP, there's a feature called the [Scan Code Mapper
for
Windows](http://www.microsoft.com/whdc/device/input/w2kscan-map.mspx)
which allows you to remap keys.

You can either try to understand the scan code mapper by reading the
page linked above, or just believe that I did it once, trust me and
paste the following lines into a file `ihatecapslock.reg` (or
something similarly imaginative), and then run it through the Windows
Explorer interface.

    REGEDIT4
    ; make capslock key another control key
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
    "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

If you ever want to scrub your scan code map, i.e. return your
keyboard settings back to the factory default, paste the following
into a file called `resetscanmap.reg` and use it analogously:

    REGEDIT4
    [-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]

You will have to reboot your PC for the scan code mapper to notice the
registry changes (log-out/-in might be enough to do it too).

Saturday, 13 August 2011

How to use Google Authenticator in Debian Wheezy

Google have [released a PAM for the Google
Authenticator](http://code.google.com/p/google-authenticator/source/browse/#hg%2Flibpam)
which can use used together with its mobile app to provide two-step
authentication for linux-based systems.

Note that this uses the same mobile app as for [2-step
verification](http://www.google.com/support/accounts/bin/static.py?page=guide.cs&guide=1056283&topic=1056284)
which you may already use for GMail and other Google Apps.

This document describes how to set up two-step authentication using
the Google Authenticator PAM on a Debian Wheezy system.  It should be
possible to modify these instructions for other linux variants and
older versions of Debian linux but Wheezy is convenient since there is
already a `libpam-google-authenticator` package.


## Installation on the phone

If you are using Android, install the [Google Authenticator App from
the
Market](https://market.android.com/details?id=com.google.android.apps.authenticator).

Google Authenticator is available for other platforms too.  It's
currently available for iOS and Blackberry.  See the
[google-authenticator](http://code.google.com/p/google-authenticator/)
project page for apps for other mobile platforms.


## Installation on the server

Tip: before you start tinkering with pam settings for ssh, make sure
you have an alternative way into your system, such as a serial console
or a keyboard+monitor.  I.e. if your machine is in some remote
colocation facility and all you have is ssh access, you should be
pretty confident you know what you are doing.

Install the Google Authenticator package

    sudo apt-get install libpam-google-authenticator

Generate a key and the emergency login codes. (Each user needs to do
this and after you have enabled the PAM, those users who have not
generated a key will not be able to log in any more.)

    google-authenticator

This will print a QR code in your ANSI terminal.  Scan this QR code
using the mobile app to send the secret to the App on your phone.

It will also list six emergency login codes which can be used in case
you do not have your phone available.  Keep a hard copy of these codes
in a safe place such as your wallet.

Create a `/etc/security/access-local.conf` to allow connections from
subnet 192.168.1.0 (edit to suit) to skip the two-step code:

    LOCAL_SUBNET="192.168.1.0/24"
    cat <<EOF | sudo tee /etc/security/access-local.conf
    # only allow from local IP range
    + : ALL : LOCAL
    + : ALL : ${LOCAL_SUBNET}
    - : ALL : ALL
    EOF

Edit `/etc/pam.d/ssh` by appending two `auth` lines to the end of the
file:

    cat <<EOF | sudo tee -a /etc/pam.d/ssh
    # skip one-time password if logging in from the local network
    auth [success=1 default=ignore] pam_access.so accessfile=/etc/security/access-local.conf
    auth required pam_google_authenticator.so
    EOF

If you want two-step authentication for _all_ ssh connections no
matter the source IP address, you only need the last `auth` line from
above (and you can skip creating the `/etc/security/local-access.conf`
file).

Finally, make sure in `/etc/ssh/sshd_config` the following is enabled

    ChallengeResponseAuthentication yes

This was `no` on my freshly installed Wheezy system.


## Further information

   * [Google Authenticator project page on Google
     Code](http://code.google.com/p/google-authenticator/)
   * [PAM Installation
     Instructions](http://code.google.com/p/google-authenticator/wiki/PamModuleInstructions)

Friday, 29 December 2006

Using an NSLU2 as a USB print server

(Update 3.ix.2011: This article is ancient.  I now run debian on my
slug rather than unslung and it is no longer serving as my print
server.  This article is kept for posterity)

I've configured my NSLU2 as a USB print server using CUPS.

My NSLU2 "Slug" is running OpenDebianSlug, and followed the
instructions at
[http://www.nslu2-linux.org/wiki/DebianSlug/Printing](http://www.nslu2-linux.org/wiki/DebianSlug/Printing)
for instructions on how to install the `usblp` module and CUPS.  To
summarise, as `root`

    wget http://ipkg.nslu2-linux.org/feeds/openslug/cross/2.7-beta/kernel-module-usblp_XXXX.ipk
    dpkg --force-all i kernel-module-usblp_XXXX.ipk
    depmod -a
    apt-get install cupsys hotplug

I then configured my printer as `printer` using the `links` text-based
browser on the slug itself.

In windows, I set up an IPP printer to print to my CUPS printer.

The set up works fine, except for one major flaw.  If I send a job to
the printer while it is switched off, CUPS can't print and so stops
`printer`.  When the printer is switched back on, `printer` still
accepts print jobs, but it is stopped.  The only way to get the
printer going again is to Start the printer, for example via the web
interface on port 631.

I found a solution by adapting the script found on
[http://www.trustix.org/wiki/index.php/Configure_CUPS](http://www.trustix.org/wiki/index.php/Configure_CUPS).
I created a file `/etc/hotplug/usb/usblp` with the following contents:

    #!/bin/sh
    #
    #
    # Arguments :
    # -----------
    # ACTION=[add|remove]
    # DEVICE=/proc/bus/usb/BBB/DDD
    # TYPE=usb 

    if [ "$ACTION" = "add" -a "$TYPE" = "usb" ]; then
      /sbin/modprobe printer
      for i in `/usr/bin/lpstat -v |awk '$4 ~ /usb:/ {print $3;}'|sed -e 's/://g'`;do
        /usr/bin/enable $i
        /usr/sbin/accept $i
      done
    fi

What this does is Start `printer` (that's what `/usr/bin/enable` does)
whenever it detects a hotplug `add` event.  I had to install
`cupsys-client`:

    apt-get install cupsys-client

to get the command `/usr/bin/enable`.