Monday, October 6, 2014

Public wsdl for testing

We do need public available wsdls sometime over internet with out writing our own, the below site helps exactly what you want...

Please check: http://www.service-repository.com/


Thursday, October 2, 2014

Resetting mysql root password in Unix or Linux systems!

These are the quick steps you can proceed to reset the mysql password in Linux or Unix.
  1. Stop the mysql server
  2. Create a file in /tmp with filename:mysql-init with the content as below:
  3. UPDATE mysql.user SET Password=PASSWORD('80odP@s5') WHERE User='root';
    FLUSH PRIVILEGES;
  4. Execute the below command to start the MySQL with the new paasword
    mysqld_safe --init-file=/tmp/mysql-init &
  5. After the server has started successfully, delete /tmp/mysql-init. 
  6. Now try to log-in to MySQL with the new password.

 Happy coding!

Thursday, September 18, 2014

Maven source plugin

The best way to generate the source jar along with the classes using maven is using the below plugin.

Just keep this plugin in the build tag as shown below:

    <build>
         <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.1.2</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


Have fun!

Wednesday, September 17, 2014

Building the wso2 products

I was wondering how to build the wso2 products mainly IS and AM, I found them as very easy after talking to a friend Thanuja, one of the developers of IS in wso2.

There are 3 steps to follow to build:
  1. Build and install Kernal.
  2. Build and install Orbit.
  3. Build and install Chunk-11.
Do all those in order from the given below svn repo:
https://svn.wso2.org/repos/wso2/carbon

Most important thing is you have to do this with java: 1.6 and maven: 3.0.5.release versions only.


The 3rd step builds all the products by default, if you don't want all the products, then comment the unnecessary products in given files:
  1. components/pom.xml
  2. dependencies//pom.xml 
  3. features/pom.xml 
  4. products//pom.xml

Have fun :)

What is "final" keyword in java


The "final" is reserved keyword in java, hence can't be used it as a variable name or class name or any method name.
final is used at different places in different contexts. I illustrate the usage and essential meaning of this keyword in different contexts.

 There would be 4 different contexts, they are:

  1. Applying final keyword for a class, in class definition.
  2. Applying in a method definition.
  3. Using final keyword in a variable definition.
  4. It is used to access the variable inside an anonymous class.

Advantages of final keyword:
  • The "final" keyword is used for high performance.
  • Using final for caching the values of variables and objects.
  • It is used for static class binding.
  • It is used to variables which will be involving in multi-threading, since final resources can be accessed safely without any synchronization.
  • It helps the JVM in optimizing the classes, methods and variables.

Thursday, March 27, 2014

Free online education websites

There are many websites available for free education and learning. Really hats off to all of them..

When I searched the google for online free websites.. found alot... but I got a good link from Dunith D which has a good collection of websites.. Here is the list..


This is taken from Dunith.D .

Thanks to Dunith.

Sunday, March 23, 2014

Ant - downloading a file in ant.


<!-- To display the complete path of the files -->
<dirset id="dirs" dir="${maven_app_dir}" includes="*"/>
<pathconvert dirsep="/" pathsep="," property="dirs" refid="dirs"/>
<echo message="${dirs}"/>

<!-- <target name="bootstrap">
        <mkdir dir="${user.home}/.ant/lib"/>
        <get dest="${user.home}/.ant/lib/ant-contrib.jar" src="http://search.maven.org/remotecontent?filepath=ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
<echo message="ha ha " />
    </target> -->

Thursday, March 20, 2014

How to add custom html signature to the microsoft office outlook in 2007


If you are getting frustrated in adding a custom html message as a signature, then we both are same group... :)

This is the quickest and very powerful way of adding the signature.

Open C:\Users\{username}\AppData\Roaming\Microsoft\Signatures\{fileName} and select {fileName} and add the signature. Restart Office ... and enjoy.


Have fun.

Monday, November 18, 2013

== vs equals in java

/**
 *
 * TODO Description go here.
 *
 * @author <a href="mailto:varra@outlook.com">Rajakrishna V. Reddy</a>
 * @version 1.0
 *
 */
public class StringManual
{
   
    /**
     * The main method.
     *
     * @param args
     *            the arguments
     */
    public static void main(String[] args)
    {
        String s1 = "foo"; //Creates a string in String constant pool rather in heap. [Happens the same for all strings created as ""]
        String s2 = "foo"; // String constant pool will not create a new string as there is already a string with the same content S1, so s2 points to the s1 i.e s2=s1.
       
        System.out.println(s1 == s2); // TRUE: because s2=s1, both references are same i.e s1.
        System.out.println(s1.equals(s2)); // TRUE: based on content.
       
        String s3 = new String("foo"); //Creates a string in heap. [Happens the same for all strings created as new String.]
        System.out.println(s1 == s3); // FALSE: because both references are not same i.e s1 is in constant pool and s3 is in heap.
        System.out.println(s1.equals(s3)); // TRUE: based on content.
    }
}

Wednesday, June 19, 2013

Script to calculate the logIn time in linux

This is could be very useful when you need to calculate the logIn time for attendance/swipes. Here it goes.


#!/bin/bash

. ~/.bash_functions

function updateLogInTime()
{
    file=$1
    fullDate=`date +"%d-%m-%Y %H:%M:%S"`
    today=`date +"%d-%m-%Y"`;
    todayEntry=`grep $today $1`;
    now=`date +"%H:%M:%S"`;
    nowInSecs=`tounixtime`
    if [ -z "$todayEntry" ]; then
       echo "UpdatedAt: $fullDate, In: $now/$nowInSecs, Out: $now/$nowInSecs, Total: `date -u -d @"0" +'%-H:%-M:%-S'`" >> $file;
    else
       tokens=( `getTokens "$todayEntry" ,` )
       # use for loop read all fields
       for (( i=0; i<${#tokens[@]}; i++ ))
       do
           token=${tokens[i]}
           case $token in
                UpdatedAt:)
                        updatedTodayEntry="$updatedTodayEntry $token $fullDate";;
                In:)
                        inTimeToken=${tokens[i+1]};
                        inTimeTokens=( `getTokens "$inTimeToken" /` );
                        inTime=${inTimeTokens[1]};
                        updatedTodayEntry="$updatedTodayEntry, $token $inTimeToken";;
                Out:)
                        updatedTodayEntry="$updatedTodayEntry, $token $now/$nowInSecs";;
                Total:)
                        diff=`calc $nowInSecs-$inTime`;
                        updatedTodayEntry="$updatedTodayEntry, $token `date -u -d @"$diff" +'%-H:%-M:%-S'`";;
           esac
       done
       updatedTodayEntry=`trim $updatedTodayEntry`
       sed -i s%"${todayEntry}"%"${updatedTodayEntry}"%g $file
    fi
}

function main()
{
     screenLocked=`isScreenLocked`;
     if [ $screenLocked -eq 0 ]; then
        updateLogInTime /krishna/Misc/Notifications/data/logInTime.db
     fi
}

main

Happy Coding!