Thursday, January 19, 2012

The Law of Requisite Variety

"The variety in the control system must be equal to or larger than the variety of the perturbations in order to achieve control"

This simply means that a flexible system with many options is better able to cope with change. One that is tightly optimized for an initial set of conditions might be more efficient whilst those conditions prevail but fail totally should conditions change.

http://www.wyrdology.com/mind/creativity/variety.html

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;
    }
}