Blog, by date: 2012_marfrom the desk of travis johnson.
fibonacci miles and kilometers (from 2012/03/29)In my running, I have been trying to keep track in kilometers. This presents a couple problems: Somehow, my mind still thinks in miles, which is weird because I do not really have that good of an idea exactly how far a mile is, either. Or someone wants to know how far a 5k is. Or, when I was running the 2011 Chicago Marathon, there would be kilometer postings between the mile markers. Anyway, it is handy to convert between them, but a bit of a pain. It turns out that the ratio of adjacent Fibonacci numbers are a decent approximation to the unit conversion between miles and kilometers. I decided to look into it a bit. First, in case you have never seen or do not remember what Fibonacci numbers are, they are a sequence of numbers where the first two fibonacci numbers are
which gives rise to the sequence
You can actually come up with a closed form solution for Fibonacci numbers, which is borderline incredible, using the recursion relationship given above. If you assume that
Then canceling a
You can use the trusty quadratic formula to solve this, it gives
Clearly the
Now, since we want
Now, finally, we have that
It seems I have run a little off track. What does all of this have to do with running? Well, the Fibonacci numbers eventually approach this fancy There is a catch though. Some Fibonacci ratios are better than others:
It looks to me like a sweet spot is at the 8 kilometer/5 mile mark. So now you can see that 25 miles is 40 kilometers, or whatever distance you wanted to know about in the first place. digital photography (from 2012/03/29)Recently I've decided to dedicate a slight bit of time to get a bit better at taking pictures. I'd always wanted to get a truly nice camera, and the opportunity presented itself, so I decided to go for it and bought a Nikon D5100 DSLR. I also ended up getting a complete steal on the Nikon 55-200mm DX VR lens, which was pretty awesome. Project 365 would be a great move from here, since I'm certainly no photographer, but it's been fun just learning about it all the ins and outs and how it all works together. In any case, I did start a Flickr: drtraviscj account which I'll be posting stuff. More later. tjtestharness - a language-agnostic DVCS unit-test/continuous integration tool (from 2012/03/26)I've been wanting to have a way to visualize which unit tests(or sets of them) passed for a given commit, if for no other reason than the sense of accomplishment from watching boxes turn yellow, then green, as they pass tests. The trouble is, I write code in a lot of different languages for a lot of different projects. I also don't want to bother with running unit tests individually–I want them to run as I perform commits. My main project right now is working on a fast quadratic programming(QP) solver for series of related QPs, and in turn using that QP solver as the basis for a sequential quadratic programming method with a penalty globalization. It's working okay, but there's a lot of levels to the project, and it's easy to make a change in one place in the code that has far-reaching effects on other parts. It's also got a very complicated structure for testing, because of the nature of nonlinear programming. Testing runs something like
So there's a lot of levels and layers and levers and settings. What was happening is that I would change some parameter and eventually it'd get checked into the repository, and that wouldn't play nice with other codes. I realized that I wanted some unit testing to automate this testing process, and document how it should be run, and soforth. But I also wanted the video game-style insta-rewards vibe to it, along the lines of the Panic Status Board(albeit less professional.) I also didn't want to spend a ton of time on it. I planned out the interface and databases over some beers with my roommate one night and wrote the entire thing in Django the next evening. I wanted it to run automatically on every repository commit. I also wanted it to try to make some sense out of Python, MATLAB, and C, since I use all three extensively. It should also actually be able to build a project from scratch, and every build should run from nothing–this enforces the rule that the repository is self as self-contained as possible. Finally, I also wanted to be able to look back at the actual run log of that unit test and see how or why it failed(and also have instructions on which repo/commit to checkout to see the bug in action). My basic idea was that I wanted some program that kept a database of projects I'm working on, displayed some commits from those projects, showed the status of any test_*.{exe,mat,py} commands it could run. Okay, so I need a table of projects, one of commits, and another of tests. Originally I built it that way, but I wasn't sure how to get columns uniformly figured out. So I decided to split the 'test’ table into 'Tests’ and 'TestResults’, which worked out nicely. The other tricky part was figuring out how I should add commits to the database, and how tests should get run. I ended up writing a fairly nice script for the commits to put in .githookspost-commit, though it requires the kludgy 'git push origin master’ in the post-commit as well. This is causing a bit of trouble with modifying commits(ie, it breaks the other script and causes extra merges/commits.) The not-so-interesting side was the one that peeks into the database, grabs the 'test’ (which is basically just a shell-script to run), and runs it. It also pushes the data back to the database when it's done. Django is a really amazing framework. The entire coding part of the project went together in about 8 hours. I'm still not happy with it. I've got a laundry list of stuff to add here:
If you're interested, check it out at code.traviscj.com's tjtestharness. |