Latest post

Twinkle twinkle little star is a short musical piece I composed and recorded last evening.

This piece consists of 56 measures. It is 1 minute 52 seconds long. The music is composed of four tracks. This is my second attempt at recording music with multiple tracks. The last such attempt was more than two years ago when I composed and recorded 'A few notes'.

The links to the audio files, sheet music, etc. are provided below. The files reside in my website. In case, my website is down, the YouTube link provided below should still work.

The four tracks in this piece are:

  1. Grand piano
  2. Slow strings
  3. Xenon pad
  4. Music box

This arrangement is based on the popular melody of the nursery rhyme called Twinkle, twinkle, little star. The melody is played with the treble notes of the piano. I wrote the bass notes for the piano and the strings, and the high notes for the pad and the music box to fill the music with emotions of love and happiness. I recorded this after about two hours of practice.

Random post

Once upon a time there was a hacker called John. He ran many websites in various web servers. The web servers were located in Canada. They were directly connected to the Internet. There were no proxy servers or firewalls between the servers and the Internet.

The websites were very popular and thousands of users from all over the world visited his websites everyday. From a glance at the web servers' access logs, he knew that his servers received most of the hits from China. One day he wanted to create a report of the usage of his various web servers. The old fashioned John decided to write his own tool to do this.

He wrote a C program to process logs from these web servers. The tool would pull down the access logs from each web server via SCP and process them to create reports. For every valid request found in the log, a certain function called add_to_statistics was called. The file containing the definition of the function began in this manner:

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
void add_to_statistics(struct in_addr *client_addr,
                       struct in_addr *server_addr) {
    char *client_ip = inet_ntoa(*client_addr);
    char *server_ip = inet_ntoa(*server_addr);
After those two lines in this function, the struct in_addr objects were not used at all. Later in the code the client IP address in client_ip was used to find the geographical location of the client from a database that mapped IP address ranges to countries. Finally, the code plotted a pie chart for each web server. The chart showed how many hits a server had received from each country. The larger the number of hits from a particular country to a server was, the larger was the slice for that country in the pie chart for the web server.

The colour to be used to fill the pie for each country was stored in a property file which began like this:

Canada: rgb(0, 0, 255)
India: rgb(0, 255, 0)
US: rgb(255, 0, 0)
China: rgb(255, 255, 0)
Which color was used most in the pie charts generated by the tool? Why?

Update: Prunthaban has answered the question correctly. The answer is: blue. In each pie chart Canada occupied the whole pie and hence blue was used to fill the entire pie chart for each web server. From the man page of inet_ntoa:

The inet_ntoa() function converts the Internet host address in, given in network byte order, to a string in IPv4 dotted-decimal notation. The string is returned in a statically allocated buffer, which subsequent calls will overwrite.