Monday, September 21, 2009

A nice Story



Once upon a time there was a shepherd looking after his sheep on the side of a deserted road. Suddenly a brand new Porsche screeches to a halt.

The driver, a man dressed in an Armani suit, Cerutti shoes, Ray-Ban sunglasses, TAG-Heuer wrist-watch, and a Pierre Cardin tie, gets out and asks the Shepherd: If I can tell you how many sheep you have, will you give me one of them?"

The shepherd looks at the young man, and then looks at the large flock of
grazing sheep and replies: "Okay."

The young man parks the car, connects his laptop to the mobile-fax, enters a NASA Webster, scans the ground using his GPS, opens a database and 60 Excel tables filled with logarithms and pivot tables, then prints out a 150 page report on his high-tech mini-printer.

He turns to the shepherd and says, "You have exactly 1,586 sheep here."

The shepherd cheers,"that's correct, you can have your sheep."

The young man makes his pick and puts it in the back of his Porsche.

The shepherd looks at him and asks: "If I guess your profession, will you return my animal to me?"

The young man answers, "Yes, why not".

The shepherd says, "You are an IT consultant ".

"How did you know?" asks the young man.

"Very simple," answers the shepherd. "First, you came here without being called. Second, you charged me a fee to tell me something I already knew, and third, you don't understand anything about my business...
Now can I have my DOG back?"

I got this story as a forwarded mail, few days back. It was like damaging myself because I aspire to become an IT consultant! Anyway, its how the customer always thinks of us! So it was pretty cool to read. Hope you like it too!

Sunday, September 13, 2009

1. Coca-Cola was originally green.

2. The most common name in the world is Mohammed.

3.The name of all the continents end with the same letter that they start with.

4. The strongest muscle in the body is the tongue.

5. There are two credit cards for every person in the United States.

6. TYPEWRITER is the longest word that can be made using the letters only on one row of the keyboard.

7. Women blink nearly twice as much as men!

8. You can't kill yourself by holding your breath.

9. It is impossible to lick your elbow.

10. People say "Bless you" when you sneeze because when you sneeze,your heart stops for a millisecond.

11. It is physically impossible for pigs to look up into the sky.

12. The "sixth sick sheik's sixth sheep's sick" is said to be the toughest tongue twister in the English language.

13. If you sneeze too hard, you can fracture a rib. If you try to suppress a sneeze, you can rupture a blood vessel in your head or neck and die.

14. Each king in a deck of playing cards represents great king from history.
Spades - King David
Clubs - Alexander the Great,
Hearts - Charlemagne
Diamonds - Julius Caesar.

15. 111,111,111 x 111,111,111 = 12,345,678,987,654,321

16. If a statue of a person in the park on a horse has both front legs in the air, the person died in battle.

If the horse has one front leg in the air,the person died as a result of wounds received in battle.

If the horse has a all four legs on the ground, the person died of natural causes.

17. What do bullet proof vests, fire escapes, windshield wipers and laser printers all have in common?

Ans. - All invented by women.

18. Question - This is the only food that doesn't spoil. What is this?
Ans. - Honey

19. A crocodile cannot stick its tongue out.

20. A snail can sleep for three years.

21.. All polar bears are left handed.

22. American Airlines saved $40,000 in 1987 by eliminating one olive from each salad served in first-class.

23. Butterflies taste with their feet.

24. Elephants are the only animals that can't jump.

25. In the last 4000 years, no new animals have been domesticated.

26. On average, people fear spiders more than they do death.

27. Shakespeare invented the word 'assassination' and 'bump'.

28. Stewardesses is the longest word typed with only the left hand.

29. The ant always falls over on its right side when intoxicated..

30. The electric chair was invented by a dentist.

31. The human heart creates enough pressure when it pumps out to the body to squirt blood 30 feet.

32. Rats multiply so quickly that in 18 months, two rats could have over million descendants.

33. Wearing headphones for just an hour will increase the bacteria in your ear by 700 times.

34. The cigarette lighter was invented before the match.

35. Most lipstick contains fish scales.

36. Like fingerprints, everyone's tongue print is different

Tuesday, September 8, 2009

Recently, I had to send a mail to all my friends.
So I was searching for a method to do it.
That's when I found this pretty useful video in youtube!

Monday, September 7, 2009

Today, I was speaking with my Internet Programming lecturer, Mr. Gupta. He was sharing his experience on teaching C to the first year mechanical class. He said, he couldn't explain the logic of adding sum of n digits to a student. He employed the usual strategy of leaving out the nines in the number. (The student didn't know that simple logic it seems!)

That's when this idea struck me. If you have a number, say x.
It shall be represented as (9*n)+y.

If we identify y then that's the sum of digits.

Say the number is 103

It's simple 99+4, (9*11)+4 hence 4.

y is nothing but (9+9+9+9....11 times) +4
So we skip all those nines and take the 4 alone.

In simpler words if x is the number then (x modulus 9) is the sum of the digits.
So in a programmer's perspective its just x%9.

Sunday, September 6, 2009

What Java does not have?

No functions in Java (Only Methods)
Function vs. Method
1. C++ functions could be present inside and outside the class.
2. But java methods could be written inside classes only.

No pointers in Java
1. Pointers lead to confusion.
2. Pointers crash program easily. (Addition of 2 pointers, Runtime memory leakage-dangling pointers)
3. Pointers break security.

No operator overloading in Java
1. Operators are immutable in java.
2. Operator’s meaning cannot be changed in java.

No preprocessor directives in Java

No multiple inheritance in Java

No static memory in Java

No destructors in Java

No goto statement in Java

Well, there seems to be more features available in C and C++ than in java. Why learn Java then? Doesn’t your brain ask this question? My brain did ask.
And I began searching for the answer.
First we have to compare C and Java to understand how the languages work.

Here is a small comparison between C and Java
C vs. Java





C





Java

So Java is powerful mainly because, of the byte code. It could be interpreted by the Java Virtual Machine. So based on the system, different JVMs are used. But the class file remains the same unlike C's exe file. It’s quite an interesting fact that JVM was written using C.

There is a big table with all the differences between C and Java mentioned in it. I would suggest you to skip it if you feel it to be too big.

Click here to view that table.

C uses a compiler or an interpreter (only one at a time).
Java uses both compiler and interpreter together.

In addition to this it uses a pretty interesting JIT. Now what does this JIT do?
Wikipedia gives the following definition:

In computing, just-in-time compilation (JIT), also known as dynamic translation, is a technique for improving the runtime performance of a computer program. JIT builds upon two earlier ideas in run-time environments: byte code compilation and dynamic compilation. It converts code at runtime prior to executing it natively, for example byte code into native machine code. The performance improvement over interpreters originates from caching the results of translating blocks of code, and not simply reevaluating each line or operand each time it is met. It also has advantages over statically compiling the code at development time, as it can recompile the code if this is found to be advantageous, and may be able to enforce security guarantees. Thus JIT can combine some of the advantages of interpretation and static (ahead-of-time) compilation.

The paragraph does not make complete sense to you unless you already know about JIT ;-).

Now let me try to put it simple.

Consider the following code:

for(i=1;i<=10;i++)
print i

It is a program to print from one to ten.

Normally, a compiler will convert the print i code ten times (say it takes ten
nanoseconds).

JIT Compiler will load print i at a place in the memory with an increment in it
and call it ten times (it takes just 2 nanoseconds).

Convert print I --------> 1 nanosecond.
Load it in memory -----> 1 nanosecond.

Coming back to our comparison, C vs. Java, I think I have told you enough for today. And as for C++ vs. Java, that’s covered in what Java does not have itself.

I have told you what Java does not have?
Why Java does not have those features is the question you have to think upon. Keep meditating till the next post.



I had been spending my last fortnight with Java. As I was studying, I understood its power and the flexibility it gives to a programmer. Though I have learnt Java in bits and pieces, I have not learnt it from the basic (ie., from the origin, history, architecture,..). In my college, we students have not been attending the classes for the past one week due to the fear of getting infected from swine flu in the campus! This has been like a blessing in disguise, I was able to peacefully explore Java. As I was exploring Java, I got an idea of making a small tutorial for people like me who have learnt Java in bits and pieces.

I will be posting my tutorial here in my blog once in a while! It is a tedious process so there is no fixed timeline on my tutorial posts. Continue your support.

Friday, September 4, 2009

Cool Pictures

Following are few photoshop works I liked.



A baby playing his own trick to the mum



Young at heart(s)-Shadow acts as the mind reader



A lady in a faded gray dress and her husband, dressed in a homespun suit walked in timidly without an appointment into the Harvard University President's outer office. The secretary could tell in a moment that such backwoods, country hicks had no business at Harvard and probably didn't even deserve to be in Harvard.
"We want to see the President "the man said softly.
"He'll be busy all day "the secretary snapped.
"We'll wait" the lady replied.
For hours the secretary ignored them, hoping that the couple would finally become discouraged and go away. They didn't and the secretary grew frustrated and finally decided to disturb the president.
"Maybe if you see them for a few minutes, they'll leave" she said to him. The President, stern faced and with dignity, strutted toward the couple.
The lady told him "We had a son who attended Harvard for one year. He loved Harvard. He was happy here. But about a year ago, he was accidentally killed. My husband and I would like to erect a memorial to him, somewhere on campus."
The president wasn't touched....He was shocked. "Madam" he said, gruffly, “We can't put up a statue for every person who attended Harvard and died. If we did, this place would look like a cemetery."
"Oh, no" the lady explained quickly "We don't want to erect a statue. We thought we would like to give a building to Harvard."
The president rolled his eyes. He glanced at the gingham dress and homespun suit, and then exclaimed, "A building! Do you have any earthly idea how much a building costs? We have over seven and a half million dollars in the physical buildings here at Harvard."
For a moment the lady was silent. The president was pleased. Maybe he could get rid of them now. The lady turned to her husband and said quietly, "Is that all it costs to start a university? Why don't we just start our own?"
Her husband nodded. The president's face wilted in confusion and bewilderment. Mr. and Mrs. Leland Stanford got up and walked away, traveling to Palo Alto, California where they established the University that bears their name. Stanford University, a memorial to a son that Harvard no longer cared about.
Most of the time we judge people by their outer appearance, which can be misleading. And in this impression, we tend to treat people badly by thinking they can do nothing for us. Thus we tend to lose our potential good friends, employees or customers.
Remember
In our Life, we seldom get people with whom we want to share & grow our thought process. But because of our inner EGO we miss them forever.

It is you who have to decide with whom you are getting associated in your life.

Tuesday, September 1, 2009

Throughout history, humans have always been prone to accidents. Some, such as the exotic car crashes seen on this page, can be very expensive. But that's trivial compared to the truly expensive accidents. An accident is defined as "an undesirable or unfortunate happening that occurs unintentionally and usually results in harm, injury, damage, or loss". Our aim is to list the top 10 most expensive accidents in the history of the world as measured in dollars.

This includes property damage and expenses incurred related to the accident such as cleanup and industry losses. Many of these accidents involve casualties which obviously cannot be measured in dollar terms. Each life lost is priceless and is not factored into the equation. Deliberate actions such as war or terrorism and natural disasters do not qualify as accidents and therefore are not included in this list.

# 10. Titanic - $150 Million



The sinking of the Titanic is possibly the most famous accident in the world. But it barely makes our list of top 10 most expensive. On April 15, 1912, the Titanic sank on its maiden voyage and was considered to be the most luxurious ocean liner ever built. Over 1,500 people lost their lives when the ship ran into an iceberg and sunk in frigid waters. The ship cost $7 million to build ($150 million in today's dollars).


# 9. Tanker Truck vs. Bridge - $358 Million



On August 26, 2004, a car collided with a tanker truck containing 32,000 liters of fuel on the Wiehltal Bridge in Germany . The tanker crashed through the guardrail and fell 90 feet off the A4 Autobahn resulting in a huge explosion and fire which destroyed the load-bearing ability of the bridge. Temporary repairs cost $40 million and the cost to replace the bridge is estimated at $318 Million.


# 8. MetroLink Crash - $500 Million



On September 12, 2008, in what was one of the worst train crashes in California history, 25 people were killed when a Metrolink commuter train crashed head-on into a Union Pacific freight train in Los Angeles . It is thought that the Metrolink train may have run through a red signal while the conductor was busy text messaging. Wrongful death lawsuits are expected to cause $500 million in losses for Metrolink..


# 7. B-2 Bomber Crash - $1.4 Billion




Here we have our first billion dollar accident (and we're only #7 on the list). This B-2 stealth bomber crashed shortly after taking off from an air base in Guam on February 23, 2008. Investigators blamed distorted data in the flight control computers caused by moisture in the system. This resulted in the aircraft making a sudden nose-up move which made the B-2 stall and crash. This was 1 of only 21 ever built and was the most expensive aviation accident in history. Both pilots were able to eject to safety.


# 6. Exxon Valdez - $2.5 Billion



The Exxon Valdez oil spill was not a large one in relation to the world's biggest oil spills, but it was a costly one due to the remote location of Prince William Sound (accessible only by helicopter and boat). On March 24, 1989, 10.8 million gallons of oil was spilled when the ship's master, Joseph Hazelwood, left the controls and the ship crashed into a Reef. The cleanup cost Exxon $2.5 billion.


# 5. Piper Alpha Oil Rig - $3.4 Billion



The world's worst off-shore oil disaster. At one time, it was the world's single largest oil producer, spewing out 317,000 barrels of oil per day. On July 6, 1988, as part of routine maintenance, technicians removed and checked safety valves which were essential in preventing dangerous build-up of liquid gas. There were 100 identical safety valves which were checked. Unfortunately, the technicians made a mistake and forgot to replace one of them. At 10 PM that same night, a technician pressed a start button for the liquid gas pumps and the world's most expensive oil rig accident was set in motion.
Within 2 hours, the 300 foot platform was engulfed in flames. It eventually collapsed, killing 167 workers and resulting in $3.4 Billion in damages.


# 4. Challenger Explosion - $5.5 Billion



The Space Shuttle Challenger was destroyed 73 seconds after takeoff due on January 28, 1986 due to a faulty O-ring. It failed to seal one of the joints, allowing pressurized gas to reach the outside. This in turn caused the external tank to dump its payload of liquid hydrogen causing a massive explosion.. The cost of replacing the Space Shuttle was $2 billion in 1986 ($4.5 billion in today's dollars). The cost of investigation, problem correction, and replacement of lost equipment cost $450 million from 1986-1987 ($1 Billion in today's dollars).


# 3. Prestige Oil Spill - $12 Billion



On November 13, 2002, the Prestige oil tanker was carrying 77,000 tons of heavy fuel oil when one of its twelve tanks burst during a storm off Galicia , Spain . Fearing that the ship would sink, the captain called for help from Spanish rescue workers, expecting them to take the ship into harbour. However, pressure from local authorities forced the captain to steer the ship away from the coast. The captain tried to get help from the French and Portuguese authorities, but they too ordered the ship away from their shores. The storm eventually took its toll on the ship resulting in the tanker splitting in half and releasing 20 million gallons oil into the sea.
According to a report by the Pontevedra Economist Board, the total cleanup cost $12 billion.


# 2. Space Shuttle Columbia - $13 Billion



The Space Shuttle Columbia was the first space worthy shuttle in NASA's orbital fleet. It was destroyed during re-entry over Texas on February 1, 2003 after a hole was punctured in one of the wings during launch 16 days earlier. The original cost of the shuttle was $2 Billion in 1978. That comes out to $6.3 Billion in today's dollars. $500 million was spent on the investigation, making it the costliest aircraft accident investigation in history. The search and recovery of debris cost $300 million.
In the end, the total cost of the accident (not including replacement of the shuttle) came out to $13 Billion according to the American Institute of Aeronautics and Astronautics.


# 1. Chernobyl - $200 Billion



On April 26, 1986, the world witnessed the costliest accident in history. The Chernobyl disaster has been called the biggest socio-economic catastrophe in peacetime history. 50% of the area of Ukraine is in some way contaminated. Over 200,000 people had to be evacuated and resettled while 1.7 million people were directly affected by the disaster. The death toll attributed to Chernobyl , including people who died from cancer years later, is estimated at 125,000. The total costs including cleanup, resettlement, and compensation to victims has been estimated to be roughly $200 Billion. The cost of a new steel shelter for the Chernobyl nuclear plant will cost $2 billion alone. The accident was officially attributed to power plant operators who violated plant procedures and were ignorant of the safety requirements needed.