“When we honestly ask ourselves which person in our lives mean the most to us, we often find that it is those who, instead of giving advice, solutions, or cures, have chosen rather to share our pain and touch our wounds with a warm and tender hand. The friend who can be silent with us in a moment of despair or confusion, who can stay with us in an hour of grief and bereavement, who can tolerate not knowing, not curing, not healing and face with us the reality of our powerlessness, that is a friend who cares.”
- Henri J.M. Nouwen
Anything that interests me finds place here. Software dominates my interests and hence a good part of this blog as well.
Thursday, July 22, 2010
A friend who cares
Friday, July 09, 2010
JSF request processing lifecycle in brief
1. Restore View Phase: For a new/fresh request, this phase creates a component tree starting with the UIViewRoot. For a post back request (a request from a previously generated JSF response), the component tree is restored (when state saving method is client, the tree is de-serialized from the request. When state saving method is server, the tree is restored from the server’s cache).
2. Apply Request Values Phase: The values held in the request are fetched and set on the appropriate components. At the end of this phase, the component tree has all the value submitted in the request. The server invokes processDecodes() on UIViewRoot and that call trickles down the entire tree invoking the decode() method on each component. ValueHolder and EditableValueHolder components update the component values and AcionSource components queue an ActionEvent for processing in further phases. If immediate attribute is “true”, validation happens at this phase.
3. Process Validation Phase: All component in the tree convert and validate their values (that was set in step 2). The server invokes processValidators() on the UIViewRoot (and that in-turn recursively invokes processValidators() on each component). Each component’s processValidators() invokes the converter and validators associated with the component. If a component fails conversion or validation, its valid property is set to false and a FacesMessage is queued (and rendered in render response phase).
4. Update Model Values Phase: The backing beans are updated with validated values in the component tree. The server invokes processUpdates() on UIViewRoot which invokes processUpdates() on each component. The processUpdates() method of UIInput types will invoke updateModel() which will update the backing bean.
5. Invoke Application Phase: Any action method or actionListener methods are invoked in this phase. In phase 2 these components would have queued an ActionEvent. The server invokes the processApplication() on UIViewRoot. This method will invoke the broadcast() method on each ActionSource in the component tree for each queued ActionEvent.
6. Render Response Phase: The encodeXX() method on each component is invoked. Each method uses its renderer to generate response and persist the component state so that it can restored in a future request.
Wednesday, July 07, 2010
ui:debug to inspect JSF component tree and UI state
On several occasions, it would be handy to view the component tree and view state.
The <ui:debug..> makes this possible. Using the plain tag with no attributes specified is the most simplest usage:
<ui:debug />
To view the The component tree, load the page holding this tag and press Ctrl+shift+d. This should bring up a new window. But Ctrl+shift+d happens to be a browser shortcut for “Organize bookmarks” in Firefox and the “Bookmark Manager” in Google Chrome. So we need to change the default hotkey which is done as follows:
<ui:debug rendered="true" hotkey="o"/>
Now reload the page and press Ctrl+shift+o. Now a new window opens with the “Component Tree” and “Scoped Variables”.
1. The component tree gives a inundated lists all UI components starting with UIViewRoot.
2. The scoped variables lists various beans in various scopes (e.g. Request Parameters, View Attributes, Request Attributes, Session Attributes, Application Attributes)
The rendered attribute can be used to turn off this feature in production.
Tuesday, July 06, 2010
String.split() trivia
The String.split() method converts a given string to an array based on a regular expression.
Examples:
System.out.println( Arrays.toString( "0:1::::".split( "[:]" ) ) ); // Output: [0, 1]
System.out.println( Arrays.toString( "::::4:5".split( "[:]" ) ) ); // Output: [, , , , 4, 5]
System.out.println( Arrays.toString( "0:1::::".split( "[:]", -1 ) ) ); // Output: [0, 1, , , , ]
As the documentation notes, “blah”.split(“:”) is the same as “blah”.split(“:”, 0) which does not include trailing empty strings.
Tuesday, June 29, 2010
Internet connection speeds
Internet connectivity technologies – fastest to slowest
1. Fiber optics
2. Cable
3. DSL
4. Dish
5. Dial-up
Friday, June 25, 2010
Unchecking a html radio button
Given the following code,
<input type="radio" value="PG" name="courseType" /> Post Graduate </input>
<input type="radio" value="UG" name="courseType" /> Under Graduate </input>
To check the "PG" html radio button in jQuery:
jQuery(blahBlahBlah).attr('checked', 'true');
To uncheck it:
jQuery(blahBlahBlah).removeAttr('checked');
Note: the following will **NOT WORK**
jQuery(blahBlahBlah).attr('checked', 'false');
jQuery(blahBlahBlah).attr('checked', '');
Monday, June 21, 2010
Tomorrow is always fresh with no mistakes in it.
“Tomorrow is always fresh with no mistakes in it.”
- Anne of Green Gables through Julie911
You know, I think you try a little harder when you're scared.
“You know, I think you try a little harder when you’re scared.”
- Rocky Balboa through Julie911
Sunday, June 20, 2010
Knowing to read
"Yes."
"I can't read it," he said. "I can't read anything. This is the greatest sadness of my life. I'll do anything so the children of my village never have to know this feeling. I'll pay any price so they have education they deserve"
...Mortenson says "...Here was this illiterate man, who'd hardly ever left this little village in the Karakoram,"..."yet he was the wisest man I've ever met."
- From "Three Cups of Tea" by Greg Mortenson and David Oliver Relin
The oppressor benefits for the day, the oppressed - for life
Twaha leaned toward Mortenson. "This man Haji Mehdi. No good." he whispered.
Mortenson was already acquainted with Haji Mehdi, the nurmadhur of Askole. "He made a show of being a devout Muslim," Mortenson says. "But he ran the economy of the whole Braldu Valley like a mafia boss. He took a percentage of every sheep, goat, or chiken the Balti sold, and he ripped off climbers, setting outrageous prices for supplies. If someone sold so much as an egg to an expedition without paying him his cut, Haji Mehdi sent his henchmen to beat them with clubs."
... Mehdi ...said ..."I have heard that an infidel has come to poison Muslim children, boys as well as girls, with his teachings....Allah forbids the education of girls. And I forbid the construction of this school."
"We will finish out school," Haji Ali said evenly. "Whether you forbid it or not."
....
"And you, are you not a muslim?" Medhi said, turning menacingly toward Haji Ali. "There is only one God. So you worship Allah? Or this kafir?"
Haji Ali clapped his hand on Mortenson's shoulder. "No one else has ever come here to help my people. I 've paid you money every year but you have done nothing for my village. This man is a better Muslim then you. He deserves my devotion more than you do."
"If you insist on keeping your kafir school, you must pay a price" Medhi said,..."I demand twelve of your largest rams"
"As you wish," Haji Ali said, turning his back on Mehdi, to emphasize how he had degraded himself by demanding a bribe....
"You have to understand, in these villages, a ram is like a firstborn child, prize cow and family pet all rolled into one"...
....
'It was one of the most humbling things I've ever seen," Mortenson says, "Haji Ali had just handed over half the wealth of the village to this crook, but he was smiling like he'd just won a lottery."
..."Don't be sad...Long after all those rams are dead and eaten this school will still stand. Haji Hehdi has food today. Now our children have education forever"
- From "Three Cups of Tea" by Greg Mortenson and David Oliver Relin
Friday, June 11, 2010
JSF 2.0 - Automatic resource bundle resolution
...
JSF 2.0 Templating
Element 1. Template
Element 2. Section ContentsNot standard terminology
</html>
Element 3. Composition
The composition brings the template (template.xhtml in this example) and section contents (login.xhtml) together by specifying which section contents (each in its own xhtml) should go into which sections (defined in the template)Wednesday, June 09, 2010
I can choose my thoughts
“There is so much about my fate that I cannot control, but other things do fall under the jurisdiction. I can decide how I spend my time, whom I interact with, whom I share my body and life and money and energy with. I can select what I can read and eat and study. I can choose how I’m going to regard unfortunate circumstances in my life — whether I will see them as curses or opportunities. I can choose my words and the tone of voice in which I speak to others. And most of all, I can choose my thoughts.”
- Elizabeth Gilbert: Eat, Pray, Love through Julie911
other people's way of living
“I’ve learned about other people’s way of living: how you cope with life’s challenges, how you celebrate good times, how you feel about issues, how awesomely goofy some of you are, and how, in the end, we all truly just want the same thing: to love and be loved, to understand and be understood, to leave this world knowing that we mattered and made a difference. We are all different, but so much alike.”
- Julie911
Wednesday, May 26, 2010
Learning
A Chinese saying:
I hear and I forget
I see and I remember
I do and I understand
Try to make sure your study is uninterrupted. You will need to find both the time and place where you can study.
It is important to remember that learning is not a race – everyone learns at their own rate. So don’t rush your leaning – make sure you get the most from the book.
- An introduction to derivatives
Monday, May 24, 2010
Friday, May 21, 2010
Searching for more proof is futile. Searching for more determination makes more sense.
“That's the way a friend described someone she had just met. She was sure (just as I'm sure) that he's going places. Once the determination is in his eyes, the learning will take care of itself.
On the other hand, if I can see the fear in your eyes, then I'm not sure that learning alone will take care of the problem. No one can prove that the path you're on is risk free or guaranteed to work. Searching for more proof is futile. Searching for more determination makes more sense.”
- Seth Godin
Thursday, May 20, 2010
I'd learned long ago how to leave things behind without regret
I'd learned long ago how to leave things behind without regret – Tony Kahn
Tuesday, May 18, 2010
Multiple tabs in gvim
The following will open all xml files found in the current directory (and its sub-directories) in multiple tabs in gvim
$ find . -name '*.xml' | xargs gvim -p
Thursday, May 13, 2010
The ability to choose who judges your work...is the key building block in becoming an artist in whatever you do.
Here's the mistake we make in high school:
We let anyone, just anyone, judge our work (and by extension, judge us.)
Sue, the airheaded but long-legged girl in Spanish class gets the right to judge our appearance.
Bill, the bitter former-poet English teacher gets the power to tell us if we're good at writing.
And on and on.
The cheerleaders are deputized as the Supreme Court of social popularity, and the gym teacher forever has dibs on whether or not we're macho enough to make it in the world. These are patterns we sign up for, and they last forever (or until we tell them to go away).
In high school, some people learn to ship, they learn to do work that matters and most of all, they learn to ignore the critics they can never possibly please. The ability to choose who judges your work--the people who will make it better, use it and reward you--is the key building block in becoming an artist in whatever you do.