Thursday, June 28, 2012

"Under The Bridge" syndrome

There was person sleeping under the bridge. A passerby advised him that the bridge might fall.
"If the bridge hasn't fallen in so many years, why would it now?" replied the one who was under the bridge. The passerby argued "Thats why. Since it has not fallen in so many years, it has grown very old and will fall any moment." Their argument continued forever.

When I put this in front of the people and ask whose side are they. They generally tend to take side of either one of them while true engineers just say "Why don't they check the date when was the bridge built and age which is generally written somewhere on the bridge."

This is what I call "Under the bridge" syndrome.

I quite often, I find people arguing about things and not able to figure out the actual problem.


Saturday, December 25, 2010

The Education System

While reading "Surely You're Joking, Mr. Feynman!" by Richard P. Feynman, I came across a chapter on his experiences in Brazil education system. While you read this, you would realize that this is the ditto situation we have in India. He has presented it very well.
=============
In regard to education in Brazil, I had a very interesting experience. I was teaching a group of students who would ultimately become teachers, since at that time there were not many opportunities in Brazil for a highly trained person in science. These students had already had many courses, and this was to be their most advanced course in electricity and magnetism–Maxwell’s equations, and so on.
The university was located in various office buildings throughout the city, and the course I taught met in a building which overlooked the hay.
I discovered a very strange phenomenon: I could ask a question, which the students would answer immediately. But the next time I would ask the question–the same subject, and the same question, as far as I could tell–they couldn’t answer it at all! For instance, one time I was talking about polarized light, and I gave them all some strips of polaroid.
Polaroid passes only light whose electric vector is in a certain direction, so I explained how you could tell which way the light is polarized from whether the polaroid is dark or light.
We first took two strips of polaroid and rotated them until they let the most light through. From doing that we could tell that the two strips were now admitting light polarized in the same direction–what passed through one piece of polaroid could also pass through the other. But then I asked them how one could tell the _absolute_ direction of polarization, for a _single_ piece of polaroid.
They hadn’t any idea.
I knew this took a certain amount of ingenuity, so I gave them a hint: “Look at the light reflected from the bay outside.”
Nobody said anything.
Then I said, “Have you ever heard of Brewster’s Angle?”
“Yes, sir! Brewster’s Angle is the angle at which light reflected from a medium with an index of refraction is completely polarized.”
“And which way is the light polarized when it’s reflected?”
“The light is polarized perpendicular to the plane of reflection, sir.” Even now, I have to think about it; they knew it cold! They even knew the tangent of the angle equals the index!
I said, “Well?”
Still nothing. They had just told me that light reflected from a medium with an index, such as the bay outside, was polarized; they had even told me which way it was polarized.
I said, “Look at the bay outside, through the polaroid. Now turn the polaroid.”
“Ooh, it’s polarized!” they said.
After a lot of investigation, I finally figured out that the students had memorized everything, but they didn’t know what anything meant. When they heard “light that is reflected from a medium with an index,” they didn’t know that it meant a material _such as water_. They didn’t know that the “direction of the light” is the direction in which you see something when you’re looking at it, and so on. Everything was entirely memorized, yet nothing had been translated into meaningful words. So if I asked, “What is Brewster’s Angle?” I’m going into the computer with the right keywords. But if I say, “Look at the water,” nothing happens–they don’t have anything under “Look at the water”!
Later I attended a lecture at the engineering school. The lecture went like this, translated into English: “Two bodies . . . are considered equivalent . . . if equal torques . . . will produce . . . equal acceleration. Two bodies, are considered equivalent, if equal torques, will produce equal acceleration.” The students were all sitting there taking dictation, and when the professor repeated the sentence, they checked it to make sure they wrote it down all right. Then they wrote down the next sentence, and on and on. I was the only one who knew the professor was talking about objects with the same moment of inertia, and it was hard to figure out.
I didn’t see how they were going to learn anything from that. Here he was talking about moments of inertfa, but there was no discussion about how hard it is to push a door open when you put heavy weights on the outside, compared to when you put them near the hinge–_nothing!_
After the lecture, I talked to a student: “You take all those notes–what do you do with them?”
“Oh, we study them,” he says. “We’ll have an exam.”
“What will the exam be like?”
“Very easy. I can tell you now one of the questions.” He looks at his notebook and says, ” ‘When are two bodies equivalent?’ And the answer is, ‘Two bodies are considered equivalent if equal torques will produce equal acceleration.’ So, you see, they could pass the examinations, and “learn” all this stuff, and not _know_ anything at all, except what they had memorized.
Then I went to an entrance exam for students coming into the engineering school. It was an oral exam, and I was allowed to listen to it. One of the students was absolutely super: He answered everything nifty! The examiners asked him what diamagnetism was, and he answered it perfectly. Then they asked, “When light comes at an angle through a sheet of material with a certain thickness, and a certain index N, what happens to the light?”
“It comes out parallel to itself, sir–displaced.”
“And how much is it displaced?”
“I don’t know, sir, but I can figure it out.” So he figured it out. He was very good. But I had, by this time, my suspicions.
After the exam I went up to this bright young man, and explained to him that I was from the United States, and that I wanted to ask him some questions that would not affect the result of his examination in any way. The first question I ask is, “Can you give me some example of a diamagnetic substance?”
“No.”
Then I asked, “If this book was made of glass, and I was looking at something on the table through it, what would happen to the image if I tilted the glass?”
“It would be deflected, sir, by twice the angle that you’ve turned the book.”
I said, “You haven’t got it mixed up with a mirror, have you?”
“No, sir!”
He had just told me in the examination that the light would be displaced, parallel to itself, and therefore the image would move over to one side, but would not be turned by any angle. He had even figured out how _much_ it would be displaced, but he didn’t realize that a piece of glass is a material with an index, and that his calculation had applied to my question.
I taught a course at the engineering school on mathematical methods in physics, in which I tried to show how to solve problems by trial and error. It’s something that people don’t usually learn, so I began with some simple examples of arithmetic to illustrate the method. I was surprised that only about eight out of the eighty or so students turned in the first assignment. So I gave a strong lecture about having to actually _try_ it, not just sit back and watch _me_ do it.
After the lecture some students came up to me in a little delegation, and told me that I didn’t understand the backgrounds that they have, that they can study without doing the problems, that they have already learned arithmetic, and that this stuff was beneath them.
So I kept going with the class, and no matter how complicated or obviously advanced the work was becoming, they were never handing a damn thing in. Of course I realized what it was: They couldn’t _do_ it!
One other thing I could never get them to do was to ask questions. Finally, a student explained it to me: “If I ask you a question during the lecture, afterwards everybody will be telling me, ‘What are you wasting our time for in the class? We’re trying to _learn_ something. And you’re stopping him by asking a question’.”
It was a kind of one-upmanship, where nobody knows what’s going on, and they’d put the other one down as if they _did_ know. They all fake that they know, and if one student admits for a moment that something is confusing by asking a question, the others take a high-handed attitude, acting as if it’s not confusing at all, telling him that he’s wasting their time.
I explained how useful it was to work together, to discuss the questions, to talk it over, but they wouldn’t do that either, because they would be losing face if they had to ask someone else. It was pitiful! All the work they did, intelligent people, but they got themselves into this funny state of mind, this strange kind of self-propagating “education” which4is meaningless, utterly meaningless!
At the end of the academic year, the students asked me to give a talk about my experiences of teaching in Brazil. At the talk there would be not only students, but professors and government officials, so I made them promise that I could say whatever I wanted. They said, “Sure. Of course. It’s a free country.”
So I came in, carrying the elementary physics textbook that they used in the first year of college. They thought this book was especially good because it had different kinds of typeface–bold black for the most important things to remember, lighter for less important things, and so on.
Right away somebody said, “You’re not going to say anything bad about the textbook, are you? The man who wrote it is here, and everybody thinks it’s a good textbook.”
“You promised I could say whatever I wanted.”
The lecture hall was full. I started out by defining science as an understanding of the behavior of nature. Then I asked, “What is a good reason for teaching science? Of course, no country can consider itself civilized unless . . . yak, yak, yak.” They were all sitting there nodding, because I know that’s the way they think.
Then I say, “That, of course, is absurd, because why should we feel we have to keep up with another country? We have to do it for a _good_ reason, a _sensible_ reason; not just because other countries do.” Then I talked about the utility of science, and its contribution to the improvement of the human condition, and all that–I really teased them a little bit.
Then I say, “The main purpose of my talk is to demonstrate to you that _no_ science is being taught in Brazil!”
I can see them stir, thinking, “What? No science? This is absolutely crazy! We have all these classes.”
So I tell them that one of the first things to strike me when I came to Brazil was to see elementary school kids in bookstores, buying physics books. There are so many kids learning physics in Brazil, beginning much earlier than kids do in the United States, that it’s amazing you don’t find many physicists in Brazil–why is that? So many kids are working so hard, and nothing comes of it.
Then I gave the analogy of a Greek scholar who loves the Greek language, who knows that in his own country there aren’t many children studying Greek. But he comes to another country, where he is delighted to find everybody studying Greek–even the smaller kids in the elementary schools. He goes to the examination of a student who is coming to get his degree in Greek, and asks him, “What were Socrates’ ideas on the relationship between Truth and Beauty?”–and the student can’t answer. Then he asks the student, What did Socrates say to Plato in the Third Symposium?” the student lights up and goes, “_Brrrrrrrrr-up_”–he tells you everything, word for word, that Socrates said, in beautiful Greek.
But what Socrates was talking about in the Third Symposium was the relationship between Truth and Beauty!
What this Greek scholar discovers is, the students in another country learn Greek by first learning to pronounce the letters, then the words, and then sentences and paragraphs. They can recite, word for word, what Socrates said, without realizing that those Greek words actually _mean_ something. To the student they are all artificial sounds. Nobody has ever translated them into words the students can understand.
I said, “That’s how it looks to me, when I see you teaching the kids ’science’ here in Brazil.” (Big blast, right?)
Then I held up the elementary physics textbook they were using. “There are no experimental results mentioned anywhere in this book, except in one place where there is a ball, rolling down an inclined plane, in which it says how far the ball got after one second, two seconds, three seconds, and so on. The numbers have ‘errors’ in them–that is, if you look at them, you think you’re looking at experimental results, because the numbers are a little above, or a little below, the theoretical values. The book even talks about having to correct the experimental errors–very fine. The trouble is, when you calculate the value of the acceleration constant from these values, you get the right answer. But a ball rolling down an inclined plane, _if it is actually done_, has an inertia to get it to turn, and will, _if you do the experiment_, produce five-sevenths of the right answer, because of the extra energy needed to go into the rotation of the ball. Therefore this single example of experimental ‘results’ is obtained from a _fake_ experiment. Nobody had rolled such a ball, or they would never have gotten those results!
“I have discovered something else,” I continued. “By flipping the pages at random, and putting my finger in and reading the sentences on that page, I can show you what’s the matter–how it’s not science, but memorizing, in every circumstance. Therefore I am brave enough to flip through the pages now, in front of this audience, to put my finger in, to read, and to show you.”
So I did it. _Brrrrrrrup_–I stuck my finger in, and I started to read: “Triboluminescence. Triboluminescence is the light emitted when crystals are crushed..
I said, “And there, have you got science? No! You have only told what a word means in terms of other words. You haven’t told anything about nature-what crystals produce light when you crush them, _why_ they produce light. Did you see any student go home and _try_ it? He can’t.
“But if, instead, you were to write, ‘When you take a lump of sugar and crush it with a pair of pliers in the dark, you can see a bluish flash. Some other crystals do that too. Nobody knows why. The phenomenon is called “triboluminescence.”‘ Then someone will go home and try it. Then there’s an experience of nature.” I used that example to show them, but it didn’t make any difference where I would have put my finger in the book; it was like that everywhere.
Finally, I said that I couldn’t see how anyone could he educated by this self-propagating system in which people pass exams, and teach others to pass exams, but nobody knows anything. “However,” I said, “I must be wrong. There were two students in my class who did very well, and one of the physicists I know was educated entirely in Brazil. Thus, it must be possible for some people to work their way through the system, had as it is.”
Well, after I gave the talk, the head of the science education department got up and said, “Mr. Feynman has told us some things that are very hard for us to hear, but it appears to he that he really loves science, and is sincere in his criticism. Therefore, I think we should listen to him. I came here knowing we have some sickness in our system of education; what I have learned is that we have a _cancer!_”–and he sat down.
That gave other people the freedom to speak out, and there was a big excitement. Everybody was getting up and making suggestions. The students got some committee together to mimeograph the lectures in advance, and they got other committees organized to do this and that.
Then something happened which was totally unexpected for me. One of the students got up and said, “I’m one of the two students whom Mr. Feynman referred to at the end of his talk. I was not educated in Brazil; I was educated in Germany, and I’ve just come to Brazil this year.”
The other student who had done well in class had a similar thing to say. And the professor I had mentioned got up and said, “I was educated here in Brazil during the war, when, fortunately, all of the professors had left the university, so I learned everything by reading alone. Therefore I was not really educated under the Brazilian system.”
I didn’t expect that. I knew the system was bad, but 100 percent–it was terrible!

Monday, November 29, 2010

Is Kindle an alternative of paperback books?

Can a digital device compete with the paperback book?
I was in favour of the argument during discussions/arguments with my wife but I really could never win the argument or convince her.
Though I always argued in favour of digital device but always felt it can never replace.

And in the mean time, Kindle came. I gifted to my wife on her Birthday. Well, she has hardly got time to use it but I have been using it most of the time.
Now, I feel a digital device can compete with the paperback book and win.

My criteria for a e-book reader are as follows:
1. Screen Look & Feel
The screen of Kindle feels exactly like a paper print. The fact that it does not flow like PC or Phone makes it very soothing to eyes. This is one of the main criteria for a e-book reader to qualify. The more the ambience light the better you can read.
The downside of this property is that you cant read in dark.

1.1 Font
Elderly people need bigger fonts and younger ones want smaller fonts. Some of the reprints of paperbacks are pretty bad. This is one of the biggest problem I face while reading books. Thankfully, in Kindle I can change the font and the quality of print can never be an issue.

2. Battery
The battery should last long. I should not be charging it everyday. Kindle's battery life is about 15-20 days easily if it is not indexing.
This durability of battery is pretty good.
If you have put thousands of book, for first few days it drain the battery because it is indexing the books in background.

3. Weight
It should not be bulky. The weight of Kindle is about 289 gms which light that most of the book. The only book in that weight I can think of "Animal Farm" by George Orwell.

4. Easy to use
Like a book, it should be pretty easy to use. I should not be browsing around and searching for where I left the book.
Kindle does it in extremely good fashion. My recent book bubble up in the menu and when I open it, it takes me to the page I left.

It is also pretty easy to transfer book from my pc to kindle. It can be done eithe via USB cable using Calibre Software or by sending mail to your free kindle account (your-login@free.kindle.com)

5. Should not Crash
When people start designing hardware or device, they tend to put each and everything which lead to complexities and crashes apart from battery drainage.

Kindle have done it smartly but they are also overloading it with features slowly for example they have put a browser and a music player in it. But so far, it is going pretty good. It doesn't crash or hangs at all.

Other features:
Dictionary:
We always needed a dictionary lookup with zero effort. I have a physical OXford dictionary, Dictionary on my phone and PC. I also purchased an electronic oxford dictionary for 7K but while reading you rarely get up and look for a word because it is too much of an effort. But with Kindle, I am using the dictionary for the first time in My Life while reading because it is effortless. All you have to do is bring the cursor to the word and the meaning is displayed with a zero hinderance to your reading. If the word is in top half of the screen, the meaning is displayed at bottom. If the word is in bottom half, the meaning is in top. What a design!!

Text-To-Voice:
I had always found almost all text-to-voice clarity of all softwares pretty bad. But Kindle's voice is pretty clear and understandable. When I am tired of reading I would just put the earphone and turn the voice on. It read it for me. I have done it for around 50 pages so far and I am pretty comfortable with it.

Music Player:
Kindle comes with music player which can play music but I hardly prefer it.

Internet:
Although, it is not the objective of the device to help browse internet but since it is almost always going to be your companion on travels, it is useful to have internet in it in case of emergency. But I would hardly use it because i have internet on my phone.
Inside the browser also, it has a feature called "Reading Mode" which is quite useful if you want to read article on web like a book - I mean navigation controls and page layout.

Shockingly, it comes with Internet which is free for lifetime and is available in almost every coordinate of world. Unbelievable, isnt it?
When my Tata Photon USB and Airtel GPRS wasnt working on a travel, using this device I could check my pnr status of train. Since 3G is not yet available in India, the internet automatically switches to EDGE.

In the end, I must say I am enjoying reading on kindle more than paperbacks.

Wednesday, July 22, 2009

Orkut Ad Block

I just realized that orkut has shamelessly started putting random and embarrassing ads.
So, I tried AdBlock Plus which doesn't seem to work. So I quickly wrote a script to block the ads from orkut.

Here is the JS script for GreaseMonkey:

var timeOutIds = [];
function clearAllIntervals()
{
for(var i=0; i< timeOutIds.length;i++)
{
var id = timeOutIds[i];
window.clearInterval(id);
if(console)
console.log('cleared the interval : ' + id);
}
}
var total = 0;
function hideBlock()
{
if(total > 10)
return;
else total++;
var frame = unsafeWindow.frames['orkutFrame'];
if(frame)
{
var div = frame.document.getElementById('rhs_ads');
if(div)
{
div.setAttribute('style', 'display:none');
clearAllIntervals();
console.log('Hiding the ad');
}
else
{
console.log('ad div not found.');
}
}
else
{
console.log('ad frame not found');
}
}
var timeOutId = window.setInterval(hideBlock, 1000);
timeOutIds.push(timeOutId);
console.log('scheduled : ' + timeOutId);


All you have to do is install the greasemonkey ad-on for firefox. And the an icon of a face would appear on the right bottom of the screen.
Just right on that icon and say new user script.
Under includes put 'http://www.orkut.com/*' and 'http://www.orkut.co.in/*'
And when the empty window of editor opens just copy-paste the above script and refresh you orkut screen.

BINGO!! No Ads.

Saturday, July 11, 2009

My First Marriage Anniversary

It was our first marriage anniversary (9th July) so we went out to Shamirpet Lake while sister was planning some big surprise at home. It was a great at Lake. We roamed around a lot.

On the way back on our skooty, an auto (full of eggs) was overtaking from left. Yes, from left. It is common in Hyderabad. As I applied the brakes, one car (perhaps Qualis) started over taking from right. The right side of handle hit the car and we fell down.

I wasn't hurt but there was a lot of blood around. It was Sravani's thumb. It was crushed badly but she was calm and in senses even after realizing what happened. Leaving my skooty there, we waved for lift. Thanks to Hyderabad culture we got lift quickly. He left us Appollo. After First Aid and X-ray, we were told that there is no need of amputation, just the surgery will do but there is no surgeon available.

By this time, Ritesh (my business partner) with Lokesh (my co-worker) has reached hospital and took us to Yashoda. I knew plastic surgeon here so I called him on mobile. He did the operation and Sravani was admitted for a day.

Today, we got relieved and are back. We celebrated our Anniversary my sister's way.

Nevertheless, It is more memorable day now.

Wednesday, June 03, 2009

Bing-Bang: Microsoft might monopolize the web market

With the advent of Bing, Microsoft might try to eat the market. I am getting the hibbie-gibbies after thinking about it.

I remember my days before Google. People used to open at least 2 windows for search (Most prominent were Alta Vista, Yahoo and ask jeeves) in Netscape Navigator. We had to keep opening lot of windows as the thing we were looking for might even be on the second page of search results. Since the net was slow, we would be more aggressive about opening as many windows as possible. One top of that, since PCs were few more then one person would use a PC to search.

First Microsoft Killed Netscape.

We were left with IE and we all know the history of IE. The one responsible for most of the viruses around.

Anyway, lets get back to the search engine.
Now, one fine day (after living with the internet for around 2 years), I came to know about Google. I still remember the feeling of the first page. It looked like designed for non-profit by some student because we were used to seeing the popup/ad-filled pages. Since that day, I haven't looked back to any other search engine for serious use. Google was definitely 100 times (i.e. 10,000 %) better than yahoos and altavistas.

Now, Bing comes with hardly -1% to +1% improvement( effectively 0%) and $ 100 M ad budget. I feel that given that budget microsoft can takeover the market. Reason being simple "99% People breathe windows. Windows is their conscience".

What if IE6, IE7 and all the stuff that links to search engine, all points to Bing? And the user find the things which he is looking for on Bing. will anyone care to open google?

No matter how bad MSN Messenger had been, it always had biggest user base. Reason was simple, microsoft forced every one to open an account from inside windows. There are links everywhere (when you run outlook express, netmeeting etc etc.).

MSN live space still claims to have 3rd biggest user base (after myspace and facebook). Did you ever heard about MSN live space? I opened once but never used afterwords.
So, the key point is Microsoft's marketing and control over me could trick me into opening an account but could not hold me longer.

Since for search engine, user has less inertia of change as compared to emails or a social network. There are chances that people who are taken to Bing at least 4-5 times would remain there.

One of the main crowd pullers for Google is Firefox to whom they pay $50m to $66m a year. Can't Microsoft snatch that deal now?

Given all this thought process, I feel that Microsoft will have 50% share in search engine market in 1 year.

So, my question remains to Google, "why didn't you create an OS for a normal user? Why?!"
See, all of the end users of windows suffer. At lest 20% people who are using windows have one problem or the other. An individual has to format his/her windows pc at least once in 3 months. This is based on my 8 years of experience.

I feel there is a huge scope of improvements. I am using Mac for past 1 year and it has been such a breeze. I never looked back.

I have used Linux but it doesn't provide a great UI experience. One has to be at least 10 times better than windows to beat it at this time.

So, My conclusion is this, Unless Google comes up with a search engine which is 10 times better then current Bing or an OS which is 10 times better than windows, it would be difficult to survive.

Disclaimer: This is my personal view point based on the current situation. I can not be held by neck for any of this.

Monday, January 26, 2009

Setting the gmail's status as 'a new fortune quote' automatically

This tiny little thing sets my status after picking it from the unix command called 'fortune' (it gives out a quote possibly funny).
So, I just used Smack API and implemented it.


import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Presence;

public class PresenceGoogle extends IQ {

protected String userName;
protected String status;
protected boolean visible;
protected Presence.Mode mode;




/**
* Override toXML in the case of mode is away
* Because Google Talk interprets the 'away'
* status as idle, and idleness is a
* per-connection property, you cannot set an
* 'away' status using this method. To set an
* idle status message, send a
* standard stanza. :
*/
@Override
public String toXML() {
if ( mode.equals(Presence.Mode.away) )
{
Presence p = new Presence(Presence.Type.available);
p.setMode(mode);
p.setStatus(status);
return p.toXML();
}
else
{
return super.toXML();
}
}


/**
* Constructor
* @param userName the userName
* @param status the new status
* @param visible the visible state > false to be invisble
*/
public PresenceGoogle(String userName, String status, boolean visible) {
super();
this.userName = userName;
this.status = status;
this.visible = visible;
setType(IQ.Type.SET);

// I am not sure this code must be test
// in case of a domain different of gmail.com
// using gmail.com...
if( userName.indexOf("@") != -1)
{
setTo(userName + "");
}
else
{
setTo(userName + "@gmail.com");
}

mode = Presence.Mode.available;
}

/**
* Constructor
* @param userName the userName
* @param status the new status
*/
public PresenceGoogle(String userName, String status) {
this(userName,status,false);
}

/**
* Return the XML of changing status
* for google
* according
* http://code.google.com/apis/talk/jep_extensions/shared_status.html
*/
@Override
public String getChildElementXML() {
StringBuilder buf = new StringBuilder();

// set query header
buf.append("");
// set status
buf.append("").append(status).append("");
// set mode
buf.append("").append(mode).append("");
// set invisible mode
if ( visible )
{
buf.append("");
}
else
{
buf.append("");
}
// close query
buf.append("
");

return buf.toString();
}


public Presence.Mode getMode() {
return mode;
}


public void setMode(Presence.Mode mode) {
this.mode = mode;
}

}

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;

public class SetStatusMessage {
public static XMPPConnection getConn() throws XMPPException
{
String login = "sandeepxxxxgiri@gmail.com";
String pass = "xxxx";

return getConnection(login, pass);
}
private static XMPPConnection getConnection(String login, String pass)
throws XMPPException {
XMPPConnection connection = new XMPPConnection("gmail.com");
connection.connect();
connection.login(login, pass);
return connection;
}
public static void setStatus(XMPPConnection connection, String msg)
{
PresenceGoogle pg = new PresenceGoogle("sandeepgiri",
msg, true);
connection.sendPacket(pg);
}
public static void setStatus(String login, String pass, String msg) throws XMPPException
{
setStatus(getConnection(login, pass), msg);
}

private static String readStdIn() throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);

StringBuilder input = new StringBuilder();
String str;
while( (str = br.readLine()) != null)
{
input.append(str);
}
return input.toString();
}
public static void main(String[] args) throws FileNotFoundException, IOException, XMPPException {
String login;
String pass;

if(args.length == 2)
{
login = args[0];
pass = args[1];
}
else if(args.length == 0)
{
String userHome = System.getProperty("user.home");
if (userHome == null) {
throw new IllegalStateException("user.home==null");
}
Properties props = new Properties();
props.load(new FileInputStream(userHome + "/.setstatus.properties"));
login = props.getProperty("login");
pass = props.getProperty("password");
}
else
{
System.out.println("Usage: \n 1. setStatusMessage \n\t Sets the status message using the login and password.\n 2. setStatusMessage \n\t Reads login and password from .setstatus.properties");
return;
}
String quote = readStdIn();
setStatus(login, pass, quote);
}
}

Then I wrote this command setfortunestatus.sh:
$cat cat ~/scripts/setfortunestatus.sh
CLASSPATH=$CLASSPATH:/Users/sandeepgiri/scripts/gmailstatus/smack.jar
CLASSPATH=$CLASSPATH:/Users/sandeepgiri/scripts/gmailstatus/smackx.jar
CLASSPATH=$CLASSPATH:/Users/sandeepgiri/scripts/gmailstatus/smackx-jingle.jar
CLASSPATH=$CLASSPATH:/Users/sandeepgiri/scripts/gmailstatus
/opt/local/bin/fortune -s|java -classpath $CLASSPATH SetStatusMessage

Now, I scheduled it using Lingon in my macos x.
In case you do not have fortune on your Mac OS X, you could just use "sudo port install fortune". This would use fortune macport.