Winning a Trip to The Googleplex

I just won a free trip to the Google Headquarters. How did I do it?

For the last three years, Google has run an international programming competition, Google Code-In, for pre-university students between the ages of 13 and 17. There are ten open-source software organizations that take part and create sets of programming tasks, usually requiring the student to write a small amount of code. After completing one task, students earn a certificate that will be mailed to them. After completing three tasks, students win a Google t-shirt.

What’s most interesting, however, is the grand prize. Each of the ten organizations name two students as grand prize winners, making a total of twenty winners. A winner receives a four-night all-expenses-paid trip to Google’s headquarters (a.k.a. The Googleplex) in Mountain View, California. The winners get to speak with Google engineers, tour Google, visit San Francisco, and receive additional prizes (swag); last year’s winners each received a Galaxy Nexus smart phone!

When I discovered this competition on December 1st — a few days after it began — I thought “well this would be a fun way to win a free t-shirt!” And so I began contributing code to a game called Hedgewars, completing tasks. Within a few days, I earned my shirt, but I didn’t feel like stopping. I didn’t even have the grand prize in mind; I was making significant contributions to the game and its main developers were loving my work. It was too rewarding to stop.

Read this article

Real-time User Count Without Any Javascript

Live Demonstration

IP cameras are frequently streamed as M-JPEG over HTTP connections. Why not use the same principle for other uses, too? Although M-JPEG streaming doesn’t work in Internet Explorer, it can still be useful.

The underlying protocol is simply a multipart HTTP request using the x-mixed-replace content type. Basically, the server sends the document (or in this case, image) multiple times, with each part replacing the previous part. So when an IP camera is streaming, it’s just sending multiple jpeg images that each replace the previous image.

It looks like this:

HTTP/1.1 200 Ok
Content-Type: multipart/x-mixed-replace; boundary=--icecream

--icecream
Content-Type: image/jpeg
Content-Length: [length]

[data]

--icecream
Content-Type: image/jpeg
Content-Length: [length]

[data]

--icecream

(and so on)

Read this article

Trying out Box2d

Dominoes falling towards a house.

What is Box2D? It’s a free and open source 2D physics engine. It is developed with C++, and has fortunately been ported to many other languages, including Actionscript and Java. I was eager to try it out.

At the same time, I was eager to get more familiar with the new C++11 standard I’ve been hearing about (a.k.a. C++0x). So I made a small program to get a taste of Box2D and C++11 features. You can view and download the program here.

To use it, drag out a rectangle with your mouse. When you release the mouse, the rectangle becomes a object in the world. It is affected by gravity, and interacts realistically with other objects. If you happen to own a touch screen, you can press space to hide the mouse cursor. You’re welcome.

Mixing Box2D with SFML graphics was a quite tricky. To keep track of the objects, I created an std::vector of this struct:

Environment.h:19 (rev f3238b80)
typedef struct {
    shared_ptr graphic;
    shared_ptr body;
} PhysicsObject;

There was a problem though: The Box2D world’s coordinates are 1 unit = 1 meter, and the Y-axis increases upwards. SFML coordinates, however, are more conventional computer graphics coordinates: 1 unit = 1 pixel, and the Y-axis increased downwards. To add to these troubles, the SFML view (sf::view) has to be able to scale (zoom) and move around the world.

Read this article

Storing Digital Data on an Audio Cassette

The cassette recorder hooked up to my computer's front audio ports.

A few days ago my dad bought a simple audio cassette player/recorder to make a digital copy of an old tape recording he had of Pioneer 10 leaving the solar system. I had the opportunity to try something I always wanted to try: Storing data on an audio cassette. After some researching, I decided to use RTTY (Radioteletype). I found an awesome program called Digital Master 780, which is part of a freeware Ham Radio software package, Ham Radio Deluxe.

To connect the tape player, I needed to use two 3.5mm TRS cables, one for my computer to hear the cassette player’s output, and another one to send audio to the player’s audio input for recording.

My DIY 3.5mm TRS cable from two earphone cables.

Since I only own one cable, I made a second one by using two old earphone wires, wire strippers, two alligator clips, and tape. It looks messy, but it gets the job done!

For reading and writing digital data to the tape, I tried out several audio formats that the program could use. Due to the low audio quality that the tape can store, I was only able to get away with using RTTY. After further experimentation, I decided that these are the best settings I can use:

    100 Baud, 170 Hz shift, 7 bits (ASCII), 2 stop bits.

Success! Here’s a video of me writing two paragraphs of “Lorem ispum” text to the tape:

Read this article