sleepy programming!!

Yes, it was about 5 a.m. and I had a torrent of MATLAB 2012a being downloaded.  I did hear about the competition from Mathworks Simulink and think of trying for that.  Matlab was approximately 5gb and it is too much for a download speed of 64kbps!!!  Though I started it as my PC is usually all time ON.. It can give challenge to servers man, lolzz . The maximum time it was on was 3 and a half days continuously downloading a game from torrent.

I was actually feeling sort of tension because I had to go to college too after a few hours, first lecture is of MaZumDaaar madam!!!!!  So I decided to sleep putting an alarm alongwith (yeah, yeah yeah,, every other lazy and careless guy like me keeps an alarm to wake up, though it doesn’t make any affect…lolz.  I looked around for the alarm watch and I was not able to find it because actually I dont have one!!! 🙂 

So, I picked my phone but guess what It had already 3 alarms set for daily basis at 6:00 am to 7:00 am.  So I thought of making a new alarm because this alarm never works! Looking at my PC and my SPEAKERS, I had an idea of making the alarm on my PC.  As we all know there is already a watch available on everyone’s PC, no matter which OS you use, we usually get the ALARM  facility like that of Kalarm and others with different distros.  I thot of making it by my own irrespective of the fact that I was too much sleepy(on eye was almost closed sitting down on the chair).

Decided the point to make my alarm myself I half conscious started my favorite VIM editor, and started typing the easy code for my alarm.

I actually used the alarm system call with the desired time of 3 hrs and a signal handler where I invoked the VLC with argument as my desired song!
It indeed took 5-6 mintures and I was BHUND!

I really do think that I look like this guy while sleeping 

but I guess, I was actually looking like that while writing the code::

Following is the 3-5 minutes code in the morning in bhund situation!

#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<signal.h>

static void handler()
{
system(“cvlc /home/beyond/Music/6.mp3 &”);
return ;
}

int main(int argc, char *argv[])
{

if(argc < 2)
{printf(“you entered < 2 variables,Control ur sleep\n”);
exit(1);
}
printf(“%d\n”,argc);
signal(SIGALRM,handler);

unsigned int x;
x=atoi(argv[1]);
if(x==0)
printf(“no alarm set”);
alarm(x);
while(1);
return 0;
}

 The second argument is the time in seconds.  I know that it does not look good to give alarm time in seconds but its the fact that I was half asleep and was not in a condition to do little bit of maths..really…

Then I decided to give this alarm a GUI via QT or C# but on that my friend Shantanu is working so I will just handover this task to him.
You may obviously modify this badly written code as deploying error-checking, command line arguments, and a basic function to take time as argument and parse that.

*BHUND — refers to a state where you are semi-concisous because either you are intoxicated or feeling heavily sleepy.  🙂

Advertisements

About Beyond

an electronics hobbyst, 8 bit microcontroller(8051/AVR/Arduino) programmer, Linux lover, in love with Embedded Linux systems ... TGL: just push it "BEYOND THE LIMITS"..

Posted on August 19, 2012, in Linux and tagged , , , , , , , . Bookmark the permalink. 5 Comments.

  1. the definition of bhund in the end was amazing 😛
    btw nice work..

  2. What about this:

    sleep 3h; cvlc /home/beyond/Music/6.mp3

  3. sleep is a standard function.. You can have $man sleep
    and
    cvlc /home….. is invoking vlc media player in text only mode where the argument is specifying the mp3 file to be played..

    hope it make clears..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s