Monday, December 31, 2012

Difference between @Autowire and @Resource

1. @Resource is part of JSR-250. @Autowire is part of Spring framework.
2. @Resource can inject by name only(to inject into a field named "xyz" look for a bean named "xyz"). @Autowire can inject by name, type(to inject into a field/parameter of type "Abc", look for a unique bean of type "Abc") and many more.
3. @Resource can inject into a field only. @Autowire can inject into field, constructor and method parameters.
3. @Resource can inject List, Map and other Collection types. @Autowire cannot.

Sources: [1] [2]

Monday, December 24, 2012

Wave and water

" To represent the two dimensions of reality, we use the images of the wave and water. Looking at the dimension of the wave, the historical dimension, we see that the wave seems to have a beginning and an end. The wave can be high or low compared with other waves. The wave might be more or less beautiful than other waves. The wave might be there or not there; it might be there now but later not there. All these notions are there when we first touch the historical dimension: birth and death, being and nonbeing, high and low, coming and going, and so on. But we know that when we touch the wave more deeply, we touch water. The water is the other dimension of the wave. It represents the ultimate dimension.
...

If the wave is capable of touching the water within herself, if the wave can live the life of water at the same time, then she will not be afraid of all these notions: beginning and ending, birth and death, being or non-being; non-fear will bring her solidity and joy. Her true nature is the nature of no-birth and no-death, no beginning and no end. That is the nature of water."

- Thich Nhat Hanh

I have arrived, I am home

"I have arrived, I am home
In the here, in the now
I am solid, I am free
In the ultimate I dwell.

...
You can recite the poem above as you breathe in and out. You can practice this poem when you drive to your office. You may not have arrived at your office, but even while driving you have already arrived at your true home, the present moment. When you arrive at your office, this is also your true home. In your office, you are also in the here and now. Just practicing the first line of the poem, “I have arrived, I am home,” can make you very happy."

- Thich Nhat Hanh

We cannot enjoy life if we worry

"We cannot enjoy life if we spend our time and energy worrying about what happened yesterday and what will happen tomorrow. If we’re afraid all the time, we miss out on the wonderful fact that we’re alive and can be happy right now. "

- Thich Nhat Hanh

Thursday, December 20, 2012

Our real home is peace.

"This house you’re living in: You and your husband built it. Other people can build houses, too, making them large and lovely. Those are outer homes, which anyone can build. The Buddha called them outer homes, not your real home. They’re homes only in name.

Homes in the world have to fall in line with the way of the world. Some of us forget. We get a big home and enjoy living in it, but we forget our real home. Where is our real home? It’s in the sense of peace. Our real home is peace."

- Ajahn Chah Subhaddo

Tuesday, November 06, 2012

Gifts of time and love

Gifts of time and love are surely the basic ingredients of a truly merry Christmas.

- Peg Bracken

Saturday, November 03, 2012

Motives Leading to a Poor Conversations

1. "Wanting to win. (The) desire to win is built into our very fiber before we're old enough to know what's going on... Unfortunately, as we grow older, most of us don't realize that the desire to win is continually driving us away from healthy dialogue. We start out with the goal of resolving a problem, but as soon as someone raises the red flag of inaccuracy or challenges out correctness, we switch purposes in a heartbeat"
2. "Seeking revenge. Sometimes, as our anger increases, we move from wanting to win the point to wanting to harm the other person... (response is) Everyone immediately clams up and looks at the floor."
3. "Hoping to remain safe... Rather than add to the pool of meaning, and possibly make waves along the way, we go to silence. We're so uncomfortable with the immediate conflict that we accept the certainty of bad results to avoid the possibility of uncomfortable conversation. We choose... peace over conflict.(the objective of the conversation is not met)"

- "Crucial Conversations - Tools for talking when stakes are high"

Maintaining Composure Under Fire

To maintain composure under fire ask yourself "what do I really want here?"

"What do I really want?... it's not to make the other person squirm or to preen in front of a crowd. I want " your actual objective of having the conversation (such as cut cost).

"When we ask ourselves what we really want,... the problem solving part of our brain recognizes that we are now dealing with intricate social issues and not physical threats."

"Once you've asked yourself what you want, add one more equally telling question:

How would I behave if I really wanted these results?"

- "Crucial Conversations - Tools for talking when stakes are high"

Work on Me First

'Although it's true that there are times when we are merely bystanders in life's never-ending stream of head-on collisions, rarely are we completely innocent... People who are best at dialogue understand this simple fact and turn it into the principle "Work on me first."...As much as others may need to change, or we may want them to change, the only person we can continually inspire, prod, and shape--with any degree of success--is the person in the mirror...People who believe they need to start with themselves...become the most skilled at dialogue. It's the most talented, not the least talented, who are continually trying to improve their dialogue skills.'

- "Crucial Conversations - Tools for talking when stakes are high"

Difficulty with Crucial Conversations

"We either anticipate a crucial conversation or are in the middle of one and we're at our absolute worst -- we  yell; we withdraw; we say things we later regret... That's because emotions don't exactly prepare us to converse effectively. Countless generations of genetic shaping drive humans to handle crucial conversations with flying fists and fleet feet, not intelligent persuasion and gentle attentiveness... Tow tiny organs seated neatly atop your kidneys pump adrenaline into your bloodstream. You don't choose to do this. Your adrenal glands do it, and then you have to live with it... Your brain diverts blood... (and) the higher level reasoning sections of your brain get less (blood). As a result, you end up facing challenging conversations with the same equipment available to a rhesus monkey."

- "Crucial Conversations - Tools for talking when stakes are high"

When Talking Turns Tough

When talking turns tough, do we pause, take a deep breath, announce to out innerselves, "Uh-oh, this discussion is crucial. I'd better pay close attention" and then trot out our best behavior(minding one's Ps and Qs)?

- "Crucial Conversations - Tools for talking when stakes are high"

Pattern of Behavior in Conversations

"If you handle even a seemingly insignificant conversation poorly, you establish a pattern of behavior that shows up in all of your crucial conversations."

- "Crucial Conversations - Tools for talking when stakes are high"

Effects of Communication Failure

"The void created by the failure to communicate is soon filled with poison,drivel(Silly nonsense) and misrepresentation.
-- C. Northcote Parkinson"

- "Crucial Conversations - Tools for talking when stakes are high"

Monday, October 22, 2012

Appealing for not being famous

"It is a kind of nowhere, (place where the author is riding his bike) famous for nothing at all and has an appeal because of just that "

- Robert M. Pirsig in "Zen and the art of motorcycle maintenance"

Friday, June 29, 2012

Thursday, June 28, 2012

"Real peace of mind must come through inner mental strength."

"Money is the top most important (thing) for value of our life. This is, I think, wrong. The material facility can provide only physical comfort. Through physical comfort mental satisfaction is false, delusion. Real peace of mind must come through inner mental strength."


- Dalai Lama

Monday, June 04, 2012

Thursday, May 31, 2012

Tuesday, May 29, 2012

Programming is a knowledge intensive activity, and good programmers know a lot

Programming is a knowledge intensive activity, and good programmers
know a lot.


Ralph Johnson 

Words and meaning

"The software industry delights in taking words and stretching them into a myriad of subtly contradictory  meanings."

- Martin J Fowler in "Patterns of Enterprise Application Architecture"

Saturday, May 19, 2012

Friday, April 27, 2012

The master - Destiny or Man?


"Look! the clay dries into iron, but the potter moulds the clay:-
Destiny to-day is master - Man was master yesterday."

- Toru Dutt

Wednesday, April 25, 2012

Creativity is the residue of time wasted.

Creativity is the residue of time wasted.


Albert Einstein through copyblogger

Tuesday, April 24, 2012

In the attitude of silence...

“In the attitude of silence the soul finds the path in a clearer light, and what is elusive and deceptive resolves itself into crystal clearness.”


- Mahatma Gandhi through A Flourishing Life

Thursday, April 05, 2012

Bad reactions and faults

If somebody acts un-reasonably to you, its their fault.
But if you react un-reasonably in response to their fault, your bad response is completely your fault. They did not control you to give out that un-reasonably response.

Wednesday, April 04, 2012

I have never found anger to make a situation better

"I have never found anger to make a situation better"

- Prof. Randy Pausch 

I can't control the card that I am dealt just how I play the hands

"I can't control the card that I am dealt just how I play the hands"

- Prof. Randy Pausch 

Its not about how you achieve your dreams its about how you lead your life

"Its not about how you achieve your dreams, its about how you lead your life. If you lead your life the right way, the karma will take care of itself, dreams will come to you."

- Prof. Randy Pausch  

Brick walls let us show our dedication

"Brick walls let us show our dedication. They are there to separate us from the people who don't REALLY want to achieve their ... dreams."

- Prof. Randy Pausch 

Wednesday, March 21, 2012

Null values in Postgresql date comparison


test=# begin;
BEGIN
test=# create temp table test(test_date date) on commit drop;
CREATE TABLE
test=# insert into test(test_date) values (null);
INSERT 0 1
test=# insert into test(test_date) values (current_date - interval '1 day');
INSERT 0 1
test=# insert into test(test_date) values (null);
INSERT 0 1
test=# select case when test_date < current_date then 'less' else 'nope' end, coalesce( test_date::varchar, 'NULL') from test;
 case |  coalesce  
------+------------
 nope | NULL
 less | 2012-03-20
 nope | NULL
(3 rows)

Saturday, February 11, 2012

It’s not hard to decide what you want your life to be about. What’s hard, she said, is...


“It’s not hard to decide what you want your life to be about. What’s hard, she said, is figuring out what you’re willing to give up in order to do the things you really care about.”

- “Bittersweet” by Shauna Niequist through Julie911

Maintaining character in every moment


My understanding:

Not all horses are skilled at being swift
Not all dogs are skilled at sniffing
Since I am naturally dull, shall I, for that reason, not take pains?
NO. One should continue to take pains.

I may not be the best body builder in the world, yet, I will not neglect my body.
I may not be the best rich man in the world, yet, I will not neglect my property

In short we do not neglect looking after anything because we despair(loose hope or complete absence of hope) of reaching the highest degree.

- A Selection From The Discourses of Epictetus With The Encheiridion

Thursday, February 02, 2012

Strong, Weak, Soft and Phantom references in Java

The following code instantiates an instance of Student class in the heap and references the created instance from the stack variable s.

Student s = new Student();

The instantiated Student object remains in the heap until it is reachable by at least one reference to it. When the garbage collector runs after the last object reference has been removed, the object is deleted from heap. 

In the above example, s is a strong reference to the Student object. The garbage collector will not remove objects that have a strong reference.

When strong references fall short
There are times when a object should be marked as garbage collectible even when there are active references to it. For example, consider a large image object held in a in-memory cache. This image object should remain in the heap as long as the caching API's clients have reference to the image object. But if the caching API uses strong references, the image object will never get garbage collected as there will always be a strong reference to the image object from the cache itself. Enter weak references.

In the above caching example, the caching API should use a WeakReference. A weak reference "is a reference that isn't strong enough to force the object to remain in memory".

WeakReference weakStudent = new WeakStudent(new Student());

weakStudent.get(); // Returns actual Student object

The weakStudent.get() call could potentially return null if there are no strong references to the Student object.

A WeakHashMap is similar to HashMap except that the keys (not values) are referred to using weak references. So when there are no other Strong references to a key, it will be removed from the map.

Once WeakReference.get() starts returning null, the reference has become garbage collectible and the WeakReference is of no good. The ReferenceQueue class helps keep track of such garbage collectible references and should be passed as argument to WeakReference's constructor. When a object becomes garbage collectable, it will be placed in the ReferenceQueue. The application can read this queue from time to time and perform clean up on its end.

Degrees of weakness
A WeakReference is only one flavor of weakness. There are 2 more flavors:
1. SoftReference - This is less weak than a WeakReference. In a WeakReference, the referenced object is garbage collected the next time garbage collector runs, irrespective of whether memory is in shortage or not. A SoftReference is garbage collected only when memory is in short supply.
2. PhantomReference - This is stronger than a WeakReference. Its get() method always returns null. Its only use is to figure out when the object is enqueued into ReferenceQueues. For a WeakReference, the object is queued as soon as its only weakly reachable. Even before finalization and actual garbage collection. For PhanthomReference, the object is queued only after the object is physically removed from memory.