Recently I have been using an iPhone app called Momento. This is a diary app with a difference. As with any diary app, you can add diary entries complete with photos and tags. Momento also allows you to connect to web services such as Twitter, Facebook and Last.fm to populate your diary with your online activity. You can also add RSS/Atom feeds to be included in your diary. Here are the feeds I have currently in Momento:
- Instapaper: Unread
- Instapaper: Archive
- Last.fm Loved Tracks
- Delicious Bookmarks
- Quora: Followed Questions
I created Momento Extendo so I could use some more Twitter related feeds with Momento:
Added List Members
Removed List Members
Added Subscribed Lists
I thought this would be a good opportunity to learn some Ruby an try hosting an app on Heroku. I choose Sinatra as the web framework because it was lightweight, easy to learn and took little to no time to get up and running. A couple of Heroku add-ons I used were Apigee for Twitter and Cloudant Hosted CouchDB. Apigee provide a proxied Twitter Api endpoint that gives you a whitelisted rate limit (20k reqs/hour). The free Cloudant hosted CouchDB solution offers 250 MB of storage with a hosted Futon admin.
The main purpose of the app is to regularly poll Twitter to detect changes in a user’s friends and lists in order to provide a feed of these changes which can be used with Momento. This polling is required because, at the moment, Twitter does not included timestamps with friendship-follow/unfollow or list activities. Initially, I thought about using Delayed Jobs to take care of the polling but this would involve using a background worker process for which Heroku charges for. As the app is going to have fairly low traffic and the single HTTP process or ‘Dyno’ can handle between 10 and 100 requests per second, I started looking for a solution that could ping the app periodically over HTTP.
I found Moment, a service that allows you to create a delayed job that makes an HTTP request at the time specified.
I use the Daily Cron Heroku add-on to remove any completed Moment jobs.
- Sinatra – lightweight web framework
- Twitter – Twitter Api client
- Twitter OAuth
- CouchRest – Provides a wrapper around the CouchDB http api
- Rufus-Mnemo – Tokenizer using syllables from the Japanese language
Some items from my Twitter Friendships feed in Momento: