Last month itself there were talks that the final year BE/BTech results will be available by January first or second week. When it became January there were posts in various unofficial blogs that the results will be coming out by January 4th. Blogs said that on worst case it will be postponed to January 5th and they even stated the time University will be updating it in the database. But days passed, nothing happened. And this cycle is still going on. I was thinking how much traffic will they be getting during these days. I just wanted to know how much clicks they will be getting for using those particular keywords in their posts. Even if they are providing fake news they will be getting lots of hits. Even i am checking those blogs twice daily. They are exploiting students’ eagerness to know about their examination results. Let me check the increase in number of traffic to this blog after posting this. I will come up with an update to this post if there is considerable increase in number of clicks.
BTW, now one of the University site says that the results are expected to come out by January 12th.

Update: Yeah, This post did bring more than 100 hits in a single day as expected.

A script written by Adhil Azeez to generate Indian flag in php. Actually he wanted to share the code here on Independence day. But i was not able to post it that day. After that a series of things happened that prevented me from getting online and updating my blog. So here is the code..

 * Filename: tricolor.php
 * Dependencies: GD Library mostly precombile with php 4.0+
 * Author: Adhil Azeez NV
 * Description: Generates Indian National Flag Image

//Create a resource identifier for the image res in ration 3:2
$flag = imagecreate(1350, 900); 
if (!$flag) {
    die("Some error occured");
//Color identifiers definitions
$white = imagecolorallocate($flag, 255, 255, 255);
$saffron = imagecolorallocate($flag, 255, 153, 51);
$green = imagecolorallocate($flag, 18, 136, 7);
$blue = imagecolorallocate($flag, 00, 0, 137);

//Draw the tricolor sections.The white portion is no need to be specified since
//the background color is white.
imagefilledrectangle($flag, 0, 0, 1350, 300, $saffron);
imagefilledrectangle($flag, 0, 600, 1350, 900, $green);

//Draw the Ashoka Chakra
//The Circle can be created with imageellipse itself after setting the thickness.
//But unfortunetly due to a bug in GD library(reported more than 5 years ago :()
//the thickness is being ignored.
imagefilledellipse($flag, 675, 450, 240, 240, $blue);
imagefilledellipse($flag, 675, 450, 210, 210, $white);

//Draw the center small circle
imagefilledellipse($flag, 675, 450, 42, 42, $blue);

for ($angle = 0; $angle <= 360; $angle = $angle + 15) {

//Draw 24 small circles in the Ashoka Chakra at the border of the circle adjacent
// to 24-spoke
    $x = 675 + 105 * cos(deg2rad($angle+7.5));
    $y = 450 + 105 * sin(deg2rad($angle+7.5));
    imagefilledellipse($flag, $x, $y, 10.5, 10.5, $blue);

//Draw the 24 spooks
    $x1 = 675 + 8 * cos(deg2rad($angle));
    $y1 = 450 + 8 * sin(deg2rad($angle));
    $x2 = $x1 + 40 * cos(deg2rad($angle - 5));
    $y2 = $y1 + 40 * sin(deg2rad($angle - 5));
    $x3 = 675 + 105 * cos(deg2rad($angle));
    $y3 = 450 + 105 * sin(deg2rad($angle));
    $x4 = $x1 + 40 * cos(deg2rad($angle + 5));
    $y4 = $y1 + 40 * sin(deg2rad($angle + 5));
    imagefilledpolygon($flag, array($x1, $y1, $x2, $y2, $x3, $y3,$x4,$y4), 4, $blue);
//if the script being invocked from CLI and has a filename arguments then write
//the out put to the file else print to the outputstream.
if (isset($_SERVER['argv'][1])) {
    if(imagejpeg($flag, $_SERVER['argv'][1] . '.jpg', 100))
    	echo "National Flag saved to ".$_SERVER['argv'][1] . '.jpg';
    	echo "Some error occured";
} else {
    header("Content-type: image/jpeg");
    imagejpeg($flag, null, 100);


The script makes use of php GD library. It outputs the image to current
output stream or save to a file.

If php GD library have anti aliasing support then we can enable that for much
better render.Currently anti aliasing is not enabled in the script.

The output is in JPEG format but it can be changed to other format if necessary
with a few modification in the script.


PHP needs GD Library support. Most of the php distribution compiled with it.

php flag.php filename

Filename argument is optional. If not present the script will output to the
current output stream

for example:
php flag.php | display
will open the image in ImageMagick picture viewer

My ISP provides unlimited download from 2am to 8am. So i was not able to sleep after 2 from the time i switched to the new broadband plan. Keeping the system on and setting a cronjob to start downloading after 2 was an option. But i was more concerned about the increasing electricity charge, than my sleep. Besides it is my social responsibility to save energy as a gonna-be software engineer :p. After a bit of googling and hacking i was able to wake up my system at a particular time. Here i am going to explain how i made my arch linux system to boot automatically at 2 am.

The configuration is done in Arch Linux. For automatic wakeup it needs a BIOS which supports RTC alarm. Most of them manufactured after 2000 supports this feature.

1) Check if your BIOS supports automatic wakeup

Execute the command below as root.

# grep rtc /var/log/messages.log
rtc_cmos 00:03: RTC can wake from S4
rtc0: alarms up to one month

If you can find something like this in the output.It says that the system can wakeup and a wakeup time can be setup.

2) Enable automatic wakeup in BIOS

Go to your BIOS setup, Under Power Management search for something like “Wake by RTC Alarm” or “Resume by RTC alarm” or “RTC resume”.Then enable it.

3) Set the hardware clock time standard as UTC

Edit the /etc/rc.conf file as root and set the HARDWARECLOCK variable to UTC

[ragsagar@h4ckb0x ~]$ grep ^HARDWARECLOCK /etc/rc.conf

Make sure that your timezone is set correctly in /etc/rc.conf
More help : https://wiki.archlinux.org/index.php/Time

4) Set the alarm time

Execute the following commands as root

# echo 0 > /sys/class/rtc/rtc0/wakealarm
# echo `date '+%s' -d '+ 5 minutes'` > /sys/class/rtc/rtc0/wakealarm

This will set the the alarm time as 5 minutes into the future.

Now run

$ cat /sys/class/rtc/rtc0/wakealarm

If the output of above command is something like “1313383930”, the alarm is set. It is epoch time. If it doesn’t yield any result make sure that the HARDWARECLOCK variable is set to UTC and reboot and try again to set the alarm time.

Now run

$ cat /proc/driver/rtc

Go through rtc_time, alrm_time and alrm_date and check if they are correct(will be in UTC).Turn off the system and leave the power on. Check if the system is booting automatically after five mintues.

5) Setting the alarm to a particular time and date.

To set the alarm to woke up the system at 16th Aug 2:05am, Run the following as root

# echo 0 > /sys/class/rtc/rtc0/wakealarm
# date --date "Aug 16 , 2011 02:05:00" +%s > /sys/class/rtc/rtc0/wakealarm

You can convert the epoch time to readable format and check the alarm time is correct.

[root@h4ckb0x ragsagar]# cat /sys/class/rtc/rtc0/wakealarm
[root@h4ckb0x ragsagar]# date -d @1313440500 +%F" "%T
2011-08-16 02:05:00

Note : The mythtv wiki about acpi wakeup says that setting the hardware clock after setting alarm will disable the alarm while most of the linux distribution sets hardware clock during shutdown. They suggest to disable hardware clock adjusting during shutdown. To do that in Archlinux set the HARDWARECLOCK=”” in /etc/rc.conf . But in my arch system the alarm was not working when i set HARDWARECLOCK=”” whereas it worked when i gave HARDWARECLOCK=”UTC”. So if the wake up alarm is not working do try after changing the value of this variable.

To start downloading when the system boots up, i added a cronjob to restart the router at 2:15 and 7:45 (to account the download in happy hours). Also added “transmission-gtk” to the gnome-session-properties. So that transmission will be launched on startup and downloading will be started.

Reference :

%d bloggers like this: