USB Power Meter – 5.12 v

USB Power measurement

USB Power Meter – 5.12 v

It is really strange that a data-connector would manage to become a standard power plug, but USB achieved just that: most devices which can work or charge using 5 volts nowadays come with a USB connector. I think this is generally a good thing, one standards means less redundant incompatible hardware, and people don’t need to have N power adapters around. Of course there are compatibility issues, and we already have reached the point where determining the power draw of a device connected over USB is black magic: this can be determined by software nobody implements (original spec), or by putting some magic resistors between pins, with each manufacturer using his own secret sequences.

This leads to the second interesting question: how much power do these various devices use? I just bought a small device that is pretty useful to answer that question: a short USB plug that measures both the voltage and the power consumption on a USB connector. This device only gives you half of the story, how much power goes into the device, not how much was consumed by the power supply (which might be a computer, a printer, or a TV), it still gives some insights into the electrical power consumption of various gizmos – as a good charger typically has 75% efficiency.

For instance, a Qi wireless charger uses 0.04 Amperes when empty, that is 0.2 Watts for doing basically nothing. Charging my Fitbit Charge draws 0.03 Amperes out of my laptop (0.15 Watts). When docked and charged, my iPhone 5 consumes 0.3- 0.4 Amperes (1.5 – 2 Watts).

I’ll need to try more devices around the house. I also would like to measure how efficient the various chargers in the house are.

Flattr this!

Mac GPG Logo

PGP key signing party

Mac GPG Logo

This Friday we had another PGP key-signing party at the office. This was a pretty academic exercise, as I rarely can use encryption in my emails: the system is way to complex to be used by the layman. What struck me during this key-signing party was how dated the whole process is, it was the developed in the 90’s and this shows in the clunkiness of the tools.

The first problem I encountered was, surprise, Unicode, or the lack thereof. Problem is that all identities and official documents have names in roman letters, but did not follow the same romanizations rules. You think this is a rare case, I encountered three during this party.

The second problem is the process involves written down key identities, which is fine, except the tools to create the printouts are horrible: everybody had a slightly different paper, with slightly different information, the content was badly laid out, with a courier font. This made the checking unnecessarily tedious.

The third problem is academic paranoia. Yes, it is possible to hack a printer to change the content of the key, but let’s honest this is a complex attack as nobody uses the same printer. This also means that a process that could be expedited using a mobile device is artificially tedious.

In fact, if I were to attack such a party, I would just use paper tricks: use thinner paper and glue together two keys, one that the reviewer sees, and another that separates when in the pocket. All participants left the party with a bundle of papers, with the assumption they checked them all, if one were to appear at that stage, they would not notice.

Ideally, I think this process could be greatly improved using a mobile app: add some QR-codes with the key’s fingerprint and the user information and use machine readable passports. The app would read both sources of information, display the information for comparison and keep track of the user’s choice (trust / don’t trust). That application does not need to connect to the network, all the processing can be done within the phone. Yes, in theory the app could be compromised, but so do the encryption tools.

Flattr this!

PDF Rendering

PDF rendering in Safari

While HTML has gone a long way, if you want reasonably stable rendering of pages, PDF is still king of the hill. But being widespread does not ensure stability.

If you look at the these two renderings, in particular around the feet, you will see some pretty weird differences (click to see full-size pictures). The first is a rendering in Safari, while the second was rendered in Chrome. You can notice many gray artefacts in transparent areas of the second image, the colours are also overly saturated.

PDF rendering in Chrome

These differences seem to be only the tip of the iceberg: at this year’s CCC there was an interesting presentation about hybrid file formats, including PDF files that would render different things depending on the viewer.

Flattr this!

Fitbit Charge

Timezone changes may result in data when the clock is rolled back, or gaps in data when the clock rolls forward. Automatic timezone changes only take effect after tracker sync.

While big smart watches are the thing those days, I was more looking for a small bracelet that would do few things well: give me the time, display information about phone calls, and maybe do some light activity tracking. I finally bought a Fitbit Charge, which provides all of the above, but also tracks steps, floors you climb and you sleep patterns. I also like the fact that you can use it as a silent alarm clock.

The device itself is a rugged looking plastic bracelet which closes with sturdy looking metal clasps. The display is quite small, but luminous, there is a single button that shows the various data: clock, steps, distance, calories, floors. The device charges with a USB cable that plugs into a connector on the back of the watch.

Setup is quite contrived, besides charging, you need to connect a special dongle to your computer, which is kind of strange given the fact the watch communicates via bluetooth. The software lets you configure the watch, which you can then pair with your phone. All the subsequent data exchange I did with the phone. I’m not completely sure if the computer step was actually needed or not.

日本, right?

While the hardware looked pretty OK, the software is basically all over the place. Of course you need an account and the iOS app cannot sync with the bracelet without internet access, while the software is not as bad as the one for Withings scale, it is not good – it is no so much software to connect the bracelet to the phone as yet another health platform with support for the bracelet. As you can expect from a Silicon Valley startup, the support for localization is completely broken: you cannot choose a language, just a country and they try to guess it wrongly from my date format.

What’s worse is that the app does not support Healthkit, so you either have all you data with Fitbit (no), or you need another App to do data mediation Sync Solver. At least Fitbit has an API to retrieve the data. Be careful, for measurements like weight, Sync Solver will get bogus measurements in the past, polluting your database, so make sure to only enable syncing for measurements you actually have on the Fitbit device.

Given the fact this is a young market, it is not really surprising to see various players elbowing each other to be the central repository for health data. The truth is I don’t trust a single of these companies, and wish they would all support Healthkit directly, and let me store my data only on the device, not the cloud and instead of trying (and failing) to develop health frameworks, they concentrate on building good hardware with good basic support for watch features, like for instance supporting travelling between time-zones…

Flattr this!

Substring considered harmful – an example


I have complained on languages that allow substring operations. It should come as no surprise that I found an occurrence of that bug in the theme I use in my blog.

As you can see on the image, the post preview contains some corrupted Unicode data. The thing is, the title this data is generated from is perfectly valid and contains the following text:

<!–:fr–>Bonne Année<!–:–><!–:en–>Happy New Year!<!–:–><!–:ja–>明けましておめでとう!<!–:–><!–:de–>Einen Guten Rutsch ins neue Jahr!<!–:–>

The weird comment tags are leftover of the previous plugin I used for handling multiple languages, and serve as delimiters between languages. They should be ignored by the rest of system.

So why do I end with corrupt data? The problem lies in the following PHP snippet (there are two of them in fact):

<header class="entry-header">
  < ?php 
    if (strlen(get_the_title()) >= 85) { ?>
      <h1 class="entry-title"><a href="<?php the_permalink(); ?>" data-title="< ?php the_title(); ?>" rel="bookmark">
  < ?php echo substr(get_the_title(), 0, 84)."...";
    else { ?>
    <h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark">
  < ?php the_title();  

The intent of the author of this code is pretty clear, if the entry-title is longer than 85 characters, cut the title and append an ellipsis. This is a code pattern you will find in many user-interface codes.

Problem is, this code does not do what the author think it does. In PHP substr is defined in bytes, not characters. In UTF-8, characters are thus typically 2 bytes long and Kanji (like 明けましておめでとう!) are three bytes. Here the 84th byte happens to fall in the middle of the ‘し’ character, and cutting there produces invalid UTF-8 data. The biggest irony is that because string length is computed before the invisible tags are stripped, the selected cut point is wrong anyway…

What is the fix? PHP actually has functions to get the width of a string in runes and cutting to the right number of unicode characters: mb_strwidth and mb_strimwidth.

You can fix your sixteen installation by replacing the following files:

Flattr this!

Convoi – Cyberpunk Publié il y a environ 3 jours par Thias Vue de nuit de Shibuya, à Tōkyō Dès le début de la conception de Convoi il me paraissait évident qu’il y aurait un monde cyberpunk, avec des voies rouillées sur des docks détrempés par les pluies acides. Si j’ai des idées assez claires sur ce qui devrait se passer dans ce monde dans le premier scénario, le monde à proprement parlé est resté quelque chose de générique, ce qui m’ennuie.

Properly Localising the Sixteen theme

Convoi – Cyberpunk
Publié il y a environ 3 jours par Thias
Vue de nuit de Shibuya, à Tōkyō
Dès le début de la conception de Convoi il me paraissait évident qu’il y aurait un monde cyberpunk, avec des voies rouillées sur des docks détrempés par les pluies acides. Si j’ai des idées assez claires sur ce qui devrait se passer dans ce monde dans le premier scénario, le monde à proprement parlé est resté quelque chose de générique, ce qui m’ennuie.

This blog currently uses the sixteen WordPress theme. Friday I turned on a multi-language plugin (xili) and theoretically, everything should have worked out of the box:

Sixteen has been already translated into French, Spanish, Russian, Japanese, Arabic and supports translation into more languages.

In practice French did not work out of the box: the french locale files were corrupt, not to mention badly translated, and the plugin uses the timeago JQuery module without setting up localization, you always get English relative time. So here are the steps to fix the Sixteen theme (version for French. Modulo the localization files, this should hopefully work for other languages:

  1. Backup everything
  2. Replace the content of the french localization file sixteen/languages/fr_FR.po with this one.
  3. Use a tool like poedit to generate a new version of sixteen/languages/ If the file is zero byte long, there is a problem.
  4. Replace the file sixteen/js/jquery.timeago.js with the latest version (1.4.1).
  5. Download the locale specific timeago configuration for the language you need, in my case it was, put these files into the sixteen/js/ directory.
  6. Replace the content of file sixteen/functions.php with this updated version

If you don’t care about French, you skip steps two and three, but note that the compiled localization files for Spanish are empty, and missing for Arabic, Japanese and Russian, so I doubt these will work straightaway.

Flattr this!

Screenshot a blog post in french with partial localisation

Multilingual – New take


I have given another shot at making this blog run in multilingual mode, this time with another plugin (xili), which seems to be better integrated with internals of WordPress. This forced me to fix some the french translation file of the sixteen theme, which was completely broken. Things kind of work now, i.e. the blog’s chrome will render in French for a blog which is French, but there still is one bug: the theme uses the JQuery timeago module, and generating date texts within Javascript means that the PHP localization framework won’t work. There is an update version of timeago, which includes support for localization, I’m not sure to what extent I’m willing to fix the current theme or just switch to better designed one.

Edit: I fixed the theme.

Flattr this!