Archives For June 30, 2013

Introducing Patina

July 16, 2013 — Leave a comment

Patina is a tool for finding occurrences of byte data patterns in one file within the data of another.

For instance, let’s say you have two files. The first file contains this:

12345

And the second file contains:

0123456789

Then a match is found for the values 12345, since the second file contains this sequence.

OK, so let’s consider another scenario. The first file contains:

12345

And the second file contains:

012346789

Notice the missing “5” in the second file. So obviously, a match will not be found for the full sequence of “12345”. So what will Patina do? Well, it will find a match for “1234”.

Patina starts with the longest possible sequence from the first file, and looks for it in the second file. So when no match is found for “12345”, the length to look for and the next sequence to check for is “1234”, then “2345”, then “123”, “234”, “345”, etc.

However, since Patina has already found a match for “1234”, it will not also find a match for “123” or “234”. The purpose is to get the longest possible matches and ignore any smaller matches within the found match.

Any matches that are found will just be output to the screen, in a format looking like this:

Data at position 0 (16 bytes) found in 2 place(s).

Of course it’s pretty useless to just get the output to the screen, but I’ll get around to dumping it as XML or JSON eventually.

The source code is on GitHub: https://github.com/codemeyer/Patina

Since reading Phil Haack’s blog post about using a Fitbit step counter, I felt the need to try one myself. I always enjoy adding a bit of “geek” to any element of my life, and measuring the steps I take, the number of calories I burn and the number of stairs I climb seemed like just the thing. Especially when I spend my entire working day just sitting at a desk. After a few months of procastrinating I finally got a Fitbit One at the beginning of April.

As mentioned, the Fitbit One measures the number of steps I take, and how many flights of stairs I climb. This data is then presented in a pleasing manner, either in the app (for iPhone or Android) or on their web site. You get colorful graphs such as the one below, which in this case displays the steps I’ve taken on a relatively active day this summer.

fitbit-graph

Recently, I extended my Fitbit family by purchasing a Fitbit Aria scale. It measures my weight and body fat as a percentage and then uploads the data to Fitbit via Wi-Fi. Even if the body fat percentage is less than scientifically accurate, I figure that as long as the discrepancy in its measurements stays constant, I will get an indication of the general “trend”, as it were.

Currently I’m averaging somewhere around 50% more steps per day than when I started measuring three months ago, so it’s obviously working! And since I recently convinced my wife to get one, I have added a new dimension of competitiveness to it all. It’s on now!