Sunday, November 11, 2007

the first story

once upon a time there was a grandmother who made vada and sold them, she'll eat the last vada as her food.
one day a crow took away the last vada, grandma became sad, and started to cry, her beloved pet, a dog named dommy, wanted to help her, so he went to the tree where the crow took shelter and said, "how  beautiful you are, i want to hear your sweet voice, so please sing for me", the crow became overjoyed and started to sing, kaa kaaka ... the vada fell from its mouth, the dog picked the vada and gave it to grandma, both lived happily ever after.

the moral of the story is, if i don't have anything to write, I'll write these kind of things, so forgive me

Blogged with Flock

the Zzz Stories

once upon a time ....

i am a great lover of stories, i wish to share interesting ones here ...

nowadays i have been adding the "Zzz" sound to most words, so welcome to "the ztories"

http://zstories.blogspot.com/

welcome

once upon a time ....

i am a great lover of stories, i wish to share interesting ones here ...

nowadays i have been adding the "Zzz" sound to most words, so welcome to "the ztories"

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

Banana, Good day & mineral water

what is your favorite mode of travel, 3-tire AC, Business class air travel or a private cruiser, mine is unreserved train travel, i.e.. general compartment, my friends who knows Hindi can recognize my Hindi knowledge which is mostly attributed to train travel, “Yatrigan kripya jyandije .. ghadi number ... Mumbai sai Chennai central sub janevalli ....platfrom number .. aaye hey”, ya I know its not exactly Hindi, but this is what I “hear”.

I haven't tried any form of luxury travel in my life before coming to IIITB, some times I end up paying 190 bucks for Bangalore-Mysore trip because its a bit faster and I can sleep properly(it doesn't mean i cant sleep in other situations), the one thing that I miss after coming to Bangalore is train travel (the other one is hot sun).

I don't know how many of you will agree that it's fun to travel in general compartment, the never ending line of vendors selling anything like chikkus, bananas, roasted ground nuts, murukku and other eatables.

I observe that most people in reserved compartment are well planed families who have the idea of hygienic food (i.e. Cooked and packed from home) or people who don't hesitate to spend money in branded products or people who hesitate to buy from these poor vendors, why others, even I feel awkward to buy and eat from these vendors when I travel in reserved compartment because no one else will be doing that, so I decided to be a general compartment person.

I even calculated the amount of money I spent on eating in one journey, 200 bucks is not that bad you know, few cups of coffee, two or three cups of tea, masala tea, tomato soup , ground nuts, samosa, a dozen of chikku, one or two custard apples, bananas blah blah blah ...

I always board the train with Deccan Chronicle and Hindu (why two?), I have to take care of my cloths which are mostly light colored ones (I have to wash them), so DC helps here..i travel light, light in sense real light(both in money and luggage), I didn't have a mobile phone, mostly I'll be unshaved and wouldn't have had a haircut, a small bag with a set of cloths and some books, every time I reach home I'll be hearing the same comment (grandfather: who will believe if you say you are a college student, mom: why torture me every time, all our relatives know about your pathetic state, I wont find a girl for you, dad: no girl will come near you) irrespective of what time I reach home (mostly around midnight), followed by “did you eat?”, the obvious answer is yes, no matter weather I ate or not, I don't want to trouble my mom to prepare something at that time, first of all I wont inform her, giving her an unpleasant surprise, and she'll be very angry of my appearance(don't forget the long nails).

I think I understand the kind of people who do general compartment travel, some wired people(Me!!), daily travelers, some people who didn't get a reservation or unplanned journeys, some poor people who don't know that reservations exist or can't afford that, etc.. however very few people enjoy journeys the way I do(I think), the heavy wind (some times hot) that hits your face when you sit near the door, the struggle to hold sambar from flowing out of plate, the water splash on face(people wash their hands thro the window, ya I know yuk..), fight between kids, elderly people, general discussion that ranges from politics to daily life, hmm It feels good.

But I should caution, if you don't like to sit with dirty people, hear some unpleasing words, worry about sitting comfortably through out the journey, or people snoring in your ears please stay away.

Other than that it's a wonderful experience to know about the majority of India, eat good snacks and fruits at throw away price, get good flow of air, and most importantly get to know some “good” bad words.

Welcome, to a new world of journeys


PS: what is “banana, good day & mineral water”, my regular food/eatables during journey nowadays, I cant expect vendors at every stop in bus, can I?.

Blogged with Flock

Tuesday, November 06, 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

Monday, November 05, 2007

Nurses or NCurses

the first time i saw this package was during Fedora Core 1 installation, a nurses package... what a funny name or is it really for nurses, but i forgot about it.
next comes kernel compilation for Advanced OS class, where make menuconfig reports some error in ubuntu.. after some digging someone found out that we have to install libncurses-dev package for it to work, and i remembered that funny incident that happened 3 years before.

the assignment questions seemed simple
  1. Observing “Linux“ behavior“ by writing a program to use the  /proc  mechanism to inspect various kernel values
  2. Learn how to write a UNIX—style shell program
what big deal, half the program is in book complete it and finish the assignment, my "proc" will intelligently display the status of the program if you give PID, and as an unexpected move Prof SN was completely "satisfied" with our work so we have to redo it.
so i want to add interactivity to my shell , that is history, command completion etc.. , so i have to capture keystrokes, but what shit, ours is not a complete shell, so the shell that we run on didn't give us the keycodes that we expect .. after a lot of blah blah .. nurses or ncurses came to resuce, there is a getch() function will capture all keys if we set keypad(stdsrc,TRUE), done...

worked for three more days to "port".. when every thing is working .. Hmm this is not what i wanted SEGMENTATION FAULT, why the hell!!, Hmm if do chdir() there is a seg fault, i got bugged of curses so had to revert back to non-interactive shell, but i can upgrade my proc code to work as a task manager (like top command) again 2 days of work, i could implement killing a process provided you have sufficient access rights, ya i know it has lot of flaws but i believe it is a "proof of concept" , now ask me do something in ncurses, i can do it with a bit of struggle.
next is a file manager in queue .. (long live ncurses ).

food for thought: try "tpp" the ncurses based based presentation program, ultimate, so decided to torture people with "tpp"  (available in ubuntu/debian repos)

Blogged with Flock

Movie Morning ...

we all would have heard about and experienced movie nite's, here is a place where we have movie mornings.

After making sure that i sleep early and get up early (save my wife) i have good amount of noise free time in the morning (say 4 to 8), first i thought about preparing for placements but god thought in different way (ya i believe in god vijay), gouuth@tLL happened and postpone that placement preparation forever...

I thought about doing my TA work, you know its difficult to work when nobody is around to disturb you (hostel effect), so i decided to go to college early ( say 5) and browse hoping that the internet speed will be good( and it is), gradually i got bored of it (actually 2 days), so i had to find some other option to "kill" time, then my old habit(actually CEG habit) of watching movies 24x7 seemed to be the best option, so here i am watching those all damn old movies(some even 20 times), suddenly i felt guilty when everyone in college is doing something important in life ( like sleeping ) WTF i am doing, so i want to see what others are doing, so today i instead of starting a movie directly took a look around and viola, there were 3 groups of people and of which 2 are ... watching movies .. what a good encouraging sight, i hurried to start my MOVIE.

so very soon expect some worst movie reviews here (PS: i kinda like all movies...).
I should say early morning walking alone in cold weather , going to infy for coffee is a damn good one, i urge everyone to try it once in every year ...

Blogged with Flock

Friday, November 02, 2007

MFC

MFC project problem statement is out...
in simple words identify a state machine which will accept the given string of alphabets (full 2 months), god only knows how to do this..        

Blogged with Flock

Intern....

accepted internship @ theLearningLabs, my professors startup.. technical updates will be in super-techie and others will be here ...                    

Blogged with Flock

Saturday, October 27, 2007

Really Nothing

Hmm... well a long time... nothing to write? Huh .. no .. its just plain laziness.
will try to post something in next week ..

Blogged with Flock

Friday, October 19, 2007

new blog

started a new blog, showing off my techie knowledge http://super-techie.blogspot.com

Blogged with Flock

cookbook

have a look at http://pleac.sourceforge.net/, thinking/working hard to contribute (Java & C++)  

Blogged with Flock

Lock "Stock"

after getting bugged by the internet speed, response time of nseindia.com & bseindia.com, java in firefox and the pain in maintaining a portfolio, i decided to build my own portfolio manager, here are the specs
1. Database: Postgresql
2. Programming Languages: Python(to populate database in 15minutes interval, using ystockquote module), JSP
3. TOMCAT (Obviously)

currently i have finished the database part, i think it's working fine. i am now in the process of building the front end, so i am going to use eclipse-europa-jee for that, wish me luck.
i'll keep posting about my progress and the details

Blogged with Flock

Wednesday, October 10, 2007

How do i Flush!!

Most programs i write suffer from either stdout or stdin not getting empty when it is supposed to (when using Eclipse CDT, explicit flush id required for me to print anything).
while i can flush stdout using fflush(stdout);, i cant do the same thing with stdin, this was creating a major headache for me, and i came across a site which gave a code snippet to clear the buffer
   int ch;
  while( (ch = fgetc(fp)) != EOF && ch != '\n' )
   /* null body */;


Blogged with Flock

Where is my Pointer

being a TA, its my job to help the students when they encounter any problem in implementation or tools used for their projects, when Joseph said that  his program is receiving SIGSEGV, i thought it must be some simple problem either the index of array is not proper or memory not allocated, so i started to debug and Voila! the program works just fine giving correct output.
we all were wondering what is wrong, and eclipse(CDT) was the first target, but debugging in eclipse also worked fine, and now we decided to go manual line by line checking so few things are observed
  • they wanted a 2D array for which they know that the column size is two and row size should be dynamically allocated
  • Array of pointers were used
so i said to them, "fine, but i think we should convert those array of pointers to double pointers", and they agreed, so the next run gave the same SIGSEGV error.
now its time for more digging, so i prefer to user -Wall option to clean and make my code perfect, there i noticed one warning, function returns reference to local pointer, voila got it... so changed the function a bit, instead of returning a pointer we passed a pointer to the function and worked on it, and the result SUCCESS.
it shouldn't have taken much time for me to find out, being an OS student, we always deal with functions(system calls) which take pointer as an argument instead of returning them, so there must be something wrong/bad in returning the reference to local pointer, the memory gets lost!!!. but why not in debugging, the only reason that came to my mind is when debugging the memory areas used by the program is locked till it is freed or the program ends.

Blogged with Flock

Wednesday, October 03, 2007

SciTE, Compile and Run

Lately SciTE is becoming my favorite text editor, (VIm rules always), i find the menu options Tools->Compile,Tools -> Go useful for beginners who are new to Linux/Programming,  but i found that even though it compiles properly, it does not execute it(i.e. run  ), Why?

few minutes of digging gave me these results
First: umask for files is 022, i.e. files created by user will be read/write for the user and read only for group and others
Second: compilers will know that they are creating executables and set executable bit when they produce .o/a.out files
Third: if "." is in your path, then the executables are searched in current directory as well

Now the solution:
SciTE uses gcc -c <filename.c> -o filename.o to compile a file, and filename.o to execute, i got the error "bash - access denied", i opened a terminal and tried to execute it by myself, still an error,
why?
when we compile with -c filename.c, we ask the compiler to just compile and don't link it, i.e. it creates an object file and not executable object file, so if you run, it'll produce the access denied error message.
so open cpp properties and remove that -c option, add "./" before executable i.e. ./filename.o

Now the more interesting points:
  1. SciTE reads config files when it loads, so any change you make you'll have to restart it
  2. also all but user config files should be edited as root
Disclaimer:- i dont know the impact of removing -c option, it might be useful in large or multi file programs, so please consult your manual for exact details.

Blogged with Flock

Stupid Me, System.currentTimeMills()

for(int j=0;j<100;j++)
{
    java.util.Random rnd = new java.util.Random(System.currentTimeMillis());
    for(int i=0;i<100;i++)
    {
        System.out.print(rnd.nextInt(10)+"");
    }
    System.out.println();
}

please don't expect the above program to give 100 different sets of 100 random numbers, there will be repetitions like anything. why?
First: for a particular seed a Random number generator should give same set of numbers, when ever it is run,
Second: our computers are fast enough to finish execution in micro seconds

so the generation of 100 numbers takes few micro seconds and the System.currentTimeMills() has resolution in milliseconds so, a week of stupid searching and debugging, here is a post.

how to fix it:-
use new Random(); forget about seed, this produces 100 different sets of 100 random numbers.

Blogged with Flock

Monday, October 01, 2007

Hello world!

class HelloWorld {
public static void main(String[] a)
{
System.out.println("this is my new blog, here i'll be posting things that i encounter while dealing with computers and programming. ");
}
}

Thursday, September 20, 2007

Live life, king size

i was traveling in a bus, i saw an old person who gave proper change to buy his ticket, but when the ticket checker came the old man didn't have the ticket to show to him, to everyones surprise he didn't even fight that he had bought a ticket, he paid his fine and started to leave.
a few people who got curious of this asked him about it, he told "i got a ticket, but the boy (who was walking at some distance) didn't have one, i have seen much more humiliation in life and those things don't matter to me anymore , but the humiliation the boy would suffer will hurt him for a long time, so i decided to give him my ticket".this is life, and i believe that he has lived his life to the fullest. or in other words living life "king size"   

Blogged with Flock