Monday, June 13, 2011

ShinyCar into MicroJS

I got a small localStorage HTML5 library I wrote into MicroJS, its called ShinyCar.

ShinyCar is very simple, it lets you set objects as keys and values of HTML5 localStorage with JSON, and it lets you either have functions for this, or, you can add this functionality to your localStorage object. Its very simple, not many LOC, but, I have used it a lot, and will continue using it in the future.

Fork me at Github!

Experience with Writing a Chrome Extension for Flipkart, Flipkart API

Even though I live in the USA, my family and I maintain contacts with India and often visit. And, when I am there, I have started using Flipkart to order books, and I find it quite a bit cheaper than competitors.

I also want to quickly look up books, see results and availability on Flipkart, and, I also use Google Chrome (and Firefox, but, I'm moving to Chrome slowly). So, I wrote my first Chrome Extension, and I will try to describe my experience.

Right off the bat, the introductory tutorial was excellent, and I was up and running within 10 minutes. By this time, I had a very basic Flipkart extension going, and was pretty excited with the progress.

Ten minutes later, I ran into a small problem. I was trying to use the DOM to turn a button's value from "Search" to "Loading...", and I had written the code, but, it wasn't working. So, I tried to figure out how to debug it. For 20 or so minutes and bashed my head against the problem with console.log() statements scattered throughout the code. Then, I read the debugging tutorial which was also excellently written by the very clever people over at Google.

I have been a Firebug devotee, but, once I started moving over slowly to Chromium/Chrome, I am liking the developer tools more and more. And, for writing the chrome extension, I could use the developer tools. The debugger is very good, and the syntax checker is extremely useful. I had a ton of trouble getting AJAX to work properly without a ton of lag, and the developer tools have excellent AJAX debugging, and I had absolutely no trouble.

Now, for the bad parts. The biggest annoyance in developing the extension wasn't really chrome or any of that, it was just that I would have saved myself a lot of page scraping if Flipkart provided a simple API that let me access its product database, I think I might start a project, so I can write an external one. The next annoyance (completely unrelated to Chrome), was weak typing. Javascript just totally ruined my life on this project, because I was doing a few things very stupidly,
a) Not using jQuery
b) Using the "+" operator without type checking
c) Not properly looking at Flipkart's DOM before trying to implement code that uses it

This isn't Javascript's fault (except b, which the world hates it for), more like my fault.

All in all, writing a chrome extension was a very good experience, and I would happily write another, I just need any ideas you have :)

Wednesday, June 1, 2011

About me

  • I like computer science (algorithms are cool), here's what I don't like about it:
    • SQL
    • PHP (although this does get better with frameworks and OOP)
    • Objective-C (it turns a simple syntax of C into something very complicated)
  • Here's what I really like about it:
    • Algorithms 
    • Python
    • C/C++
    • Haskell and Lisp (I'm not very good at these, but, getting better)
  • I also like mathematics
  • Why?
    • It sharpens reasoning skills
    • I participate in mathematics competitions
    • OCW MIT is like a gateway drug
    • Mathematics problems (not exercises as found in most textbooks), are fun.
  • I'm also 13, so, I have more time to spend on hobbies than someone that has to work.