Debugging Warnings in Tests

| Comments

Object#id will be deprecated; use Object#object_id

Hate seeing warnings in your test output? Yeah me too. Came across a fairly weird bug today and this is how I debugged it.

Hello jQuery.PrettyTextDiff

| Comments

For some work I did recently, I had to produce a visual diff of text. A visual diff makes it easy for the user to understand what exactly changed with a quick scan.

There’s an excellent library from Google, called diff_match_patch that does a really good job of analyzing the text and producing the diffs in a programatic manner. However, it lacks the sauce to visually present it to the user.

So I wrote a jQuery library which is a wrapper around Google’s library and makes it trivial to wow your users.

State of E-commerce in India

| Comments

So, since moving back to India 4 months ago, we’ve trying to buy stuff off the internet, like we did back in Seattle (oh Amazon), from diapers to audio CDs (whaaaat? I know). While the world is much much better compared to 2006, there are still some Idiocracies in the UX and process. There are the big players (FlipKart, infibeam and the like) where (from the 4 months experience) you’d find what you are looking almost 6-7 times out of 10. The long-tail of e-commerce in India is the real deal though – the tail is really really long. I use to find the long time and almost always (9+ out of 10) the things I am looking for are found somewhere. Funny thing is that you’ll never find two things you need in one site. Over these 4 months, I don’t think any of these sites have come up more than once in my search.

Emacs: Change Fonts Dynamically Based on Screen Resolution

| Comments

I regularly switch between a Thunderbolt display at home and the Mac’s native retina display when I’m in a coffee shop or the like.

It bugs me that I have to adjust emac’s font manually when I switch displays – started “re-using” emacs again last week. So I automated this today:

Allowing and Testing CORS Requests in Rails

| Comments

I’m currently writing a backbone-based Javascript app that’s going to directly call a REST-style API (implemented with Rails ).

CORS (Cross-Origin Resource Sharing) is new technique makes it possible for AJAX requests to directly talk to HTTP-services outside it’s own domain. Read this awesome primer to read more on CORS.

While there are lots of examples that show how to allow CORS requests in Rails (just google), they almost never have tests with them. While it’s simple to test the HTTP headers, you may have to look around a little (or a lot) on how to test a HTTP “OPTIONS” request. When you make CORS requests, the browser may make a pre-flight “OPTIONS” request to verify that the server allows CORS.