Month: March 2005

Weight Table – Perl

The Perl Version

I really liked the Tcl version, but at some point I didn’t want to stick to an application any more. A web interface would have been much better for my needs.

This change by itself would not have prompted a new implementation, but I realized that there would be no GUI interface, and that hence the tables and graphs would have to be built on the fly. Tcl’s sluggish response and the need for external software made me wonder whether that was the right approach.

I saw the GD package, and was surprised how easy it actually was to create graphs given knowledge of the data. Further along, I found GD::Graph, which actually went all the way to displaying a graph from data input. I had to do without comments, but as soon as I get hotspots to work, they’ll be there again.

As a result of the conversion, the code went down from 20k for the Tcl version to 8.5k for Perl. Of course, the Tcl version could be optimized considerably (especially the computation of coordinate transformation, which is not centralized), there is no GUI in the Perl version, and the latter benefits from a sizeable library. All in all, though, I think I’ll stick with Perl for future programming tasks, and will switch to PyQT for GUIs.

All the Perl that's Practical to Extract and Report

Weight Table – TCL

Weight – The Tcl Version

Ok, the real name of the program is gewicht.tcl, and it is correctly TCL, since it’s an acronym. Now that we’ve got the FAQ done, let’s move on to greater things…

The only external package used is TkTable. The weight input is a table, so that you can see past dates and modify the data there, or even input many days at the same time. If TkTable is not available, don’t despair – you’ll still be able to input today’s weight (but not the bodyfat) very conveniently.

All you need to run the program is Tcl, more precisely a currentish Tcl/Tk wish application. gewicht.tcl expects the file gewicht.txt to be present in the startup directory. It will read the file and figure out the current weight chart from there, asking for additional data if there is no information for the current day.

The format of the file is fairly simple. In human-readable terms it’s a sequence of lines, each of which contains the data for one particular day. Each day is made up of the date, the weight, the bodyfat percentage and a comment, each separated by semicolons.

Example:    16.03.2003;170.4;20.1;Back from Maui

Of course I didn’t choose the example to rub it in! 🙂

Everything after the weight is optional. The code knows how to work around missing data, and it doesn’t expect the dates to be sequential.

Once input is complete, a chart pops up. Dots mean single day data, lines denote averages. Big black dots mean data with comments, and if you hover above the dot, a popup will show the comment. An unruly status display at the bottom will show the current pointer pixel’s date and weight.

By default, it shows dates on the x-axis and weight in pounds on the y-axis. A ‘complicated’ system of keyboard shortcuts allows you to get to additional data:

  • l for ‘lbs’, displays the weight in pounds
  • k for ‘kilos’, displays the weight in kilograms
  • b for ‘bodyfat’, displays weight and bodyfat (y axis displays bodyfat units)
  • f for ‘fat’, displays weight and total fat (y axis displays pounds)
  • t for ‘total’, displays weight and non-fat total (y axis displays pounds)
  • q for ‘quit’
  • right, left, control right, control left, home, end navigate if you need to scroll
  • alt f, shift alt f save the current canvas as postscript file

Weight Table – The Table

This is the current chart of Marco’s body fat. (Click on picture to see other views)

If you want to input new data for a particular day, please do so here:

User Name:

Software – Overview

This section deals with the public domain software I've written or collaborated with. The major projects, all accessible from the menu at the left, are:

  • HTML Tree – a way to generate a static site from an XML file and a directory structure. Essentially, HTML Tree applies a template to a set of files and adds navigation based on the XML file structure. If you want a (fast) static site instead of a dynamic site, this might be the tool for you.
  •  Weight Table – an implementation of a weight table. Started as a tool to help me lose weight, and became then a challenge in itself. The first thing I implement when I am faced with a new programming language is the weight table. Currently, implementations are available in Tcl/Tk, Perl, Java (not published), and PHP/Joomla.
  • Polar HRM – I used to ride my bike all over the place, and it annoyed me that I had to use the (quite horrible) Polar software to get graphs of my workout data. Thanks to Dave Bailey, who created software to read Polar data, I added my own twist and started generating my own workout graphs, integrated into HTML Tree above.
  • Passwords – com_passwords is a component that allows you to store secure content on your site. You can add notes, and all content that is in bold face (strong or bold tags) will be obfuscated in plain view. A separate, encrypted copy of the content is stored and can be retrieved by presenting the correct passphrase. Don't lose the passphrase, or your data is lost for good!
  • Joomla Synchronization – frustrated with having to be online to edit my site, I started thinking of using Blogg-X to do the deed. That caused more frustration, as the current version doesn't work on Linux, while the previous version doesn't work with Joomla 1.0.15. So I started thinking about a different tack: use Joomla to edit a Joomla site!

Computers – Overview

A geek like me needs a whole section on computers. I tried to categorize my current public work in two general sections:

  1. {moscontentlink:Software} where I discuss software projects I have been or am currently working on. All of these are in the public domain, typically licensed using some variant of the GPL v2 appropriate for the circumstances.
  2. A general section on Computers, technically a blog, in which I put everything else – including hardware reviews, Linux tips, etc.