whazzing around

a thing on the internet

Fitgem v0.5.0

| Comments

I’m happy to announce that the latest Fitbit API features have been exposed through the fitgem ruby library and released as v0.5.0.

New features include glucose, blood pressure, and heart rate logging and retrieval methods. Documentation has also been updated to include new endpoints for the Time Series interface.

Source | Gem | Issues | Documentation

v0.5.0 changelog

  • Added Fitgem::Client#heart_rate_on_date to retrieve heart rate data by date
  • Added Fitgem::Client#log_heart_rate to log heart rate data
  • Added Fitgem::Client#delete_heart_rate_log to delete previously logged heart rate data
  • Added Fitgem::Client#blood_pressure_on_date to retrieve blood pressure data by date
  • Added Fitgem::Client#log_blood_pressure to log blood pressure data
  • Added Fitgem::Client#delete_blood_pressure_log to delete previously logged blood pressure data
  • Added Fitgem::Client#glucose_on_date to retrieve glucose data by date
  • Added Fitgem::Client#log_glucose to log glucose data
  • Added Fitgem::Client#delete_glucose_log to delete previously logged glucose data
  • Updated README

Long Live Markdown

| Comments

I’ve been doing a lot of development around markdown lately and I’m really starting to love it. Specifically, Github-flavored markdown has grown on me with its ability to do easy fenced code blocks and syntax highlighting.

comments = Comment.all


comments = Comment.all

When I rewrote the code for this web site awhile back I decided to support markdown, but didn’t really think I’d use it much; maybe to do code blocks but not much else. Now I find myself writing markdown for all content, and only translating it through various interpreters when I need the HTML. In retrospect I’m extremely glad I went through the effort to add markdown support for the site— I use it all the time now.

There’s an incredible app for writing markdown on the fly: Mou is a Mac application that lets you input markdown on the left pane and the HTML is dynamically updated in the right pane. I’m literally using it right now to write this post, just to get a preview of what it will look like when I drop it into the <textarea> on the web site.

I basically use it for all markdown content authoring, and then I copy/paste the result into whatever application/content field I will use it in. It allows me to do edit/revision cycles on content as well as seeing the application of styles. Highest recommendation.

I also recently forked git-wiki and started working on improving it for my own use. It also uses Markdown to write the wiki entries, which gets a little weird if you’ve ever used MediaWiki or Wikipedia. The default way to define wikiwords in git-wiki didn’t really work for me so I updated it and checked everything back into my own repo. I’ll be updating more about my git-wiki fork once I get it refactored and a little more configurable.

So there you go- markdown is awesome and you should write your content in it; if you’ve never worked with it then try it out on Github (just make a public repo and create a README.md in the index).

Fitgem v0.4.0

| Comments

I’m happy to announce that the latest Fitbit API features have been exposed through the fitgem ruby library and released as v0.4.0.

In addition to the new features, I thoroughly documented the entire library API (available here), added many more unit tests, refactored the subscriptions methods, and moved the oauth process documentation to the project wiki on github.

Source | Gem | Issues | Documentation

v0.4.0 changelog

  • Added YARD documentation to thoroughly document code
  • DEPRECATED: Fitgem::Client#log_weight method, use Fitgem::Client#log_body_measurements instead.
    The new method allows you to log more than weight (bicep size, body fat %, etc.)
  • Added Fitgem::FoodFormType to be used in calls to Fitgem::Client#create_food
  • Added Fitgem::Client#log_sleep to log sleep data to fitbit
  • Added Fitgem::Client#delete_sleep_log to delete previously logged sleep data
  • Added Fitgem::Client#activities method to get a list of all activities
  • Added Fitgem::Client#activity_statistics method to get statistics for all logged activities
  • Added to documentation of supported endpoints for Fitgem::Client#data_by_time_range
  • Added unit tests for parameter validation for many methods
  • Overhauled notifications methods, including extensive documentation, unit tests, refactoring, and a couple of bug fixes. These methods now return both the HTTP status code and the JSON response body. See https://wiki.fitbit.com/display/API/Subscriptions-API for information on how to interpret each of the error codes.
  • Added fitgem to travis-ci for continuous integration (http://travis-ci.org/#!/whazzmaster/fitgem)
  • Added fitgem to rubydoc.info (http://rubydoc.info/github/whazzmaster/fitgem/master/frames)
  • Updated README
  • Moved OAuth documentation from the README to the fitgem wiki

December 2011 Reading List

| Comments

I thought I’d jot down my current technical reading list. I tend not to read technical books straight through, but instead I pick up a few at a time and refresh myself on whatever I’m interested in at the time. (Full disclosure: these links include my Amazon affiliate code).

  • Learning Mysql

    Back in 2002 I got my exposure to SQL while doing elemntary PHP programming. I read a little about MySQL back then, but never really went deep into things such as indexes and optimizations. Rails obscures a lot of that stuff, but I wanted to be able to optimize efficiently and learn more about the underlying technology. So far this book has been really good at diving down underneath your SELECT, UPDATE, CREATE, and DROP actions.

  • Metaprogramming Ruby

    This is bar none my favorite Ruby book, and in my opinion is far better than the Pickaxe book for those who are coming to Ruby from another language/ecosystem. The fellas at Bendyworks have been doing a bi-weekly book club on this book and I’ve happily attended as many as I could to talk about it. This book goes into incredible, understandable detail about the object model and dynamic nature of programming in Ruby. It gets my highest recommendation.

  • C Programming: A Modern Approach

    My college computer science curriculum was in C++ and Java. My job at Intuit involves C/C++/C# development, but it tends to fall heavily into the C++/C# side of things. I respect the hell out of Zed Shaw’s outlook on programming, and truly believe that a working knowledge of C development will take you far. To that end, I’ve been working through Learn C the Hard Way online while reading this superb book. I also purchased the original The C Programming Language book, but A Modern Approach is, in my opinion, superior as a reference and primer.

My technical reading list changes often; I’ll usually read through three books over the course of several weeks and then pull more off my shelf and refresh myself on a different topic. It’s why I also buy books on the periphery of my interests just to have them on my shelf. I enjoy having the references available, even if I don’t read them as soon as they arrive.

Whazzing.com v1.2

| Comments

Whazzing.com v1.2 has been deployed to production. Updates include:

  • Posts can now be attached to projects in order to create news feeds on a per-project basis.
  • Added favicon to the site
  • Added ranking implementation for posts using Redis. Not in use yet.
  • Added RSS feed for posts. Available at http://www.whazzing.com/posts.rss
  • Updated styles for the post and project pages

Upcoming plans include:

  • Post ranking implemented
  • Section on the homepage for ranked posts
  • Project RSS feeds
  • Twitter integration on projects

Fitgem v0.3.6

| Comments

On October 14th Fitbit announced the latest version of their API, including support for features of their new Fitbit Ultra tracker hardware.

Source | Gem | Issues | Documentation


Floors and elevation info from activities_on_date

pp client.activities_on_date("2011-10-24")
     "Weight lifting (free, nautilus or universal-type), light or moderate effort, light workout, general",
     "Weight lifting (free, nautilus or universal-type), light or moderate effort, light workout, general",
    [{"activity"=>"total", "distance"=>2.07},
     {"activity"=>"tracker", "distance"=>2.07},
     {"activity"=>"loggedActivities", "distance"=>0},
     {"activity"=>"veryActive", "distance"=>0.3},
     {"activity"=>"moderatelyActive", "distance"=>0.68},
     {"activity"=>"lightlyActive", "distance"=>1.09},
     {"activity"=>"sedentaryActive", "distance"=>0},
       "Weight lifting (free, nautilus or universal-type), light or moderate effort, light workout, general",

Floors and elevation info from data_by_time_range

pp client.data_by_time_range("/activities/log/floors", {:base_date => "2011-10-24", :period => "1d"})
{"activities-log-floors"=>[{"dateTime"=>"2011-10-24", "value"=>"9"}]}

Food Goals now available through the foods_on_date method

pp client.foods_on_date("2011-10-24")

Device info now returns lastSyncTime

pp client.devices

Get details on a food with new method food_info

There is a new method that will fetch detailed food information given a food ID. Food IDs are generally retrieved by searching for a food using find_food.

# Get food info for an apple
pp client.food_info 20711
   "defaultUnit"=>{"id"=>226, "name"=>"oz", "plural"=>"oz"},
   "units"=>[226, 180, 147, 389]}

Calories now returned in find_food results

pp client.find_food("GoLean Raisin Bran Crunch Cereal")
    "defaultUnit"=>{"id"=>17, "name"=>"bar", "plural"=>"bars"},
    "name"=>"Cereal Bar, Raisin Bran Crunch",
    "defaultUnit"=>{"id"=>304, "name"=>"serving", "plural"=>"servings"},
    "name"=>"Raisin Bran Crunch Cereal",
    "units"=>[304, 91, 256, 279]}]

Searching vs Finding

| Comments

I’ve found that many of the truly interesting and outlook-altering pieces of information I’ve acquired have come via finding something randomly or pseudo-randomly as opposed to searching it out.

These days the information in question is often a tool, configuration, or piece of code that radically shortcuts an oft-repeated activity. It has nothing to with luck, or ability to use Google, however. The delight in finding the perfect tool or option is often that you never conceived that it could exist in the first place.

The most stark example I’ve had recently is in pursuit of my quest to learn vim. In changing over from TextMate to vim many times I would end up pondering really newb questions: how do I cut a line of text? How do I move to the end of a file? A couple of HI-YAH’s of Google-Fu later I’ve got the answer an I’m trucking along. Some days, however, I’ll be reading something unrelated and all of a sudden learn that dt followed by a character will delete from the cursor position to the next instance of that character. It’s weird, but that was a game-changer for me. Changing out strings became: dt” and then insert and go.

I could also characterize my use of guard in this way. I was at a Mad-Railers hack day awhile back and Brad happened to be using guard for his rspec execution during TDD. It was a revelation that I could just edit files and tests and it would automatically rerun. Here’s where things get interesting, however. It had previously never occurred to me to even look for a way to speed up my tests or optimize the time spent manually executing them. It was a problem I didn’t know I had. After learning about guard I looked through the list of available guards, however, and found some other interesting ones. These additional plugins for the guard model were also solving problems I didn’t even know were bugging me until I found they were solved problems.

This all came to me this morning as I was watching Ryan Bates’ Railscast on using Spork to speed up test execution further by preloading the Rails framework and keeping it in memory between tests.

When worrying about getting a primary goal completed (say, a feature in an application) you don’t often think about solutions to one-off problems or annoyances, let alone prioritize solving them. This is partially why I invest time at the beginning of a project to develop and optimize the code-test-fix cycle, why I obsess over the deployment model when I only have a README, and why I like continuous integration before a test has been written. Once your process for coding is solid, you can optimize it piecemeal as you need to or as you find unexpected tools or processes that would increase your productivity drastically.

An example: my tests were already running really well under guard, but 15 minutes or install and configuration of guard-spork I saw immediate speed gains.

Paperclip and ImageMagick on Ubuntu

| Comments

In getting the paperclip gem working on my server for some screenshots I ran into a frustrating problem. I kept getting an error during model saving: “/tmp/1234bduct-123.png is not recognized by the ‘identify’ command”. Eventually I solved the problem, so here is my solution, hoping that it helps someone else out there.

After some googling and reading Stack Overflow I quickly came across the solution that Paperclips :command_path option wasn’t being set correctly. The problem, however, was that it looked like I was correctly setting the ImageMagick path:

$ which identify

I kept double- and triple-checking that the option was set correctly in my config/environments/staging.rb file:

WhazzingCom::Application.configure do
  Paperclip.options[:command_path] = "/usr/local/bin"

That seemed to be correct, but I still kept getting the same error. Eventually I came across an excellent suggestion that perhaps my installed version of ImageMagick was incomplete, corrupt, or missing libs or dependencies. First I reran the ImageMagick apt-get install…

$ sudo apt-get install imagemagick --fix-missing

…which installed identify to /usr/bin rather than the existing version in /usr/local/bin. I then updated my environment file to the following…

WhazzingCom::Application.configure do
  Paperclip.options[:command_path] = "/usr/bin"

…and refreshed the page and everthing worked as expected!

Redesigning Whazzing.com

| Comments

For the last month I’ve been working to create this new development-focused blog and project repository for my work. I was previously self-hosting a Wordpress blog, but I’ve developed a desire to own my destiny when it comes to the display of my work. There were a ton of little features I wanted to develop but didn’t really want to delve (back) into the PHP world or hack at the Wordpress template framework.

I’d recently read the excellent Responsive Web Design and it made me very excited to design a site that effortlessly works on phones, tablets, monitors, and TVs. Another project I have in mind is primarily aimed at mobile form factors, so I thought a semi-major experiment was in order to ensure I was thinking in the right direction when it came to media queries and mobile design.


I built whazzing.com with ruby 1.9.2, rails 3.1, mysql, and various gems. My first commit was August 19th, 2011 and I deployed version 1.0 to production on September 20th, 2011.

As I started coding this site, Rails 3.1 was entering it’s final release candidate testing phase so I decided to start fresh on it. The asset pipeline is just a terrific addition to the framework, and combining it with the style organization I’ve been developing off of Dale Sande’s incredible Axle framework provided for a very smooth visual design experience. I added a little bit to Dale’s CSS organization to support the media queries I wanted to support.

|-- stylesheets
    |-- admin.css.scss
    |-- application.css.scss
    |-- design.css.scss
    |-- devices
    |    |-- phones.css.scss
    |    |-- tablets.css.scss
    |    |-- high-resolution.css.scss
    |-- imports
    |    |-- colors.css.scss
    |    |-- form.css.scss
    |    |-- mixins.css.scss
    |    |-- navigation.css.scss
    |    |-- text.css.scss
    |-- reset.css.scss
    |-- typography.css.scss

One of the interesting takeways from the excellent testing panel at Madison Ruby was that people are divided about the usefulness of cucumber. I had always stumbled in wrangling cucumber to be really useful for the applications I was writing and so I decided to eschew its usage this time. I focused instead on getting good coverage via my RSpec controller and model tests. I found that leaving cucumber aside really streamlined the process and didn’t leave me eternally feeling like I was losing focus on the functionality I wanted due to the the myriad tests that were demanded by all the tools I was using.

Madison Ruby was a fantastic source of information on how to write better ruby code and rails applications. In particular, Jeff Casimir’s talk on using view-models and decorators as opposed to helpers in rails was food for thought. Halfway through implementation on this site I switched over to using draper for my presentation logic and I love it.

Another tool I wanted to test out for this project was git-flow. At Scott Chacon’s eye-opening Git workshop I increased my git knowledge 10 times, easily. Going through the underlying structures of git taught me a lot about what’s really going on during commits, push, and branching, and I wanted to try to formalize the release process of this project a bit more using git-flow’s branching model. The result: I loved the structure of the branches, even if this was a one-man project, and will definitely use it on more projects in the future.

Finally, I’ve been more and more intrigued by Markdown since Github and many other sites support it these days. Instead of pouring time into creating a WYSIWYG editor or trying to drop one in, I instead grabbed the Redcarpet gem and simply use markdown to create the posts and project descriptions. I also use albino and pygments for code highlighting.

Methodology & Features

The problem I had to overcome this time (and every time I jumpstart a project) is that too often I get bogged down on tangents. I’ll get fixated on one unimportant feature or line of code, I’ll get frustrated that I can’t get it the way I want, and eventually I won’t even want to open the text editor due to feelings of dread. This time I was determined to mercilessly cut features until I had something simple I could get coded and deployed, and then iterate from there. A few times I almost got bogged down, but forced myself to leave features on the table for future releases so that I could get my high priority functionality into production.

I settled on four main features for the first release:

  • Responsive design so that the site would look great on regular monitors, phones, and tablets.
  • A micro-resume viewable here that I could link to from my new business cards and elsewhere
  • Taggable blog posts without comments (for now)
  • A project guide so that I can link to all my projects in one place, with links to docs and code where appropriate

My major feature list for the next release includes:

  • Comments on blog posts (spam-protected and everything!)
  • RSS feeds of blog posts
  • Release tracking of projects
  • Rating and ranking of blog posts

I’ll also, of course, be correcting anything that shakes out while using it.

What’s Next

I’m looking forward to extending this project, while using it as a platform to document the other things I’m working on. I would really like to use redis for some analytics/tracking ideas I have, and I’m interested in how to tie in akismet spam-blocking for comments.

The images along the left side don’t scan well on mobile devices, so I’m going to look into replacing them in the next release as well. I like the structure of the site, but the specific details could be tightened a little.

I’d like to get a styleguide up and running so that my CSS can be standardized a little. I tried as much as possible to be OO in my CSS but failed in a few places that I’d like to clean up.


Many, many thanks to Joe Nelson, from whom I shamelessly stole the idea for the micro-resume. Thanks so much for the idea- it jump-started what became the new site, blog, etc.

Also, thanks to Kevin Burke. I read his blog post on designing your personal site and was inspired to go beyond the usual “reverse chronological order of posts” home page. Instead I tried to create a homepage that advertises all the things I’m working on, blog posts being only one of the pieces.

Thanks to Dale Sande, who helped me step up my CSS game with his excellent Axle framework and thoughts on OOCSS (object-oriented CSS). If you ever get a chance to attend his OOCSS talk definitely do it; as a primarily backend dude I found it immensely helpful for structuring my CSS and semantic markup.