Proper nerdy

Not blogged in a while, and today’s post is going to show me up for the geek I am.

So for a while I’ve been using my website to publish my own recipes, and automatically calculate the nutrition information. From time to time I would even add this information to MyFitnessPal, when I used the recipe during a tracking phase. Lately I’d been wondering, can I generate bar codes to use MyFitnessPal’s scanner, so I don’t have to look up the recipe data manually?

Turned out it’s quite easy to generate bar codes in Perl, there are several modules out there for doing so. All I needed to do was modify my site content regeneration script to generate the images and display them on the page, then go through the tedious process of scanning each bar code and adding the nutrition data.

So as of today, MyFitnessPal users should be able to scan the bar code on my recipes for their own tracking purposes.

Nerd details:

Generating bar codes that will scan on a screen isn’t hard. By default the module I used generates pixel-exact bar codes. However, any image scaling applied to the generated image, and the code won’t scan; at least, not on the screen.

EAN-13 Bar codes have an internationally recognised system, allowing the encoding of country of origin (or special code), company ID, and then item number. Books are encoded with a special country code known as Bookland (978 / 979) and 999 is reserved for Vouchers. I decided 999 would be the best code to subvert.

Next, a “company ID”, for which I chose 7707. Why? Syllabic encoding for memorisation. Quack’s Echo (KwaKS eKo) encodes 7707 (KKSK) for memorisation. The item numbers are simply IDs in my recipe database.

Told you.

Leave a Reply