Wednesday, December 9, 2009

Your country needs you - and how




I got this very important 'msg' today evening. You'll thank me for not forwarding this to you. It ran like this:

hi guys.
Ths msg s vry vry imp Pls frwd2al. (OMG!! Last time I got an important 'msg' was in the heydays of Swine flu - what is it now? Equestrian measles ??)
V hav 2stp d chinese products whch v r buyin. (who told you I brought Chinese products? The mallu shpokeeper who sold me that secret chinese stuff swore discreteness... Dang, he must have snitched under pressure)
So tat v can mak china economic down. (Ah! So this is how we make economic down. I bet not even Amartya Sen knew this)
U al knw tat china goi2start war wit india (WTF?!? I didn't know that I knew this - *scratches head*)
within 2or3 mnths (Whoa.. 2 or 3 months? Do our intelligence agenicies know this??)
Pls guys stp buyin chines prdcts. (Swear I will... really - we'll burn em like swadeshi movement)
Stdnts hav 2shw our powr by sending ths sms 2whole india. (Yeah! Go students.. But when you say whole India do you mean to include the remote village of Tarlekuntanhalli too??)
Atleaz do this for our india. (You break my heart sir. 'Atleaz' ?? Meaning I have not done anything for my country yet ?!? Waaah :`-( )

I suspect a Chinese hand in this forward.. Their plan is to cause panic in minds of Indian students (who make up a sizable chunk of our sizable population) Who do they think they're fooling? For one, it's definitely not me ;)

Tweet from Java

Here's how you can use Twitter API to Tweet from java:


import java.io.*;
import java.net.*;
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;


public class Tweet {
static String twitterUrl="http://twitter.com/statuses/update.xml";


public static void main(String[] args) throws Exception {
//Hate args checking.. Won't do it; Not even usage shall be displayed - figure it out
OutputStreamWriter ostreamwriter;
String statusmsg="";
int i=2;

URL url = new URL(twitterUrl);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
conn.setRequestProperty("Authorization", "Basic " + Base64.encode((args[0]+":"+args[1]).getBytes()));
while(i < args.length-1){
statusmsg = statusmsg+ args[i++]+" ";
}
statusmsg = statusmsg+ args[i];
String encStatus = "status="+URLEncoder.encode(statusmsg, "UTF-8");
ostreamwriter = new OutputStreamWriter(conn.getOutputStream());
ostreamwriter.write(encStatus); //--> Magic Magic :)
ostreamwriter.flush();                              //I forgot this at first..

//If interested you can check the response after this, though
}
//Won't bother with exceptions either. 
//A programmer should be intelligent enough to discover errors without any display mechanisms...
}
}


And voilĂ :













(or you could also use this )

Tuesday, December 1, 2009

Short story #6

[...They say it's bad luck if a black cat crosses your way...]

It was getting late for work and he had missed his cab. Weather did not help in any way, gloomy as it was. He decided to take the shortcut to the nearest bus stop, instead of standing at his doorstep, cursing his luck. Thunder rumbled in distant sky. He prayed he did not get wet so early in the morning. Sitting with wet clothes, in that awfully cold place called office was not something he looked forward to. Neither was the presentation he was supposed to be giving today.

Brows furrowed, hands deep in his pockets and his head low, he hurried past the butchers shop of that gully, that would for today, serve as his shortcut. He did not even shudder, as he did always, when he went past that particular landmark. So lost was he in his thoughts that he nearly jumped onto the road when he heard that sound.


MIAOW!

A cat as black as the deepest darkness, with bright jewel like green eyes looked up at him, midway through tackling a mouse. He scowled at it (although for what reason he did not know) He was not superstitious, but
[...They say it's bad luck if a black cat crosses your way...]
still he did not like the way it stared at him.

Curse you, curse you; Dirty human, who walks upon the plate we eat
Damn you, damn you; Wicked man, for no reason which us you beat

Shit. He did not care if the cat actually was cursing him now. He had no time for such stupidity. He mimed kicking, aiming his feet at the cat, which deftly picked up the mouse between its teeth and ran away, it's net displacement resulting in
[...They say it's bad luck if a black cat crosses your way...]
it crossing his path.

His momentum carried him forward a few steps before he thought about his action (all the while not really sure, whether some consideration would have resulted in a different outcome) and just as he went past the crossing point of their paths, a cold drop of water hit his forehead hard, dripping down to his eyes. Before he crossed the next 20 yards, that landed him at his bus stop, heavens opened up and drenched him completely.

He reached his office full 16 and a half minutes late, wet. Nancy, his colleague whispered as soon as he reached his cubicle, "Boss man is in a bad mood today. He's looking for you, I think"..
"Thanks", he said. "I'll drop by his chamber right away" and he started towards his boss' chamber.

He knocked on the door and entered the chamber. Boss was peering over a long piece of what appeared to be fax paper. He looked up.

"Ah, here you are. I was looking for you. You're late you know", the boss said and then continued without missing a beat, "This just in. There are some changes in the figures you'll be presenting today. You'll have to start working on this immediately and if you are lucky enough
[...They say it's bad luck if a black cat crosses your way...]
you may just finish this, and then we can have our presentation as planned. You know how much this means to the team, right?"

He could hardly protest as boss man dumped the sheets of the latest reports into his (still wet) hands. Taking it as a sign that he was dismissed for now and also for the fact that he wanted to show that he was going to start working on it immediately, he started looking at the numbers on that report even as he started from the chamber towards his cubicle. Shit, he thought, as he felt the numbers made no sense. He sat heavily in his chair, took out a pencil and started marking those parts that made some sense to him, dimly aware that some parts of the fax were slightly smudged by his wet hands.

Two hours went by, he was not even half way through. His stomach grumbled, but he stayed at his place. No lunch today, he thought. Dumb luck. And his mind wandered to the black cat who
[...They say it's bad luck if a black cat crosses your way...]
had crossed his path that morning. Hmmmph. He had to push such thoughts away. That would get him nowhere. And he was pretty confident, he'd be done in a couple of more hours, if he concentrated hard. Imagining his colleagues nodding appreciatively at his presentation, he started working away furiously.

Shit. He had smudged more that he had thought he had. He extrapolated whatever figures he had, cursing his stupid luck, his mind going back to his lab exams (where he had performed similar feats of adjustment), going back to the black cat (more than once) and returning with the faithfulness of a well trained dog, to the task at hand.

Hours passed...

He was almost done now and he looked up at the clock. Shit again, it was 4:30. He had only an hour before the presentation. His thoughts turned to despair, (and also to the cat which crossed his path that morn) and by the time he finished, it was exactly 3 minutes to 5:30. He snatched his laptop up and ran 12 flight of steps to the meeting room. As his luck would have it
[...They say it's bad luck if a black cat crosses your way...]
lifts were not working today, of all days.

Entering the meeting room, he tried to throw a casual smile at those present and was treated to a couple of grimacing (ghastly even) looking smiles. Or perhaps it was just his imagination (which again wandered briefly over to the black cat who, you know, crossed his path that morning) Turning on the projector, he started his presentation, although without his usual confidence.

For the next one and half hours he battled his way through the presentation, fielding all sorts of questions thrown at him. Were a couple of questions asked just to rile him? Anything was possible today he thought and as the presentation concluded, he did not quite think he had pulled it off. Infact he had no hopes of it at all. As boss man took the guests away for the evening entertainment, he just slunk away from the office, too tired and too dazed, now for sure believing that - it's bad luck if a black cat crosses your way.. There was no other reason that could explain such a bad day.

Now once you believe in the problem, you have to believe in the solution as well..
So, determined to set this all right, he decided he should retrace his steps of the morning, uncrossing the darned path where this all began. An undo, a ctrl+z of sorts.

As he neared the spot where the (darned) creature crossed his way, he saw that there, at the exact spot, was a boy of about 8. The boy stood there all alone, crying. "Ah, another victim of badluck", he thought pitying the boy and decided that perhaps he should enquire and offer him his solution (ctrl+z and all that)

"What's wrong kid?", he asked, "Why're you crying?"

Sobbing the kid replied "Cat" (his heart leaped)

"What happened, kid? What of the cat?", he asked, now feeling suddenly very light headed.

"My cat", the kid sobbed again, "Someone ran over her today morning. I have her no more" and he started wailing..

They say it's bad luck if a black cat crosses your way, but they did not say it is for whom...