Friday, April 27, 2012

Bad Ending of a Good Start

Today I am sad. Very sad. I wanted to speak up but there is no one to listen. I am looking some loved ones around but I am alone. But its difficult to just be silent. So here I am.

Happiness are generally short. Or we feel they are short. The reaosn could be because we feel its importance when its not around. And when its not around, then the period looks longer. This week has been the worst week of my life because of multiple reasons that probably I may not share. Life takes U turn. There is no GPS system of lifee which tells you how far and steep is the next turn. It comes random in a minute. You need to make some decisions. Which may be hard sometime. Decisions are never wrong. Its just the result which decides if the decisions taken was right or wrong.


Many a times you get into a situation where neither you can move ahead not you can take a turn back. What to do. Your life becomes standstill and everything looks stagnant. I am in such a situation. I was having fun since last week. It was fantastic weekend. Had been to stonehenge, windsor castle and oxford university. I was tired, very tired as it has been long day.Even then I decided to go to some pub for a drink. I saw a casino on the otherside of the road and could not stop myself to get into it. Sometime I feel casinos has some natural power that attracts you. I have been in casino twice before. I had decided that I will not play but still I played and lost 70 GBP. I think that was probably the trigger of some bad time. It was I suppose predecided. After then I seen only the worse which has taken away my mind completely. Only I am aware that how did I manage the work whole week. It was last week of my business travel, so many meetings were lined up and had to accompalish many things. In almost all the meetings, mind was running somewhere else. Somehow, I managed to complete stuff with very little sleep everyday.

When things go wrong, you simply hope that they turn right asap. What what is right. If you have that answer, still you can put in effort to move in this direction. But if even thats not clear, then it makes the situation worse. You cant do anything. You just let life drives you and can hope.

I would have been fantastic if there would have been rewind button. You just press it, go back and could alter stuff...

Newaz, I think the post has been bit philosiphical on life. I am feeling a bit light hearted and I think I should go to sleep now. Thanks all of you for reading it.

Sunday, October 11, 2009

Launch Jboss/tomcat from Eclipse

Today I tried to configure jboss within eclipse to use JSP in one of my own project. On running, I landed up with a strange exception

2005-05-27 21:35:54,421 ERROR [SocketListener0-1] compiler.Compiler (Compiler.java:412) - Javac exception
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:105)
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:929)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:758)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:407)
.....
....

It took my 2 hours to setup JAVA_HOME even though it was setted up right. I changes the registry entries because on googling someone specified this as a solution.

But finally what worked was copying $JAVA_HOME\lib\tools.jar under $JBOSS_HOME\server\default\lib

So this post is for saving time for those who are also struggling with the same problem. Its worth giving this as your first try and I am sure it will take you through.

Sunday, September 14, 2008

Its been a while, but I am still not bad in probability

Few days back, one of my friend who like to solve Data structure problem asked me an interesting probability problem. I thought, ah probability, I am no more good in it. Its around 7 yrs I dint even touch its basics. And I am not in profession to make money by betting in stock market based on the probability of any stock to rise. 

Today is Sunday. I went to park for a walk with school friends and had a fantastic breakfast. I was feeling fresh. I had nothing much to do. Suddenly the thought to try out the problem ran into my mind, and as I was free and in good mood so I thought to give it a try. 

Here Is the problem:

Assume your computer is reading characters one by one from a stream (you don't know the length of the stream before ending). Note that you have only one character of storage space (so you can't save the characters you've read to a something like a strong). When you've finished reading you should return a character out of the stream with equal probability.

Everybody has different approaches but I always go to the route by taking example.

Question ask to select a character from stream in such a way that probability of selecting any element in the stream is same. It is conditioned by the one character extra space that we can use. 

Lets consider that the stream has 5 elements:
a, b, c, d, e

As the stream has 5 elements then everyelemet should have 1/5 probability to get selected.

First solution:
Read a and keep it in buffer. Read next char(b) . Get a random number from random generator, which returns 0 or 1 with equal probability. we have random generators built in in all the languages. If zero (0) comes, don't swap b with a but if 1 comes, swap b with a. Do the same for rest of the characters C, D and E.

Lets see the probability:
  • A: it would be the final choice if random generator returns zero(0) for all other characters in the stream.  p(a) = 1(a) * 1/2(b) * 1/2(c) * 1/2 (d) * (1/2)e = 1/16 
  • B: B final selection depends only on character c, d, E. Not on A. B would be the final choice if random generator returns (1) for b and (0) for characters c, d, e.                                 p(b)= 1/2(b) * 1/2(c) * 1/2 (d) * (1/2)e = 1/16
  • p(c) = 1/2(c) * 1/2 (d) * (1/2)e = 1/8
  • p(d) = 1/2 (d) * (1/2)e = 1/4
  • p(e) = (1/2)e = 1/2
You see, as we go down in the stream, probability increases. And the reason is there are less characters to replace it. E has the highest probability as there is no more character to replace.

This is definitely not required. What we have noticed,
For a, there are 4 more character to replace it if it get selected as final choice.
For b, there are 3 more character to replace it if it get selected as final choice.
..
..
For e, there are no more character to replace it if it get selected as final choice.

Lets modify it. If we our self make selection of a character difficult or less as we go down the stream, we can get the equal probability.

Final solution:
As we go down the stream, decrease the probability of swaping a character.
We can use random function like random (1, n) where the character will be swapped only if it random(1, n) returns n. So its probability will be 1/n.

Now, the probability for each alphabet to get selected for swapping will be
p(swap A) = 1/1
p(swap B) = 1/2, p(do not swap B) = 1 - p(swap B) = 1/2
p(swap C) = 1/3,  p(do not swap C) = 1 - p(swap C) = 2/3
p(swap D) = 1/4,  p(do not swap D) = 1 - p(swap D) = 3/4
p(swap E) = 1/5,  p(do not swap E) = 1 - p(swap E) = 4/5

We are almost done. Now lets calculate the probability of each character to come as random number as final answer from stream.

A: = A is selected as swap. And no other character is selected for swapping.
     = p(swap A) * p(do not swap B) * p(do not swap C) * p(do not swap D) * p(do not swap E)
     = 1/1 * 1/2 * 2/3 * 3/4 * 4/5 = 1/5

B: = p(swap B) * p(do not swap C) * p(do not swap D) * p(do not swap E)
     = 1/2 * 2/3 * 3/4 * 4/5 = 1/5

C: = p(swap C) * p(do not swap D) * p(do not swap E)
     = 1/3 * 3/4 * 4/5 = 1/5

D: = p(swap D) * p(do not swap E)
     = 1/4 * 4/5 = 1/5

E: = p(swap E) 
     = 1/5.

All the characters has equal probablity of getting selected. 

Monday, February 18, 2008

People Never Fail....They Just Give up.

Today, while browsing via blogrolls, I landed to a profile of a guy who is an exception to this world, who is blessed with strong will power. Title is just not a quote to me, I mean it now.

The guy I am talking about is Rajat Mishra, who joined NDA. He had to left the army because he had an accident in which he lost his right hand. Despite of sudden and steep change in his life, rajat dint loose. He decided to learn to write from left hand. Not only he learned to write from left hand, he also cracked GMAT with commendable 740 score. He cracked the interview and joined ISB. Just after 20 days, he found ISB not his cup of tea. He left it and joined IIMA for 2 year mba.

Hats off to you dude. You may find him here.

Now it make sense to me.....People Never Fail, They Just Give up.

Monday, August 06, 2007

Suddenly felt to write random.

After a while, Today, I don't know why, even I have other pending work inline, but I am feeling to write something. I don't have much to write except my presentation last week in the company.
A week before last week, I got the mail from HR to give presentation on our tech forum activity in company. Actually here everybody present something and last week, it was my turn. Before this, I was a part of good audience when technology geeks of Wirkle Inc., my company, presented on core IT related technical topics.

Was I also going to present some technical topic ?.

Actually other then technical topics, companies case study always inspires me and force me to move ahead with positive energy. So, I decided to present a case study on YouTube which was recent revolution after myspace in internet space. Here I go...



Although its not very stylish and colourful but I tried to aggregate all facts and figures. It could be a bit motivational and who knows, tomorrow, maybe anyone from us, make another youtube.

Friday, April 27, 2007

Convocation.....Most awaited moment

After two years of long time gap, last week, we were in college again on the occasion of Convocation ceremony for our batch (2005). Everybody was looking more mature, responsible and importantly more disciplined. Guys, who were always seen in torn jeans and funky t-shirts, were in formals.




Aren't they looking like the top professionals of industry gathered at one place to discuss about some important issue?





Convocation is most awaited by all and the reason is you meet all your friends under the roof where you met them first. You meet your classmates and batch mates to whom you could not meet because after college, some left the town, some left the country and those who still in the same town go early and come late from office. But it does not take time to have fun with them once again


Convocation ceremony started and we all were sitting in convocation hall. Around 200 people sat in black & red rob with pin-drop silence. We were being addressed by top most persons of industry. There was one lesson common in everyone's speech and that is responsibilities towards society. We take so much from the society and when it comes to return to the society, we starts to blame our system. According to Dr A.P.J. Abdul Kalam, Indians are the most ethical and disciplined citizens in the world when they are in foreign but when they come to India they don't bother breaking the laws. Vice Chancellor GGSIPU University talked about lack of vision when a youth come out of the college and that is the reason of increasing attrition rate in the industry. While talking about engineer's capability to take quick decision, he gave us an example of two friends who were in forest. Suddenly a lion came in front of them. Both were frightened because they were not prepared for this situation. First person said, to save our life we need to run faster then lion. He asked second person, Do you think we can run faster then lion? Can you guess what he had replied? He replied, I don't need to run faster then lion. I just need to run faster then you.


Finally degree distribution event started and after waiting for a while, I was a graduate from Delhi University.


Saturday, April 21, 2007

Back in writing mode

Hello,

yes, its 1 year 3 months and a day since my last post but its better to be late then never.

Right now I don't have anything to write but from this point onwards I promise that I will be more regular and will try to keep this blog updated.

Thank You,