Tuesday, January 27, 2009

8 * 2 = 16 hours

it all began when all those "super" teachers whom i have encountered in my life, all would have been well if somebody would have encounter(ed) them before i met them, then 150 poor souls would have been saved.
Like every story has a beginning, this began on one sad depressed evening, i decided to canvas my parents about the evils of using windows, my dad got so energetic and demanded an outright lesson in using ubuntu.
But my uncle said யான் பெற்ற இன்பம் பெருக இவ் வையகம் , so i was given the idea of preaching linux to "Our kids" (this indian slang of whoever lives nearby, i mean the kids, become "our kids" to elders), so after a few (i mean one) brainstorming session, i decided to wear the teachers hat.
i was thinking or dreaming might be the apt word, to be the greatest teacher in the world, so i requested a few places to give their students a guinea pigs, and to my surprise they all agreed (dont ask how many), however i decided to be volunteer faculty, so NO FEE.
but the truth is the fear of stones if something goes wrong.

so i prepared (trust me, i was not like my exams) for days, examples, documents, presentations etc.. i was all prepared to unleash the full power of gouutha-ism.
so the D-Day arrived, i was armed with my laptop , dresses as appropriately i could, and i did shave for the occation.
and i reached the hall, and was greeted by a "STANDING" crowd, my god, all over my life i never stood up for any of my teacher,(unless they can see through the crowd and kick me for my marks in tests) , all i could see were 2/3rd year engineering kids, threatened with compulsory attendance (and it was taken), in few minutes i could see, half the class wants to go out, so i gave a break after first half hour, a bunch of students were missing, and first rows were "sparsely populated".

next comes the installation, thanks to ubuntu i could prove to them that linux is Not at all difficult.
by the time it was 11, the crowd started to you know.. students stuff, and trust me, i was not in any p0sition to control them, first the guilt feeling, they are not doing anything that i haven't done, and its fucking student life.
so after few lunch break requests, i with a kind heart gave them a break for one complete hour ...
the remaining was not different from above,
however the conclusion is a few buggers did really showed promise, however my biggest fear is they were "first benchers" (as opposed to backbenchers) the eager kids, me being a backbencher all over my life think, we make things better.
a few failures on my part, first not wanting to break their existing setups, that sucked the fun out of installing a lot of applications, and i really could not keep up my promise of showing them a kernel compilation and others,
i know that hose things can be learnt from internet, (as i pointed out to them) lets see ..
i however got some feedback, and i asked the organizers to remove the stupid attendance restrictions next time, if possible.
hmm... hoping for more

Thursday, June 5, 2008

What will be the output of the following C and Java programs?

C/JAVA:
int sum = 0;
for(int i=0;i<3;i++)
sum+=sum++;

Now print the value of sum

Answer...
C:
7
Java:
0

Why?...

Wednesday, June 4, 2008

download youtube videos

i know there are hell-a-lot of ways to do it.. for those who like to do it the dirty way like me..

  1. Install the browser
  2. Install flashgot
  3. Install Python
  4. Download and save the python script say youtube-dl.py from http://www.arrakis.es/~rggi3/youtube-dl/
  5. Now restart the browser and Tools->Flashgot->More Options
  6. Click Add, give a name, say My Youtube Downloader
  7. Click browser and select python.exe
  8. and in command line arguments give [the full path of youtube-dl.py] -t [URL] example: C:\youtube-dl.py -t [URL]
  9. now create a shortcut in desktop or startmenu for "C:\program files\mozilla firefox\firefox.exe" -console, if you have installed it in different directory then choose your correct executable
  10. Launch the browser using the link/shortcut that you created in above step
  11. in flashgot menu select your download manager and right click on any youtube link and select "Flashgot link", switch to the console that opened while launching forefox and see the progress..
PS:
  1. the files will get stored in your home directory, say c:\documents and settings\
  2. when downloading multiple files, the console output is really ugly
  3. in firefox 3, there is no output in console but the download proceeds without any problem

Thursday, March 13, 2008

AWK 1 liners

how to find the websites visited by particular IP from squid access logs?

grep -E '192\.168\.12\.35' /var/log/squid/logs/access.log | awk '{print $7;}' | sort | sed 's/http:\/\///' | cut -d ':' -f 1 | cut -d '/' -f 1 | uniq

  1. grep -> get only entries related to 192.168.12.35
  2. awk -> take 7th column, the URL
  3. sort -> sort them
  4. sed-> remove http:// from URL
  5. cut -> remove port number
  6. cut -> remove directory and file information
  7. uniq -> remove duplicate entries
good na...

Thursday, February 7, 2008

Some more 'C'

in shared memory IPC in C, if you share a pointer does that mean that you share the memory location pointed by the pointer, no, after many hours of debugging a code, where a program shared an array of pointers with its child process, the child process calculated Fibonacci series and updates the array pointed by the pointer which is in shared memory location, after the child process ends, when we tried to access the array, the famous GCC report "segmentation fault".

A multithread program to calculate Fibonacci series, if every thread waits for the output of previous thread (assuming, that each thread calculates fixed number of elements in the series), then why the hell you need a multi-threaded program, so we all know that there is a formula to calculate nth number in Fibonacci series, and iterative calculation is better than formula, so what do we do.
Split the range so each thread can calculate some amount of numbers, in every thread use the formula to find the first and second number and iterate to find others.

Saturday, November 10, 2007

Give windows a “bash”

How many of us, who love the power of command line feel handicapped when it comes to windows, with its pathetic cmd.exe or command.exe, I was missing the auto-completion, multiple tabs, and most importantly the commands, pipes, redirection, tee, I am not sure of the windows equivalents of these, so I was looking for some way to Linux-ify my widows.

Being a TA required me to compile few softwares for windows (skyeye, softgun, arm-elf-gprof etc...), so I had to choose between MinGW and Cygwin, first I started with MinGW and found it quite inadequate, since Cygwin gives a complete Linux environment, I settled for it, but I still miss the tabbed terminals, I was searching for “tabbed command prompt” in google and found a few links but none were open source, some how I stumbled upon a blog where they have mentioned about Console2, an open source one currently under development, so I downloaded it and am pretty happy about it, now i'll give a step by step procedure how I got a almost working gnome-terminal(or Konsole) alike...

  • download and install cygwin
  • download and extract console2
  • open console2
  • press ctrl+s to bring settings dialog
  • go to tabs option, click add change title to you something you want, select cygwin.bat from CYGWIN_HOME, press ok
  • now if you want a cygwin terminal press ctrl+f2 (assuming the cygwin appears below console2)
If you dont want cygwin then you can use gnuwin32 package, and add its wbin folder to path and just use console2 with all the power of unix

Console2: http://sourceforge.net/projects/console

Blogged with Flock

Tuesday, November 6, 2007

infront or infront of back

sounds crazy right, i could not come up with a sexy title for (pre or post increment operators in c), anyways today the issue of pre/post increment operators in c, sagar and i had a good 15 minute discussion how this works so he results are here

int i=5;
printf("%d,%d,%d",++i, i, i++);
/*
output: 7,7,5
*/

how, we understood that printf evaluates from right to left, so it'll do i++ first and return '5' and update value of i i.e. 6 in stack, the middle i is just i, the first ++i, will increment value of i in stack i.e. it becomes 7, now it'll examine the value of stack finds i=7, therefore it substitutes 7 as first and second argument


int i=5;
printf("%d,%d,%d",++i, i, ++i);
/*
output: 7,7,7
*/


how, we understood that printf evaluates from right to left, so it'll do ++i in stack i.e. 6 in stack, the middle i is just i, the first ++i, will increment value of i in stack i.e. it becomes 7, now it'll examine the value of stack finds i=7, therefore it substitutes 7 as first and second argument

because in post increment operator, the assignment happens before increment, therefore in case one 5 is assigned or returned, and get incremented on stack.
fair enough understanding i think.

refer:-

Blogged with Flock