Dial to find the price of a book

Dial  +91-40-44556944(pin 8586), enter ISBN and know the cost of a book on flipkart.

Scenario
You are in a book store, looking at an interesting it. Before buying it, you would like to peek at its price online and see if you can order it online for a better deal. You have a mobile phone, but no internet on it.

Use Case
Dial a number (+91-40-44556944 and pin 8586), enter the ISBN number of the book that you are holding and instantly get the price of the book.

APIs used
This is the scenario and the solution that I hacked together, during the weekend. Hacker News carried a story about kookoo.in some days ago. The phone API looked interesting and I decided to give it a try.
KooKoo.in has Java APIs that can be used to create web services that feed into the phone API they provide. I fired up an instance of Google App Engine at http://flipring.appspot.com/price.

Technical WorkFlow
  1. When the user dials the number and the PIN, the web service is called the first time and it plays a message telling the user to enter the ISBN number. A session variable stores the state.
  2. When the user enters the ISBN number, the web service is called again, something like http://flipring.appspot.com/price?data=0333933427. This time, the value in the session variable indicates that the user has entered the ISBN number and its price is required. 
  3. A crawler kicks in an gets the search site from flipkart.com with the ISBN. The product page is obtained and a naive search is done to extract the price, discount, book name and author. 
  4. This data is played back and the session variable is set to initial state again. 
The code for this servlet is available here. The entire application was put together in under an hour and the crawler code is brittle.

Next Steps
As the next steps, I am looking at
  • Improve the crawler, get prices from more sites to return the cheapest price
  • Host the code as a project on github or google code.
This is my first DTMF application and please do write to me if you have feedback. Watch out this space for updates.

Sounds of some sorts


Earlier this week, I came across this youtube video that illustrated various sorting algorithms with sound effects. Unfortunately, it was a video and not a live demo.
I picked up the baton and decided to play around with HTML5 audio and see if I could get a live demo out. Unfortunately the Audio API can only playback audio files, there is no support for generating sounds yet. I decided to pick up some audio files from the Piano and Drum beat examples. I was able to find 12 unique sound files, and associate them to each value in the sample input.
The tricky part was to keep the code for the algorithms while allowing the animations and sound effects have time delays. I wrote a couple of basic functions like greater() and swap() that were called for comparisons and swapping values in the algorithm. They also added the required animation/sound effect to a queue that played asynchronously till the queue was empty.
There you have it; the sounds of some sorting algorithms. The web page is available here.
I was also exploring the additions to the audio API that were proposed and are a part of Firefox 4. It has interesting way to not only playback audio files but also generate audio. Next step - try to see if I can have larger samples and generate sounds for them !!
Watch out this space for updates.