Ruby for everyday tasks
Ever since I learned to drive, I’ve been trained to record both the trip and total mileage when buying gas. As a young driver, this was for my parents’ finance tracking - they’d buy gas on their vehicles, and so it all went into the big money database somewhere.
Being a creature of habit, though, I kept doing this after I started buying my own gas, and eventually wound up with a stack of gas receipts with two numbers scribbled across the top. Since my parents no longer cared about them, though, I became responsible for these little scraps of paper. Why not have some statistical fun with them?
To satisfy my curiosity (and to be able to throw away all those crumpled-up receipts), I wrote GasTracker, a single-serving Sinatra application that allows users to list cars and drivers, then record the gas purchases made by each driver on each vehicle. To get some usefulness out of the thing, I also made it generate summary statistics for the purchases it tracked:
Yes, those numbers are accurate for my gas purchase history: I really have spent almost $1,800 on gas since September 2009, even though I got an average purchase price of $3.17 per gallon.
Right now, I have this deployed internally behind Apache (with Passenger) so that I can have some password-protection. Next steps are to clean up the UI, finish out the REST API, and write a mobile application. (Feel like contributing? Fork it on GitHub!)