Tracking Happiness
A friend of mine Anu has this popular question to ask when she meets us "What am I proud of and grateful for?". It's an interesting question. While answering it last time, I realized its a proxy question for asking how happy am I. I don't know what Anu thinks but I will ask her next time I meet her.
In general tracking happiness is very difficult. It depends on so many things, from sleep to how many good conversations you had in a day. But I have realized if I have a good answer to Anu's question; it means that I am quite happy. So for last few weeks I have made notes every day (sometimes multiple times a day) using a single word,"What am I proud of and grateful for?".
I use NomieApp on my phone and some CouchDB magic to create real-time word cloud of the words. Click on the image below to see real-time cloud.
Nomie is available both on Android and iPhone, it allows you track anything you want privately. There is no server-side component. But you can backup the data to your Computer or Dropbox. If you are experimental then you can sync the data to a CouchDB instance in real-time. Syncing to CouchDB not only backups your data but also gives you API to play with. I use cloudant hosted service of CouchDB but you can set up your own CouchDB.
My setup is below
Nomie updates all the data to a db called username_events, where username is your couchdb username. Now I don't want to expose everything to the world and hence I filter the notes that begin with #grateful and #proudof, replicate them to another db called proudof_grateful. Below is the filter function
function(doc,req) { if(doc._id.substring(0, 4) == 'note' && (doc.value.substring(0, 8) == '#proudof' || doc.value.substring(0, 9) == '#grateful' )){ return true; } return false; }
and the design document
{ "_id": "_design/only_grateful_proud_notes", "language": "javascript", "filters": { "myfilter": "function(doc,req) { if(doc._id.substring(0, 4) == 'note' && ( doc.value.substring(0, 8) == '#proudof' || doc.value.substring(0, 9) == '#grateful' ) ){ return true; } return false; }" } }
On proudof_grateful I have CouchDB views that would count the words and give me word:no_of_occurrences as response. Below I have listed MapReduce functions with responses
#count_grateful #map function function (doc) { var s = doc.value.split(" "); if(s[0] == "#grateful"){ emit(s[1], 1); } } #reduce function function(keys, values, rereduce) { return sum(values); }
The response when you access the url https://your_couch_db.com/proudof_grateful/_design/summary/_view/count_grateful?group=true
{"rows":[ {"key":"Coffee","value":1}, {"key":"Family","value":3}, {"key":"Food","value":3}, {"key":"Love","value":2}, {"key":"Opportunity","value":1}, {"key":"Peace","value":2}, {"key":"Privilege","value":1}, {"key":"Sister","value":1} ]}
Similarly for counting #proudof words
#count_proud #map function function (doc) { var s = doc.value.split(" "); if(s[0] == "#proudof"){ emit(s[1], 1); } } #reduce function function(keys, values, rereduce) { return sum(values); }
The response when you access the url https://your_couch_db.com/proudof_grateful/_design/summary/_view/count_proud?group=true
{"rows":[ {"key":"Amma","value":1}, {"key":"Code","value":3}, {"key":"Cooking","value":1}, {"key":"Friends","value":1}, {"key":"Hack","value":2}, {"key":"Patience","value":1}, {"key":"Work","value":1}, {"key":"Workout","value":2} ]}
Now that I have all the data as JSON response I use wordcloud2.js library to draw word-cloud in real time.
To be frank it shows what I am really #proudof and #grateful for. All you need is a sense of achievement and something to be grateful for; so you are grounded. That for me defines happiness.
Let me know if you want to any help in setting up this for yourself.
Love this!! Thank you so much for sharing.
Thanks for an awesome app Brandon.