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:

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:

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:

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

TDD

I read about TDD and it’s associated red-green-refactor cycle while learning Ruby on Rails and I was quite intrigued by the concept. It seemed like a novel way to approach programming. From what I read on the Internet about it, it also seemed to r…

I read about TDD and it’s associated red-green-refactor cycle while learning Ruby on Rails and I was quite intrigued by the concept. It seemed like a novel way to approach programming. From what I read on the Internet about it, it also seemed to reduce bugs in the code and generally leads to better, more human understandable code.

So, when we were given our first programming assignment in CS 241, I decided to approach it with the TDD mantra. Programming this way was a great expirience, once I had come up with enough test cases for my assignment, programming it up wasn’t too hard because I had already captured all the edge/unusual cases. 

All in all, I was satisfied with this approach, and I will most definately be using it again for future assignments when possible.

And then there was one less

So I decided to drop my CWL 114 class, not because I didn’t like it, but because I realized that I do not need to take two gen-eds this semester to graduate in time. Following the advice of one of my friends, I mapped out my tentative schedule for…

So I decided to drop my CWL 114 class, not because I didn’t like it, but because I realized that I do not need to take two gen-eds this semester to graduate in time. Following the advice of one of my friends, I mapped out my tentative schedule for the next 4 semesters and came to the conclusion that 18 credit hours this semester is not required. I am now back to a happy 15 credit hour schedule 🙂

Consequently, I now have my Tuesdays and Thursdays (almost) free. I plan to invest that time into expanding my current technological skill set to include(as of now) Python and possibly Django. I also want to spend more time with Ruby and Ruby on Rails and possibly build an application using it.