Wednesday, February 25, 2009

Wisdom

To Err is Human,
To Re-Err is Foolish,
To Learn from Other's Err is Wisdom.

Two days before, my two-wheeler got punctured and I had to get office through other means of Transport. I was lucky for the first day, I had a colleague who used to commute through Share-Auto. We need to take 2 trips to reach our Office.

First, from Velachery Bus Terminal to SRP Bus-stop and then from SRP Bus-stop to our Office in Kottivakam. When we reached SRP Bus-stop, my colleague advised to cross the road across before getting a Share-Auto.

I questioned him, because there were lot of Share-Autos which are standing nearby. He told me that they will charge Rs.10 instead of Rs.5 if we cross the road. Blindly, I took his advice and we crossed the road and took a Share-Auto for Rs.5.

Yesterday, It was my turn to come to Office all alone. My laziness caught me, I took the Share-Auto which was nearby, rather than crossing the road. I was thinking that who will ask Rs.5 extra for just a 10 feet before.

But to my dismay, the Auto-walla charged me Rs.10 when I got down at my office.

This is one of the daily lessons which we learn from our own bad experiences and trial-and-error methods. There is no need for us to go through the same bad experience which already happened to others. We can learn from others. That is WISDOM !!!

But, we must scrutinize the authenticity for such information without bias.

Books are means of communicating the Mistakes done by oneself.

How did Danny Boyle ???

How did Danny Boyle got Academy Award for "Slumdog Millionaire"?

A) It is a Good Movie with best performance, - NO
B) It is an Artistic Movie, - NAY
C) He's a Genius, - Of course, NOT
...
D) It is Written - Yes (it is fate...)

Sunday, February 22, 2009

Guruji Vasudev

Recently, I'm ready books by Guruji Vasudev (not Jaggi Vasudev). It is published by Sixth Sense Publication. I bought them at "Permanent Book Fair", Kannimara Library with 10% discount.

Some of the books are:
* Tao de Ching (Cheena Kathigal - Chinese Stories)
* Sufi Kathigal
* Think Differently (Marupattu Sinthiyungal)
* Zen Kathigal

I'm currently reading "Sufi Kathigal".

The Reader

Yesterday, I saw the film "The Reader" (Der Vorleser in Germany). It is one of good film. I recommend it. An wonderful performance by Kate Winslet. A strong storyline. The Music is also good. Note: the film is A-rated. I'm not surprised that she has won Oscar Award for her performance.

I kept my fingers crossed for Brad Pitt for his excellent performance in "The Curious case of Benjamin Button". But, I heard Sean Penn won it for "Milk". I feel very sorry for Brad Pitt.

I like both the movies "The Curious case of Benjamin Button" and "The Reader" very much. I recommend the movies, it is very good to watch. Far from the DISGUSTING "Slumdog Millionarie".

The another Movie, I watched over in this weekend is "The Man who know too much". It is an Alfred Hitchcock Film. Every Hitchcock Movie watch makes me like him more and more. He is the Brilliant Director in last century, who in the world could make you to sit and watch a 90 mins drama which happens only inside a "Single Room".

Last but not least, I have completed "The Blood of the Fold" by Terry Goodkind. The Wizard's Third Rule:

"Passion Rules Reason."

Letting your emotions control your reason may cause trouble for yourself and those around you. (thanks to wiki)

Monday, February 09, 2009

Some Quotes

An expert is a person who has made all the mistakes that can be made in a very narrow field.
-- Niels Bohr

The whole problem with the world is that fools and fanatics are always so certain of themselves, but wiser people so full of doubts.
-- Bertrand Russell

There are only two ways of telling the complete truth--anonymously and posthumously.
-- Thomas Sowell

...when you have eliminated the impossible, whatever remains, however improbable, must be the truth.
-- Sir Arthur Conan Doyle, (Sherlock Holmes)

Talent hits a target no one else can hit; Genius hits a target no one else can see.
-- Arthur Schopenhauer

I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones.
-- Albert Einstein

There's no point in being grown up if you can't be childish sometimes.
-- Doctor Who

Sunday, February 08, 2009

Dynamic Load Library - Linux

Have you ever wondered, how to load, link and execute library functions when it is needed and unload it after it is used in Linux.

libdl - Library gives you this opportunity. For example:

* If you are writing an application which makes use of XML Parsing Library sparingly. You may want to load this XML Library when there is need and unload it afterwards.
* Or, you may want to load choose a particular library depending on the runtime parameters of an application.

libdl comes in handy, with only 3 interfaces with in the library. The following functions are defined in "dlfcn.h".

* dlopen - gain access to an executable object file
* dlsym - obtain the address of a symbol from a dlopen object
* dlclose - close a dlopen object
* dlerror - dlerror - get diagnostic information

void *handle;
int *iptr, (*fptr)(int);

/* open the needed object */
handle = dlopen("/usr/home/me/libfoo.so", RTLD_LOCAL | RTLD_LAZY);

/* find the address of function and data objects */
*(void **)(&fptr) = dlsym(handle, "my_function");
iptr = (int *)dlsym(handle, "my_object");

/* invoke function, passing value of integer as a parameter */
(*fptr)(*iptr);



Don't forget to set the LD_LIBRARY_PATH.

Thursday, February 05, 2009

Creating Static Libraries in Linux

add.c
=====

int add(int a, int b) {
return a+b;
}

int sub(int a, int b) {
return a-b;
}

>>gcc -c add.c // creates add.o


mul.c
=====

int mul(int a, int b) {
return a*b;
}

int div(int a, int b) {
return a/b;
}

>>gcc -c mul.c // Creates mul.o


Creating Archive
================

ar cr libaddmul.a add.o mul.o // Create and replace the obj files in the archive

ranlib libaddmul.a // generate index to archive

nm libaddmul.a // list symbols from object files

How to use the Static Library
=============================

math.c
======

#include "stdio.h"
#include "addmul.h"

int main() {
printf(" 3 + 5 = %d\n", add(3, 5));
printf(" 3 - 5 = %d\n", sub(3, 5));
printf(" 3 * 5 = %d\n", mul(3, 5));
printf(" 3 / 5 = %d\n", div(3, 5));
return 0;
}

addmul.h
========

extern int add(int, int);
extern int sub(int, int);
extern int mul(int, int);
extern int div(int, int);

gcc -o math math.c -L((libaddmul.a path)) -laddmul // compile math.c with addmul library