Reflections on Spring 12

Wow. I guess I’m a senior now. Feels a bit strange to be honest. I’ve grown a lot these past three years, and I can’t wait to see what my last year at UIUC holds. I feel that my next two semesters are going to be as crazy as Spring 12 was. I’m pre…

Wow. I guess I’m a senior now. Feels a bit strange to be honest. I’ve grown a lot these past three years, and I can’t wait to see what my last year at UIUC holds. I feel that my next two semesters are going to be as crazy as Spring 12 was. I’m pretty sure I will be taking 18 credit hours each semester, and am also looking to do some research. 

Let’s talk a bit about Spring 12. CS 473: Algorithms was AWESOME. It was a lot of hard work, but the material that I learnt in that class is invaluable. My favorite topics had to be Greedy Algorithms and Dynamic Programming. There is just something beautiful about these two topics that appeal to me. In CS 440: AI, I enjoyed our discussions about Bayesian Networks and HMMs tremendously. I’d come across these terms before but could never fully understand what they meant, or why they were used. 440, and it’s book, changed that. I also improved my Python skills in this class since I did all the programming assignments in Python. CS 421: Compilers was another great class. I came into the class not caring much about compilers in general, but along the way I developed an appreciation for language design, parsers, interpreters and compilers to such an extent that I’m considering taking more advanced compiler classes before I graduate. 

The only thing that disappointed me about Spring 12 was that I didn’t have the time to learn a new language/framework/database etc. Hopefully, I shall make up for that this Summer. 

 

Post Facebook Camp Hackathon, Pre Yahoo Open Hack All Stars 2011

Facebook held it’s Camp Hackathon at UIUC yesterday, and it was another great experience. Sam and I built a system to remotely control your iTunes music library via text messaging, a web interface and voice. Technologies used were Python, PHP, Twi…

Facebook held it’s Camp Hackathon at UIUC yesterday, and it was another great experience. Sam and I built a system to remotely control your iTunes music library via text messaging, a web interface and voice. Technologies used were Python, PHP, Twilio and NodeJS (NowJS and Express). I’m a huge fan of NowJS, it’s an excellent product that makes realtime communication in NodeJS so much simpler, and it opens up a world of possibilities in terms of applications that can be built. It’s the fourth time I’ve used this library, and each time it’s elegance blows me away. The same holds true for Express.  Robust and easy to use (though we didn’t use it heavily for this project). All the text messaging stuff was handled via Twilio, another service that I am a huge fan of. 

Heading out to New York tomorrow for the Yahoo Open Hack All Stars 2011. I’m super excited for this event and can’t wait for the competition to begin!

Snip: pastie.org clone using Express and Redis

I’ve been wanting to learn and write something using Redis and Nodejs for the past few days. While scouring the Internet for knowledge I came across this article that describes how to implement a simple pastie.org clone using Redis and nodejs. I u…

I’ve been wanting to learn and write something using Redis and Nodejs for the past few days. While scouring the Internet for knowledge I came across this article that describes how to implement a simple pastie.org clone using Redis and nodejs. I used this article as ‘inspiration’ and modified their sample application.

Instead of using Nerve for routing and returning html in the form of a string, I decided to use Express to build the application and Jade for the templates. I also replaced Pygmentize, used for syntax highlighting, with a Javascript syntax highlighter. Lastly, I swapped the Redis module ‘redis-client’ with the recommended ‘redis’ module instead. I then rewrote the application using these new tools.

Code is here. 

 

Linkedin Intern Hackday

WOW. That is pretty much all I have to say after getting back from the Intern hackday. The sheer level of technical wizardry on display was ridiculous. There was a VNC client implemented in Javascript, a multiplayer capture the flag game that used…

WOW.

That is pretty much all I have to say after getting back from the Intern hackday. The sheer level of technical wizardry on display was ridiculous. There was a VNC client implemented in Javascript, a multiplayer capture the flag game that used nodejs + WebGL, a webapplication that allows you to share files by ‘streaming’ it to another user (no storage on an intermediate server) written in Django … all in all, absolutely amazing. Sam and I built a web based AI, called ‘Sherlock’. We used a homegrown audio recorder + chunker written in Python, Google + Bing + Qwiki APIs and NowJS for server-client distribution. I was really happy with how our application turned out in the end, it looked great and functioned pretty well. We made the final 15 (out of 45 teams) and I am really proud of what we accomplished over the course of 16 hours. 

For the curious, the winners were: 1st prize was the capture the flag game, 2nd prize was taken by Linked Out (an application that used data available on Likedin to predict who will change jobs) and the 3rd prize was grabbed by the Django-streaming-file-sharing application (they called themselves Beamit). 

#inday, I shall miss you.

 

On Django

A week or two ago I started learning Django, and wrote my first app, a simple contacts book thingy. Right from the get go, I was amazed by how everything felt so natural in Django, at least to me. The MTV pattern seemed really intuitive and I had …

A week or two ago I started learning Django, and wrote my first app, a simple contacts book thingy. Right from the get go, I was amazed by how everything felt so natural in Django, at least to me. The MTV pattern seemed really intuitive and I had no problem diving right in and creating an app. The Django documentation is extremely well written and answered all the questions I had while coding. Even though I was creating my first Django app, I had no problems in incorporating generic views, model forms, pagination etc. In order to have database migration support (yes, I kept changing the schema even for a simple app :p) I installed South and everything was smooth sailing from there. The last thing I want to add to the app is search capabilities, and for this I’ve decided to use the Haystack application. I’m pretty sure this is overkill for such a simple app, but I wanted to try out this application and hence decided to throw it in.

After working with Django, I’ve decided to go back and give Rails another go. I’ve almost completely forgotten all the concepts from Rails, and I would love to refresh my memory. 

Mozilla World Series of Hack

Sam and I took part in Mozilla’s World Series of Hack held on 7/22/11 7.30pm to 7/23/11 7.30am. The rules of this contest were slightly different from previous hackathons I’ve attended: contestants were allowed to start work on their projects as e…

Sam and I took part in Mozilla’s World Series of Hack held on 7/22/11 7.30pm to 7/23/11 7.30am. The rules of this contest were slightly different from previous hackathons I’ve attended: contestants were allowed to start work on their projects as early as 7/15. They would then have 12 hours to work on it during the event and then they must demo at 8.00am. 

Sam and I had an idea that we started working on sometime around 7/19, but on the day of the competition we decided to completely change our idea and build something in the 12 hour period.

We wanted to implement a turntable.fm clone in 12 hours. Our concept revolved around a social music experience, where peers (users) connected to hubs (channels) and within a hub they could play music that would be heard by all peers connected to that hub. Each hub would have a ‘now-playing’ queue and songs added by peers would get added to this queue. Everyone present in the hub could also chat with other users present in the hub.

We implemented our idea using node.js, making heavy use of the awesome NowJS library for communication between the server and the clients. All audio playback was handled using html5.

NowJS is a wonderful library, and it was no suprise that a LOT of teams at the event took full advantage of it’s capabilities. The guys from NowJS were also at the event and were super helpful. 

Overall, the event was a great experience, and I learnt a lot in 12 hours. Kudos to Mozilla and the engineers from all the other companies who helped make WSOH kickass.

 

Tweet streamer using Node.js

A day or two ago I decided to learn Node.js and was looking for tutorials and articles on the internet for the same. In my quest for knowledge I came across this tutorial that talks about building a real-time tweet streamer using Node. Unfortunate…

A day or two ago I decided to learn Node.js and was looking for tutorials and articles on the internet for the same. In my quest for knowledge I came across this tutorial that talks about building a real-time tweet streamer using Node. Unfortunately, the code as presented on the website doesn’t work, I guess due to changes in the Node API since the tutorial. After a bit of researching and digging around in the Node API docs, I managed to produce a version that works.

Be warned though, this application makes a LOT of requests to the Twitter API resulting in your application being banned for an hour from using the Twitter API. Also, this is the first node application that I have written, so I might be making a lot of beginner mistakes. Please forgive me for this. The goal of writing this application was to have a working version of what was presented to us in the tutorial.

The version of node I am using(based on the output of 'node -v') is 'v0.5.0-pre'.

Here is my code.

All your __import__ are belong to us

Everyone knows and loves Python’s import function. This function is used to import external modules into the current module/script we are writing. Here are a few simple examples illustrating how the function can be used: Internally, a call to the …

Everyone knows and loves Python’s import function. This function is used to import external modules into the current module/script we are writing. Here are a few simple examples illustrating how the function can be used:


# import a specific module
from vehicle.four_wheels import car
my_car = car.Car(transmission="automatic")
# import a specific class within a module
from vehicle.four_wheels.car import Car
my_car = Car(transmission="automatic")
# import everything from a module into the current namespace
from vehicle.four_wheels import *
my_car = Car(transmission="automatic")
my_bus = Bus(color="Yellow")

view raw

gistfile1.py

hosted with ❤ by GitHub

Internally, a call to the import function makes a call to the built-in __import__ function. However, there are 2 cases where using import would not work and the only way out is to call __import__ ourselves.

The most common case where we would have to call __import__ directly would be when we want to import specific modules at run-time based on user input. Here is how we might do that:


# global scope these variables so that
# we can use them throughout our code
Car = None
Bus = None
#
# exciting stuff happening here
#
# now, based on the variable vehicle
# we want to import a specific module
if vehicle == "car":
# equivalent to: from vehicle.four_wheels.car import Car
_Car = __import__("vehicle.four_wheels.car", globals(), locals(), ["Car"])
Car = _Car.Car
if vehicle == "bus":
# equivalent to: from vehicle.four_wheels.bus import Bus
_Bus = __import__("vehicle.four_wheels.bus", globals(), locals(), ["Bus"])
Bus = _Bus.Bus

view raw

gistfile1.py

hosted with ❤ by GitHub

Yes, I know that we didn’t really have to import at run-time in the previous example. It was just meant to be a simple example 🙂

Another case where we might have to call __import__ is when, for some reason, the parent modules/folders for a module we want to import or a module itself has a name with characters that are not allowed by Python. For example, something like the snippet below would not work:


# this does not work!
from vehicles.fourwheels.car import Car

view raw

gistfile1.py

hosted with ❤ by GitHub

Notice how the hyphen is not allowed in the module name. Here is how we might work around that:


# this works!
_Car = __import__("vehicles.four-wheels-car", globals(), locals(), ["Car"])
Car = _Car.Car

view raw

gistfile1.py

hosted with ❤ by GitHub

California!

I’ve been in California for 3 weeks now and I’ve been having a blast! Work is great and being with friends and family is always a good time. I’ve started work on my secret project, but have been having misgivings about it since yesterday. More spe…

I’ve been in California for 3 weeks now and I’ve been having a blast! Work is great and being with friends and family is always a good time.

I’ve started work on my secret project, but have been having misgivings about it since yesterday. More specifically, I’m concerned about the fact that what I’m building is not how I pictured my idea. I’ve decided to stop development for a few days and think more seriously about the purpose of the application. I think I have a good idea, it’s just that I feel that I’m not executing it correctly. In the meantime, I’ll be working on the other items on my Summer to-do list. Also, I think I’m going to take up running on the days that I don’t bike to work 😐 

My Ubuntu Setup

I’m currently running Ubuntu 10.04, and will update to 11.04 in a week. Since I started using Ubuntu over a year and half ago I’ve found a few apps that I now absolutely cannot live without. Here is my attempt at listing most of them, in no partic…

I’m currently running Ubuntu 10.04, and will update to 11.04 in a week. Since I started using Ubuntu over a year and half ago I’ve found a few apps that I now absolutely cannot live without. Here is my attempt at listing most of them, in no particular order:-

tig: Text based gui for browsing git repos. 

ddd: For when command line gdb is just not enough. Used it extensively during my CS 241 course, especially for the programming assignment in which we had to implement malloc(); pointer arithmetic can get messy quickly 🙂

gvim: I’m a huge (g)vim fan! I adore this colorscheme, and you should also get this for painless folder navigation within (g)vim. 

Dropbox: Ever since my old laptop died on me and I lost all my data, I’ve started to become super cautious with regards to backing data up. That’s where Dropbox comes in and simplifies my life. I’m a huge fan of their service and the way syncing with multiple devices works so seamlessly. 

vlc: for when you need your media fix. 

Ubuntu Tweak: makes customizing your Ubuntu setup a breeze. 

Cheese Webcam Booth: My choice for a webcam software. 

xpad: Allows you to put sticky notes on your desktop, very similar to the notes widget in Windows 7

Faenza icon set: It’s pretty. Oh, so pretty.

htop: It’s like top. But better. 

That’s all I can think of right now. I’m petty sure I’m missing a few so I’ll be editing this post as and when I think of something.