My Blog

Code Ninja

Apparently Amazon hires only ‘Code Ninjas‘. And so, I am one! ;-)

Here, you integer, take this! Hoo! Hah! :D


Launching TweetBytes

Proudly announcing my very own Twitter client, TweetBytes! Bursts of short spans of coding over four nights. Built using PHP, TweetBytes uses OAuth to connect users to Twitter, whereby the user need not reveal his password to the application.

Update: TweetBytes is now @tweet on txtWeb

TweetBytes facilitates Twitter access through text messages, and is a complete SMS based Twitter client. But I’ve put in enough effort to make sure it isn’t largely inferior to the web and smartphone clients. And well, it surely beats their ass up in the sense that it requires no Internet! Just carry it along in your phone, and access it from anywhere through text messages, thanks to txtWeb.

The front end development and the code for OAuth authentication took as much time as developing the back end features of the client. Check it out here.


Well, that was my first tweet from TweetBytes, and tweeting here gets as simple as sending @tweet This is my tweet to txtWeb. Update: A few more tweets here from some of my friends using it!




Update: TweetBytes has expanded to newer horizons after being published on the platform on 20th September 2012. Access it here.

I might have missed a couple of them, but I’m trying to archive tweets from others regarding the application. Thanks everyone!!


Surprising Milestone

To know that there are football fans out there in a cricket obsessed country like India is very heartening. My @Euro app for Euro 2012 published on txtWeb got 28000+ hits over a period of about 25 days.

Now put it front of any application that delivers cricket scores, and it would get absolutely dwarfed. But never the less, this was quite surprising.


Back To The 8-Bit Era

He who hasn’t had a taste of the classic 8-bit video gaming console in his childhood has missed out on some of the best things in his life. And if you are one of the few, there is a certain something that you must do. Just get back out there.

I’m not sure how exciting it would be for someone who hasn’t been through those days, but for me, those glorious days of gaming are something to look back and cherish. And it is so wondrous to go through it all over again. So nostalgic, that what flashes through me is those box of game cartridges that come in various colors and claim to hold one less than ten million games in each, that hyperfastidious adapter which had to be fixed at an angle so precise so as to keep the console running, the Reset button that had been misused a thousand times and the sheer brilliance of a hundred games encapsulated within each of those three-inch long chips. And not to forget those innumberable fights for the joystick, and the first taste of multiplayer gaming.

Thanks to Nintendo, though I can bet that the one which I had and the ones which we found in India was everything except Nintendo.

There is this emulator that I got from a friend of mine recently, and it’s been giving me immense joy. If you can relate to what I’ve said so far and if you don’t already have the emulator, you are going to be taking it off right away. And if you do not know what I’m talking about, I’m going to force it on you. I wish.

I have the entire thing loaded along with the emulator here. Just download, and run the VirtualNES exe. Open the games from the rom folder, and you’re good to go!

Some shots from some of those bloody awesome games. I don’t think I would have to name any of these.

I miss the gun.


Featured Live Scores App

And now they’re featuring one of my apps on the homepage of txtWeb!

Signs of rising popularity of the game of football in India. The young from the metros are already well into the game. Just a little more publicity, then my app would be used by a lot more people.


Blog Nomenclature

With all this difficulty around keeping my blog rolling, I thought about adding a Twitter widget by the side so that I can at the least voice out randomness once in a while.

Instead I’ve decided to keep my blog running in two streams, and just follow this rule: Push all the little ones into ‘Bits’, and move the blog posts into ‘Bytes’. The “Bits and Bytes” nomenclature.

This wasn’t the original idea, but now it works. :)


Inactivity and Activity

I must be the least frequent visitor of my own blog. Absolute inactivity for months. Or maybe not quite. I’ve actually been putting my site to some good productive use otherwise, and it’s already brought me some things, and enabled me to do a lot of things.

On the blog front, I probably get an average of half a visitor every month, or maybe a quarter, but when I visit my cPanel AWStats, I can see that I get an average of 2000 to 3000 hits per day, and occasionally much greater. 1600 unique visitors each month. I don’t know how much sense numbers make, but now that’s something to make me happy. And well, thanks to my hosted applications of various sorts feeding roughly 25+ applications on the Windows Phone platform and txtWeb platform put together.

I don’t know how January weirdly has much greater bandwidth usage, probably was around the time when I was uploading a lot of things and setting up the site.


And I attribute my inactivity on the blog to me being active on the other end, working with Internet Society,, Slum Soccer, BigFourZa and a few others besides managing the Computer Science Forum in my college, working on two projects as a part of the academic curriculum, and doing my usual experiments.

Overload. Zero time.

I’m not sure if I’m handling them right, but I can say that I’m able to manage. Applications. Websites. Ideas. Classes. I’ve earned through a few, and I’m just doing the rest as a service which I ought to be doing. But everything is a learning process, which is what encourages me to keep going.


Asynchronous Refresh

With the pace with which the web standards and technologies have been evolving, periodical page refreshes to fetch new data from the server has become a thing of history for quite a long time now. Everyone would remember times when pages used to refresh every minute or so when following the updates of a football or a cricket match on the Internet. And those of you who were observant enough would have noticed how things don’t work the same way anymore, and about how updates are delivered seamlessly without any signs of page reload.

I have been working on creating a simple Social Chat-Room for a college project assignment, and while in fact most of its coding is already done, I know the code that I have used is ugly and annoying, talking of how the wall of the chat room gets rendered. I have set the frame containing the display wall to refresh every 10 seconds using the following piece of code in the head section of the page.

Easiest thing to do. And ugly too.

And now comes along a real project, which gives me a good reason to start learning. I’ve got to work on developing a “Live Updates” module for this quite-happening football blog, BigFourZa, a blog about the Big Four of the English Premier League. Something which demands me to start learning. Something for which a continuously refreshing page isn’t going to cut it out.

Time for AJAX. Time for jQuery.

What this Asynchronous Refresh is about is making calls to the server-side document and loading its contents to make it available for dynamic rendering on already present elements in the currently loaded document without any whole page refresh as such. Say we have a page, scores.php, which reads entries from a database and displays it on screen. Now when we add new entries into the database, unless we force a page refresh, the new entries are not going to be displayed on the page.

What we can do with jQuery is asynchronously poll the scores.php from another page, say main.php, and display the contents of scores.php in it. The code of asynchronous refreshing is what is of our interest now, and so the main.php would be something like this:



The interval is set to 10000 msec, so every 10 seconds the function is called and scores.php is loaded inside the element <div> with id=myscores, of the currently loaded page, which is main.php. And that’s all it takes. Not to forget to include the source of the jquery.js in main.php. And anyhow, one flaw with this code is that it takes initially 10 seconds before the document is loaded for the first time. For this, you’d have to add this into the head section:

Now to debate, there are much better methods to achieve this than polling, but in terms of simplicity nothing beats polling.

If someone doesn’t have much of any problem with understanding the Document-Object-Model (DOM) of an HTML webpage, then the documentation that is available on the Internet for jQuery is alone sufficient to start playing with it. And for me, it really is time to get working with things. Maybe soon, I’ll be ready with a working prototype of the Live Updates, or with the updated no-shabby-code Chat Room for you all to see.


Personal Home Page

It’s been a while since I looked back into my blog, holding good with how I thought it would turn out to be. And it’s sooner than I anticipated, which is bad. But then I’ve come to a milestone here that’s encouraging me to get back to writing. 1000 hits to my site. Talking about blogs that get such a response each day, this isn’t anything to brag about. But it sure feels great.

A counter plugin that’s been installed is doing the job. And then there’s my own script that’s running everytime a page on this site is loaded. A simple PHP script. Implementing a counter is possibly one of the simplest things you could achieve with it, but its significance is not to be played down for the reason that the very existence of this language arised merely from the need for keeping visitor count. A 25 year old Rasmus Lerdorf, back in 1994, wanted to track the visitor hits to his personal website, and put together a set of Perl scripts and formed what he called as Personal Home Page Tools. And over the following years, the language was open-sourced which led to the rapid development and evolution of the scripting language what we now know as the PHP: Hypertext Processor.

Bearing a close resemblance to C++, anybody who’s learnt programming at school should be able to pick it up in no time. And the best of all is what you could actually do with it being a web-scripting object-oriented language. For how I began using it to just scrape data off the web, things in it turned out to be so elegant that it drew my interest and now I’ve picked it up quite enough to be doing all of what I do on it.

This language now, means a lot to me.


Underneath Facebook

A myriad of us spend a considerable amount of our free time on one site, Facebook. A few others might spend all their time, and there are a few who have already spent a lifetime. All of us know Facebook as how it appears from the outside. All information in our profile, wall, albums and pages, beautifully rendered in that blue and white layout. Friends. Photos. Status Updates. Comments. Likes. Videos. Apps. Games. Everything under one platform. Facebook has evolved to that point where it in itself has become as much a phenomenon as the whole Internet is.

For how it has become very much a part of our lives, it would do some justice for us to know a bit about how things work underneath.

I have been interning at this startup called QuiKast for the past two weeks, and as a part of my project over there it was required that I learn about Facebook. So while what I talk about in this post will no way be related to programming and development, I sure will come back with a post talking about a Facebook app. But now, let’s get to the Facebook Graph.

Now for all the people who don’t know what a graph is yet, a graph is a set of nodes connected by edges. The general representation of anything in a graph is with ‘objects’ acting as nodes, and the ‘relationship’ between two objects acting as an edge. I think that describes it in a fairly simple and concise manner.

Here is how things work. ‘Facebook’ is a graph. The whole of it. To some such a perception would sound absurd. But that’s how things are. Everything in Facebook is an object. Every piece of anything on Facebook is an object. You are an object on the Facebook graph. Your friend is an object on the graph. Your status update is an object of its own. Your photos are objects of their own. And what holds them together is the relationship between them, the edges, except that there are different kinds of relationships between different objects. The relationship could be something like ‘friend’, or something like ‘like’, or ‘tag‘, or ‘own’, or anything else you could think of. Probably this image is going to help you with the visualization.

Facebook Graph

That sure does make things a lot easier to understand. So Facebook identifies and knows certain kinds of relationships as I told you about. And the objects that interact can be virtually anything. Of course, it knows of people, pages, groups and apps but whatever it is, is a property of the object. And whatever the object is, is given an unique identifier. The object of my profile on Facebook has the ID 559736373. And the object of Mark Zuckerburg has the ID 4. The Facebook ID of the official page of Adidas is 182162001806727. And the ID of the Texas HoldEm Poker app is 2389801228. Now here’s what happens when I go and like Adidas. An edge is drawn between 559736373 and 182162001806727. And the relationship that describes the edge is ‘Likes‘. Suppose I upload a new photo. It is given a new identifier. And then there’s a relationship ‘Photo From‘ between myself and the photo. And then I tag a couple of my friends in it. Two new edges are introduced into the graph. Between each of my friends and the photograph. By the relationship ‘Tags‘. Even external objects residing anywhere on the internet is mapped onto the graph once it starts interacting with Facebook. Take for example the “Like” box that you see on the top right corner of this site. The first thing that happened when I added the “Like” box was that Facebook created an object for ‘’. Now the moment someone likes it, a new edge is drawn between them and this site.

I think we’ve come one step down now. It makes more sense to get looking into things with a more hands-on approach. Let’s start exploring the Facebook Graph. Externally. Not from within Facebook. Let’s visit And please do this through Firefox or Google Chrome. What do you observe? There you see the object of the page Internet Society. Now this is an object, and it has some attributes which you can see from the graph. These attributes are properties of that object. Now try That’s me.

Okay. This doesn’t seem to define all of me properly, does it? It doesn’t show all the details that you see in my profile, does it? Nope. There is more to my profile. I link to different objects. The different things that define me. My wall posts. My photos. My friends. And everything else. It is very much possible to view them all through the graph. Say you want to check all my friends. And the music that I like. Well, I know this didn’t work. You need something called an access token to view my profile details. Then the URL would become something like This isn’t really a valid access token. I can give you an access token, but then it would expire in a while and wouldn’t work if you try. I would rather go with screenshots. You can view my friend list here. And the music that I like here. Observe that each music band that I like and each friend of mine has an unique ID, and also check out the awfully long access token on the URL. Likewise you can access just about any detail of mine, anything like a photo or any of my wall posts, using an access token. You would have to go to /photos or /feed or /groups or /videos or /likes or other relationships. And you would require an access token to access any of these, because that’s how my privacy settings are. Within Facebook, when you click on my profile, you get to see all these details, but that’s because being a friend, Facebook internally gives you access privileges and then you make a request to view my details. And say when you visit the profile of someone who is not a friend, then Facebook does not give you privileges to view his posts or photos. It’s all about privacy.

Let’s jump into a photo that is public and can be viewed by anyone. Check this out. If you can follow the braces, then you’d get the real feel of the graph. You can see the “from” tag which gives the owner of the photo. You can see the names and IDs of the people who have been tagged in it, who have liked it, who have commented on it. You can even check out the comments in the “message” tag. Note that every comment also has its own ID. And not to forget, you can check out the link of the photo under “images:source”, the URL where it really resides on the web.

And you can see that Facebook is a lot about traversing through these graph structures, generating them, and rendering the right content at the right place. But it’s one messed up graph, and what seems simple isn’t really all that simple. Mad coding, defining Data Structures that can handle these, and continuous optimization runs behind the scenes.

I think we’ve come to an end here. I really appreciate it if you read through the whole thing. It sure is good to know more about something you are passionate of. I tried to be as descriptive as possible, but I can’t be telling that I explained the whole of it. There’s always more to learn, and best way to do is to visit the Developers page in Facebook and start reading up on things. However, I’m sure this would have given you a good insight into how things are ‘Underneath Facebook’.

Copyright © Bits and Bytes | Arjun Abhynav. Powered by WordPress.