Saturday, September 10, 2011

How to debug XSLT with Visual Studio

Evaluating and debugging XSLT with visual studio is a very simple task and very useful in developing XSLT.

Evaluating xslt with VS.

Open the xslt file using visual studio and then select show xslt output option from XML menu.

image

It will show a browse option to select the input xml for the processing. Next will will show the output xml in another tab.

image

Debugging XSLT with VS

For debugging xslt, all you have to do is to set a break point on the xslt and select bebug xslt option from the XML Menu.

image

Saturday, August 13, 2011

NLP Eye Accessing cues

NLP (Neuro-Linguistic Programming)  was developed by Richard Bandler and linguist John Grinder, and they believed that NLP will be useful in "finding ways to help people have better, fuller and richer lives"

There are usual meanings to the eye moment. By observing the eye movement, it is possible to tell “which sensory systems” are accessed.

1. Up and to the left usually means that a person is remembering something visually

eye_acc_vrec

2. Up and to the right usually means that a person is imagining something visually

eye_acc_vcon

3. Left side usually means a remembered sound

eye_acc_Arec

4. Right side  usually means an imagined sound

eye_acc_Acon

5.  Down right (which is down right obvious!) usually means that a person is accessing a bodily feeling or emotion.

eye_acc_K

6. Down left usually means that a person is accessing internal dialogue

eye_acc_loop

Lying

Note that venerable proverb: Children and fools _always_ speak the truth. The deduction is plain --adults and wise persons _never_ speak it. Parkman, the historian, says, "The principle of truth may itself be carried into an absurdity." In another place in the same chapters he says, "The saying is old that truth should not be spoken at all times; and those whom a sick conscience worries into habitual violation of the maxim are imbeciles and nuisances." It is strong language, but true. None of us could _live_ with an habitual truth-teller; but thank goodness none of us has to. An habitual truth-teller is simply an impossible creature; he does not exist;he never has existed. Of course there are people who _think_ they never lie, but it is not so--and this ignorance is one of the very things that shame our so-called civilization. Everybody lies--every day;every hour; awake; asleep; in his dreams; in his joy; in his mourning; if he keeps his tongue still, his hands, his feet, his eyes, his attitude, will convey deception--and purposely.

- Mark Twain

http://grammar.about.com/od/60essays/a/lyingessay.htm

Wednesday, August 3, 2011

Dealing with MySql passwords

1. If the current root password needs to be changed

mysqladmin -u root -pcurrentpassword password newpassword

2. To Setup a root password, if a password was not setup

mysqladmin -u root password NEWPASSWORD

3. Changing the old password by using sql commands

In mysql, user data is kept in the user table of mysql database. Hence it is  possible to directly update or change passwords for users.

Step1. Login to db.

mysql –u root –p

Step2. Use mysql db

mysql> use mysql;

Step3. Change password.

mysql> update user set password=PASSWORD("newpass") where User='root';

Step4. Reload privileges

mysql> flush privileges;

Tuesday, August 2, 2011

Pride

Here lies Jan Smith,
Wife of Thomas Smith, Marble Cutter.
This monument was erected by her
husband as a tribute to her memory
and a specimen of his work.
Monuments of this same style are
two hundred and fifty dollars.

          epitaph composed by a marble cutter

Sunday, July 31, 2011

How to write a custom registry handler to handle associations

WSO2 Registry is a content repository which provides set of abstractions over a raw relational db. Registry provides a rich set of features for storing, managing and finding resources/content. However, sometimes, one have to go beyond existing default functionality to implement custom behavior to suite specific requirements. Handlers and Filters are such an extension point of registry which allows users to implement customizations by write small about of code.

A handler is written by extending the Handler class and overriding its necessary methods. Custom handler is registered with the registry by putting an entry in the registry.xml

public class CustomHandler extends Handler {
public void addAssociation(RequestContext requestContext) throws RegistryException {}
public void removeAssociation(RequestContext requestContext) throws RegistryException{}
}

<handler  class="org.wso2.carbon.regisry.samples.handler.CustomHandler">
<filter class="org.wso2.carbon.registry.samples.handler.CustomMediaTypeMatcher">
<property name="mediaType">mytype</property>
</filter>
</handler>

In order to invoke our CustomHandler, we have defined a custom media type and a CustomMediaTypeMatcher class. CustomMediaTypeMatcher class should extend the MediaTypeMatcher class. 

When a resource with media type mytype is added to the registry, associated registry filter classes will be called to perform an evaluation and based on its result, associated handlers will be invoked.

In our scenario, we want to invoke the methods addAssociation, and removeAssocation when a resource is associated with a resource which has the media type “mytype”. The code sample for the CustomMediaTypeMatcher class to handle it is shown below.

public class CustomMediaTypeMatcher extends MediaTypeMatcher{
public boolean handleAddAssociation(RequestContext requestContext)
            throws RegistryException {
        Resource resource = requestContext.getRepository().get(requestContext.getSourcePath());
        if (resource != null) {
            String mType = resource.getMediaType();
            return mType != null && (invert != mType.equals(getMediaType()));
        }
        return false;
    }

    public boolean handleRemoveAssociation(RequestContext requestContext)
            throws RegistryException {
        Resource resource = requestContext.getRepository().get(requestContext.getSourcePath());
        if (resource != null) {
            String mType = resource.getMediaType();
            return mType != null && (invert != mType.equals(getMediaType()));
        }       return false;
    }
}

Happiness and Sadness

Types of Happiness: Emotion and Sentiment

It is not easy to find happiness in ourselves, and impossible to find it elsewhere.
—Agnes Repplier

What do you take me for, an idiot?
—General Charles de Gaulle, when a journalist asked him if he was happy.

A distinction can be made between two major types of happiness. A long term sentiment of happiness (flourishing, well-being) and a short term emotion of happiness ( Joy, satisfaction).

As an emotion, happiness is a short-term state of pleasure or satisfaction occurring as a result of ( real or imaginary ) positive changes.

A steady diet of simple pleasures will keep you above your set point. Find the small things that you know give you a little high—a good meal, working in the garden, time with friends—and sprinkle your life with them. In the long run, that will leave you happier than some grand achievement that gives you a big lift for a while. - David Lykken

It was found that those people who are relatively the happiest now will be the happiest ten years from now, despite day to-day fluctuations.

Determinants of Happiness

It is pretty hard to tell what does bring happiness; poverty and wealth have both failed.
—Kin Hubbard
We are no longer happy as soon as we wish to be happier.
—Walter Savage Landor

Happiness can be experienced as a result of being focus on an activity and not the result. Happiness is then to be found in activities we value in themselves.

"It's the hunt—not the money—that makes my blood race; after all, you can only sleep in one bed at a time, and drive one car at a time”

- Chris Verbiski

Happiness depends on the way we act than the specific result of our activities.

Happiness “arises more from the pursuit than from the attainment of any end
whatever”. It "depends more on the degree in which our minds are properly
employed, than it does on the circumstances in which we are destined to act, on the materials which are placed in our hands, or the tools with which we are furnished."

Linking happiness to an attainment of goal results in unhappiness than happiness and in the end when the goal is achieved, we may not actually enjoy it as much as expected. It may be due to the fact that original circumstances may have changed by the time achievement is obtained or the expectation and reality gap. 

“There are two tragedies in life. One is not to get your heart's desire. The other is to get it” - George Bernard Shaw

Post coitum omne animal triste est —"After sexual intercourse every animal is sad"

Maintaining Long-Term Happiness

Happiness is not a state to arrive at, but a manner of traveling.
—Margaret Lee Runbeck

The happiness of most people we know is not ruined by great catastrophes or fatal errors, but by the repetition of slowly destructive little things.
—Ernest Dimnet

Dealing with the baseline (expectation)  and reality (current situation) gap can be done by (a)  eliminating the gap by changing the baseline or reality (b) coping with the gap by changing our attitude toward it.

Sadness
One can endure sorrow alone, but it takes two to be glad.
—Elbert Hubbard
It is our job to make women unhappy with what they have.
—B. Earl Puckett, an advertiser

Sadness confirms our appraisal of things as valuable; hence it may happen that we take pride in our ability to feel sadness.

When it gets dark enough you can see the stars

Grief
Let us so live that when we come to die, even the undertaker will be sorry.
—Mark Twain

Grief is the most profound type of sadness. It is concerned with death, the most substantial misfortune we encounter: it expresses the irrevocable loss of someone very close and of great value to us.

Moral Value

Happiness, it is said, is seldom found by those who seek it, and never by those
who seek it for themselves.
—F. Emerson Andrews

Thousands of candles can be lighted from a single candle, and the life of the candle will not be shortened. Happiness never decreases by being shared.
—Buddha

Sorrow makes men sincere.
—Henry Ward Beecher
If a way to the better there be, it lies in taking a full look at the worst.
—Thomas Hardy

Happiness is often achieved through positive illusions; in sadness, reality is better known. Sadness is unpleasant, but it is morally valuable for committing ourselves to the more profound moral obligations. Happiness is also morally valuable but for different reasons: its main value is in helping us to perform the "small" everyday moral deeds.

Source: The Subtlety of Emotions.