Recursion and Tail Recursion

Consider a simple factorial function
Here is a simple Java implementation that uses recursion:
public void factorial(int n)
       if (n <= 1)
            return 1;
        else {
               return n*factorial(n-1);

If you called factorial(5), this is how recursion evaluate.
5 * factorial(4)
5 * (4 * factorial(3))
5 * (4 * (3 * factorial(2)))
5 * (4 * (3 * (2 * factorial(1))))
5 * (4 * (3 * (2 * 1)))
Note how every recursive call has to complete before the java interpreter begins to actually do the work .
Here's a tail-recursive version of function that add N Integers.
public static int sum(int a,int b)
                    if ( a == 0 )
                           return b;
                           return sum(a-1,b+a);

Here's the sequence of events that would occur if you called sum(5,0).
sum(5, 0)
sum(4, 5)
sum(3, 9)
sum(2, 12)
sum(1, 14)
sum(0, 15)
In the tail-recursive case, with each evaluation of the recursive call, the b is updated.


Robotframework running on jenkins CI

This is sample video which running Robotframework project on Jenkins CI , On request I will provide Full tutorials .


Installing rails on ubuntu

Ruby on Rails is one of the most popular application stacks for developers wishing to create sites and web apps. The Ruby programming language, coupled with the Rails development framework, makes app development simple.

Since Ruby on Rails doesn't come in a neatly packaged format, getting the framework installed used to be one of the more difficult parts of getting started. Luckily, tools like rvm, the Ruby Version Manager, have made installation simple.

Before any other step install mpapis public key (might need gpg2) (see security)

gpg --keyserver hkp:// --recv-keys 

Install RVM (development version):

\curl -sSL | bash

 you need to do is source the rvm scripts by typing:

source ~/.rvm/scripts/rvm

The Quick Way

The quickest way of installing Ruby on Rails with rvm is to run the following command as a regular user:

\curl -sSL | bash -s stable --rails

You will be prompted for your regular user's password as part of the installation procedure.

The Long way

If you need to install specific versions of Ruby for your application, you can do so with rvm like this:

rvm install ruby_version

After the installation, we can list the available Ruby versions we have installed by typing:

rvm list

We can switch between the Ruby versions by typing:

rvm use ruby_version

For Installing rails

gem install rails

symbols in ruby

Symbols are good way to save memory,What's that mean?. When object is created each time in ruby it is allocated with a memory,when we instantiate same object again and again it will also create a additional new memory.But symbols don't lets look in to a example

When ever we instantiated the same object in each time the object_id of that string object gives different memory locations but in case of symbols memory location are same.Thats means symbols can hold the same for each call but string cannot.

Integers and floats in ruby

Numbers in ruby are divided in to integers and floating point number and they are called Decimal numbers.You can do all kinds of mathematic operations in ruby.

These are integer operation Bignum and fixnum are two subclass of integers

Floating numbers are decimal numbers always returns a floating number.

variable in ruby

Variables are temporal space for assigning a value in programs.It is like when we assign value in some variable in algebraic equation back in schools.In ruby we can assign any value in to variable.

Here x = 10 that means a value of 10 is assigned to variable x and y is assigned a value of 20.When a variable assigned with a particular type of object the variable also act a like type of that object so when we call "x.class" it will return fixnum. When we call variable that is not initialized,it will return with message uninitialized local variable z.

class in Ruby

"class is a blueprint of an Object" What's that mean? Object and class,An object is a package which are called at the runtime which cannot modified at run time,So what we defined in class are converted to object and this object are called at runtime execution.
so we can call class as a blue print of an object.In class we actually designing our program for the output what we required.We can include method inside the class so methods need variable declaration for their operations,Programmers can decide these methods and variables should be kept as private for outside the class.All kinds of designing are done inside the class.Lets look at an example how class and object are created at ruby.
To crate a class in ruby, use the key word class and class name should start with capital alphabetic letter and to create a object use the keyword new

In this program Animal is the class and dog is the method inside method there is a message of string type,When we call this class as object and from the object we call the method,It will print "I am Barking". is the object creation and new method is assigned to barking.The new object of animal is created with address like <0x000000111> something like that.So object is created now we can call the method the created object using "" .


selenium javascript alert box

This is a easy task to capture javascript based alertbox , /* * To change this license header, choose License Headers in Project Properti...