Tracking your nicotine intake with CouchDB and Protovis
JavaScript Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



An application to keep track of how many cigarettes you smoke in a long run.

It's a standalone HTML/JS application served from CouchDB database, so called CouchApp, built with the soca Rubygem.

It's specifically tailored for usage on the iPhone:

Screenshot: Smokes


Because quitting is easy. Restraining yourself is much more interesting. Also, because Protovis charts are sexy.


You'll need a working Ruby & Rubygems on your developmment machine, and working CouchDB database — either local or remote.

If you have CouchDB running locally, you don't need anything else.

If you don't have CouchDB installed, you should give it a shot. It's awesome database. Otherwise, you can get hosted database for free from CouchOne or Cloudant.

The application relies on the soca RubyGem to deploy the application source into the database. So, let's install the gem first:

$ gem install soca

Then, clone (or download) the repository and switch to the folder with application:

$ git clone git://
$ cd smokes

Copy the example couchapprc configuration file:

$ cp couchapprc .couchapprc

You may want to edit the settings in the file:

$ $EDITOR .couchapprc

The default (development) database is set to http://localhost:5984/smokes.

If you have Admin Party disabled, or you want to use hosted database, make your changes accordingly.

Now, let's push the code into Couch:

$ soca push

and open the application in browser:

$ soca open

You may well want to seed the database with some dummy data, to see something interesting. That's easy.

First, install the json and rest-client gems:

$ gem install json rest-client --no-ri --no-rdoc

Then, run the provided Rake task:

$ rake seed

And reload the app.


To run the application FOR REALZ at your own or hosted server, you'd probably want to restrict the access. In Couch, that's simple.

Just make sure you have Admin Party disabled and you have your admin credentials handy. Prefferably, create separate smokes user.

Then configure the security for the database (make sure to replace USERNAME, PASSWORD and SERVER):

# Display current settings
$ curl http://USERNAME:PASSWORD@SERVER/smokes/_security

# Restrict access to the database
curl -H 'Content-Type: application/json' \
     -X PUT http://USERNAME:PASSWORD@SERVER/smokes/_security \
     -d '{"admins":{"names":["USERNAME", "smokes"]},"readers":{"names":["USERNAME","smokes"]}}'

You can now load the application simply by placing the credentials into the URL:


Don't forget to put this instance as an environment into the .couchapprc file, probably as production. You can deploy the application simply by doing:

$ soca push --debug=true production

For quick access to the application on the iPhone, put it on your homescreen.

Please report any errors, concerns or similar as Github Issues.

Karel Minarik