Thursday, September 20, 2012

On Leaving India!

Warning: This is a random rant. And some of you may not be ok with the attitude of this rant.

It's almost time and I'm all set to leave India for the first time and it is probably for my good. It is a bit ironic that of all people I've been the one chosen to leave the country at such an early stage of life. As my email id goes, few months back, i had the least idea that i would go out of the country and that too as a long term business. Nevertheless, it's hard to turn down when your lifelong dream calls you to make a choice between itself and the country you love.

I've been known among my friends and family to often pass off niche comments whenever I'm asked about going to another country for a long term. And truly, by heart, even now i cannot think of settling down permanently in country other than India. So I've been in extremely mixed emotions about this. I'm not saying it was a hard choice to make, the choice i had to make was damn easy. But somewhere in the corner of the heart it pricks a little bit as i am actually about to go through with it. Nevertheless I'm damn excited on this new phase of my life. It has really moved very fast so far.

As most of you might already know, I'm now formally engaged to my long term girl friend Gayathri. She is the most amazing human being I've ever met in my life. So naturally, this adds even more excitement to my trip given that marriage is around the corner. In a way, I'm more excited about coming back here for marriage than about going there and taking up my first job.

Personally this journey is a big step for me as I've never gone beyond South India most of my life. Bangalore and Hyderabad have been my borders except for one Delhi trip during college. So I'm half excited and half scared to face the new geography, new culture and what not. Everything is a bit overwhelming, I'm gonna be staying right across the road from Stanford for my first few weeks there.

Off late the only question I'm being asked by everyone is "Are you gonna permanently settle down in the US?". I really don't know the answer for this question. All my life i never thought I'd set foot in another country for a long time. But here i am all excited about how things have turned over in a few months. So I'm not really in the mindset of planning for the long term. Deep down the heart i wish to be back in India sometime in the future.

I'll conclude this almost pointless rant by saying i will miss a lot of things about Indian lifestyle but I'm looking forward to the most important phase of my life and I'm not a least bit sad about it not being in India.

And hey, I'm getting married on March 4, 2013 in Chennai. I will surely invite every one of you personally later, just book your calendar for that date right away :-)

-Vignesh

Wednesday, July 11, 2012

Serverless Downloads - HTML5 Awesomeness!

HTML5 brings an awesome feature known as client downloads. At first glance, the term "serverless downloads" may sound oxymoronic, but it sure makes a lot of sense. In the HTML5 era, we write a lot of thick clients. All the day to day web apps which we use are damn thick (Gmail, Facebook, etc.). So in the context of thick clients, serverless downloads make a lot of sense.



Content-Disposition HTTP Header

On the web 2.0 days, when you wanted to force a browser to download a file to disk rather than displaying it (especially if the file is of some format which the browser is capable of rendering), you used to set the Content-disposition header in the HTTP response.
Content-Disposition: attachment; filename="sample.txt";
There is no way for the browser to let the user download the file without contacting the server, even if the contents of the file were to be generated totally on the client side.


The Problem

This is old school. These days there are lot of web apps where you create the data on the app itself. For example, consider Google Docs, you create all sorts of documents on the web. Every time you click the download button, the data is sent to the server and the same data comes back along with required filetype's additions and you see the download dialog box.

This step seems too radical and unnecessary. Given how thick the clients are these days, it is atrocious to send some data to the server and get back the same data as a file from the server. The same holds for all sorts of web based photo editing apps, etc.


The Solution - "download" attribute

Now with HTML5 it is possible to generate a file on the client side and make the user download it without contacting the server at all. The simple addition of "download" attribute to the anchor(a) tag will tell the browser to download the content present in the "href" attribute rather than navigating it. Now, this can be combined with a "blob:" or a base64 encoded data url to create a file and download it, all on the client side.

I have put up a demo where you can enter text into a field and then download it as a pdf.

Demo: http://garage.foamsnet.com/static/pdf.html
Image Courtesy: http://www.html5rocks.com

-Vignesh

Saturday, June 23, 2012

Convert your keyboard into an Android game controller!

I have been gifted with a new android phone. It's the big G branded Galaxy Nexus. Its blazingly fast and awesome to use (especially after years of HTC Wildfire usage). Right from day one, i have been really addicted to this game called Temple Runner which wasn't compatible with my old phone.

The game is very straightforward to play and it involves only 4 different operations. Swipe up, left, right and down. Coming from a strong keyboard background, I was never 100% comfortable with touch interfaces as i was with keyboard. And these 4 operations sounded analogous to the accelerate, brake and turn operations while playing a racing game in the computer keyboard.

That got me thinking, is there a way to make the computer keyboard into a game controller for my Android phone? Turns out its fairly straightforward. In this post i'll explain exactly how to do that.

Ingredients
  • Android phone (obviously)
  • USB cable connected in debugging mode
  • Android SDK installed
  • Very very basic python english
There's a tool named monkeyrunner which enables us to send operations from the computer to the phone via a very simple Python API (monkeyrunner tool is a part of Android SDK). A sample code for a controller would look like this:

Code until line 7 is fairly straightforward to understand. The only thing that i would like to explain here is the device object. It is an object of the MonkeyDevice class. This class has all the API methods that you need to use in order to simulate the operations. For example, device.touch(100, 200, MonkeyDevice.DOWN_AND_UP) will simulate a touch event at co-ordinate 100, 200 (with the origin being top left). As simple as that!

You can find the detailed documentation of the monkey device class to know about other methods like drag, type, etc.

The full code which i used for playing Temple Run game is given below:


One point to note is that, the sys.stdin.read(1) line will read one character and wait for the enter key to be pressed. This could be annoying given that you are writing a game controller. In order to avoid the enter key press, if you are on linux run "stty raw" before running this script and if on windows use the getch function in msvcrt module.

-Vignesh

Friday, May 25, 2012

I'm Feeling Lucky!

I have completed my college life. No more exams, no more results, no more bunking first half and sleeping and lots of other things will be no more. At this point, I want to take some time out, share the experience of my amazing roller coaster ride and thank the people who mattered and have helped me get where I am today (and where I will be in a few months :-P).

The Dream

Just like every computer science student, I had a dream too. My dream started along a bit early. Right from my school days, I had two role models. I had only one dream. I found a few 6 year old messages in my gtalk log where i was cribbing to my friends about my dream of working at my dream company at its headquarters.

The Start

I got through a really good job during my on-campus placements. It is at this point most people get carried away, but somehow i managed to not fall into that trap and thereby miss my dream. I chose to do my final semester internship in another company so that I will have bandwidth to explore other options. Btw, the workplace where I am doing my internship is awesome (this place is so awesome that I just can't stop boasting about it whenever I talk of internships).


Ok coming back to the topic, naturally the first step was to prepare for other companies' interviews. I started doing that and decided to apply to a company by end of March. Thankfully, one of my friends knew a person there who could refer me and get me an interview (btw, my friend happens to be a really wonderful human being who has helped me whole heartedly whenever i needed any help. He also happens to be my college senior and i am heavily indebted to him!). Off went my resume into the company and i got an automated "thank you for your interest in us" email.

The Phone Call

Then the recruiter called me and was ready to set me up with interviews beginning with a phone screening. I was told I would get a call by 11 AM. The interviewer had some issues in dialing in my number so it got delayed by 10 minutes. One of the worst 600 seconds of my life where I was tensed to the core. Once the interviewer called me, time flew off. Einstein was right.

I felt quite confident. Eventhough i didn't nail the interview, I felt it was far away from being tagged along a tweet as #pathetic. Few days later, I got an email from my recruiter stating that I have cleared the phone screening and will have to visit their office in Hyderabad for on site interviews.

The Visit

I was plagued with sickness and was in a severe low health for a few days before the interview. They flew me from Chennai to Hyderabad on the evening before the interview. I have been informed that I would be picked up by a cab as soon as I landed at Hyderabad. That was the first "awe" moment of the trip. The cab driver was standing at the arrival lounge with a placard that had my name.


I couldn't have dinner that night, couldn't have breakfast on the day of the interview. Somehow i reached the office. The first thing I noticed was the sheer enormity of the Hyderabad office. It was just too good.

Thankfully Air India was flying that day!
Once I reached the office, I had to have a sticker with my name printed on it (a temporary id card sorta thing). Since it wouldn't stick to my t shirt, i had to stick it around my arm like a watch!



And then there were 6!

Then started the interview process. There were 6 rounds each comprising of 45 minutes to one hour. I had a lunch break in between for half hour and eventhough i couldn't eat much (because of my illness), i was totally mesmerized by the food court that they had. The interviews were over around 6 o clock in the evening and I came back to Chennai the same night. It was a long day and i was totally down with illness at the night.

The Wait

Next came the worst part, waiting for the results. I don't know what to write in this column, but there a few things and people that helped me overcome this strenuous period. My work at internship gave me some distractions but night times were a nightmare where I barely slept for 2 or 3 hours.

The Surprise

Then came the call on 17th May, stating that I have gotten through and that I will be intimated about the work location in a day or two. I was wonderstuck, I had no words to describe what it meant to me. I mean, it was my dream ever since from when I was at school. Fortunately, I was with the people I love when the call came and I could not have been more happier.

As it turns out, the call on May 17th wasn't the happiest moment in my life. That came a few days after, when I received my offer letter. It was a totally unexpected freaking surprise. My salary was mentioned in US dollars. I was searching the letter to know my work location (as I was most eager to know whether the work location would be Bangalore or Hyderabad). When I found it, my heart just froze, I mean, it just froze. It was my dream location. It was what I dreamed about in my school days. It was whose pictures I posted in Orkut years back when it was my dream.

It was a DREAM COME TRUE !

The People

None of this would have happened if not for the really supportive people around me. I have an amazing set of F.R.I.E.N.D.S from college and school. I really owe them for all their support over the past howmanyever years I have known them.

Another bunch of people whom I really owe a lot are my friends in twitter. It was one of the main reasons why I was able to achieve my dreams. Every discussion (the technical ones) I had in twitter had been a value addition to me. When I think of it, few people come to my mind immediately. Thanks a lot guys, eventhough we've hardly met in person, you are a vital part of my life.

Thanks are due to my parents who have been alongside me for every single decision I took in my life. They trusted me totally and I hope I have justified that trust to a certain extent now.

Apart from them, I sincerely thank all of you who have been a part of my life over the past 22 years. Without you people, I will not be where I am today.

Conclusion

I am joining my first full time job in a few months. I am living in dreams when i think of the fact that i am going to be working in the same place where people like Prabhakar Raghavan, Matt CuttsGuido van RossumJoshua BlochRobert Love (and not to mention Larry Page and Sergey Brin) work. My life cannot be more close to perfect than it is now. Once again, I sincerely thank each and every one of you!


I'm Feeling Lucky!

-Vignesh

P.S.: I have not mentioned about one very important person in this post. That is completely intentional and the reason for that being lack of words to describe what that person means to me. :-)

Sunday, April 8, 2012

Pre School Problem - A programmer's approach!

Flashback - A few weeks ago

I came across this question in facebook. It said, "This problem can be solved by pre-school children in 5-10 minutes, by programmers in 1 hour, by people with higher education.. well check it yourself :)"



I shared this post and we had few nice sessions of fun with my colleagues in office. Myself and a colleague of mine were discussing about this and i told him, "the best part about this puzzle is that it cannot be solved programatically". And we carried on with our lives.

Train Journey - Last night


Last night when i was travelling by train, I had gotten a side lower berth and hence couldn't sleep (i have grown too tall to fit in to side berths :-( ). So, i had to while away time. I was tweeting, finished through a couple of stanford algo and nlp class videos. Then i had nothing to do, phone was almost running out of charge and so was the laptop. So i closed everything and started staring outside the window. Various thoughts came across, and one among them was "is there no way to programatically solve that facebook puzzle?".

Thus I started thinking about it, the first solution that came to my mind was to convert the numbers into a linear system of equations and apply linear regression on it. Then, the value of the co-efficients would give the mapping between a number and how we arrive at the solution (explained in detail below).

Coding Session - Today


I came home had a nice sleep. When i woke up, the first thing i wanted to do was to test out if my theory works. Obviously python (numpy) was the toolkit in my arsenal that would help me do this quicky. So here are the steps:

  • Convert the input number into co-efficients of 0 or 1. For example, 2172 would translate to [0, 1, 2, 0, 0, 0, 0, 1, 0, 0]. (i th element denotes the number of times number i occurs).
  • Now we have the coefficient matrix ( of size n x 10 where n is the number of inputs).
  • We also have the constants column vector which are the known outcomes
  • Now, we apply linear regression on this system to get the output
  • Output will be a mapping between a number and how much it contributes to the output (0 maps to 1, 1 maps to 0, 2 maps to 0 and so on.)
  • So to compute the outcome of a new number, merely sum the mappings of the digits in that number.
The whole program is embedded below:


The output of the program is:
['0 maps to 1', '1 maps to 0', '2 maps to 0', '3 maps to 0', '4 maps to 0', '5 maps to 0', '6 maps to 1', '7 maps to 0', '8 maps to 2', '9 maps to 1']
As we can see, that's a perfectly valid mapping!

Moral of the story:
  1. Mathematics is really powerful. 
  2. We can teach a computer much faster than we teach a pre-school kid. ;-)


-Vignesh

Monday, February 27, 2012

DOMCA - Days of my lives!


Note: This is a personal article about my college.

Department of Mathematics and Computer Applications, more commonly known as DOMCA within PSG Tech. It is the place where i spent 5 years of my college education. I have come across many students who have been a part of this department over the past 10 years, mostly through social media like twitter or facebook. But nowhere have i seen an article/post that talks about the fame and pride of this department. So I decided to do that part and this article is my small contribution to the department where i lived for 5 fun filled years.





To begin with, the department offers 4 masters programmes none of which is a BE/BTech/ME/MTech programme. Now, its really tricky to be in an engineering college, especially one of calibre as high as PSG Tech, and to belong to a department that doesn’t have an engineering programme. There will be a lot of internal politics and complexes going on among students between engineering and non-engineering stream within the college, and obviously DOMCA’ites find themselves in the minority (as there are around 15 to 20 different engineering programmes compared to 4 programmes in DOMCA).




But despite all that, the department have managed to produce students of world quality (yes, you read it right, i said “world” quality) excelling in mix of qualities. Its more of a “you name it, we have it” kind of place. Starting from the orientation talk on my very first day, to the last hour of class I attended and the last exam i wrote in my 5th year, i thoroughly enjoyed every single moment i spent in the department.




Key #1 to any department is their students. None of the programmes offered by DOMCA admits students through the government’s single window system, which means there are no school level state toppers in DOMCA. Yet, we somehow manage to groom ourselves through five awesome years of college experience that gives you an example for almost every possible situation that you would ever face in your life.
Key #2 to any department is their faculties. I am not going to claim that all the faculties are awesome. Some of them are really top notch (by this, i mean "world" class). Some of them are lame. But what makes DOMCA faculties unique is their willingness to learn, their willingness to teach us what we want rather than teaching us whats prescribed in the syllabus.
An even more important factor that decides the success of any department is student-faculty interaction. This is something that i personally think DOMCA nails to perfection. All faculties are friendly. Some of them, "literally" friendly. Whenever you have a problem, academic or personal they are there to help you out. I can even quote some of them as best examples of purity by heart.





Every person who is at DOMCA right now, or who are going to be a part of this wonderful place, rejoice it. Your sophisticated office cubes can never match TCS Lab. Your super duper fast multi core giant machine in office can never beat the fun offered by the dabbas in CC. I really wish i could be back at the department some day.


There are a lot of shortcomings, but in the long run, you hardly remember the shortcomings as you remember the good things. So, that's where this post is coming from, all the good things i have been through in the past five years.


This may not be Carnegie Mellon. This may not be Stanford. But our hearts really are proud every time we quote that we are from DOMCA in PSG Tech. So, according to me and possibly many others who were a part of this wonderful department, this isn’t just a department where they teach you subjects, this is an ecosystem that has been built upon human values.


To quote Sheldon, “I love PSG Tech, But my feelings for DOMCA are much greater. It is the singular location in space around which revolved my entire universe."



-Vignesh

Friday, February 10, 2012

Social Photos - Move photos between Google+, Flickr and Facebook!

Introducing Social Photos - http://social.foamsnet.com



A spin off project from my earlier Orkut Deja Vu. This cool web app lets you transfer photos between Google+, Facebook and Flickr using an intuitive drag and drop interface.




Do check it out and leave your feedbacks! :) Once again, the URL is http://social.foamsnet.com

-Vignesh