Skip to main content


Showing posts from 2014

Basic linux commands

System Info date – Show the current date and time cal – Show this month's calendaruptime – Show current uptimew – Display who is onlinewhoami – Who you are logged in asfinger user – Display information about useruname -a – Show kernel informationcat /proc/cpuinfo – CPU informationcat /proc/meminfo – Memory informationdf -h – Show disk usagedu – Show directory space usagefree – Show memory and swap usageKeyboard ShortcutsEnter – Run the commandUp Arrow – Show the previous commandCtrl + R – Allows you to type a part of the command you're looking for and finds it Ctrl + Z – Stops the current command, resume with fg in the foreground or bg in the background Ctrl + C – Halts the current command, cancel the current operation and/or start with a fresh new line Ctrl + L – Clear the screen command | less – Allows the scrolling of the bash command window using Shift + Up Arrow and Shift + Down Arrow !! – Repeats the last commandcommand !$ – Repeats the last argument of the previous…

Bash programming

Bash is a Unix shell written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell (sh).[3][4] Released in 1989,[5] it has been distributed widely as the shell for the GNU operating system and as a default shell on Linux and Mac OS X. It has been ported to Microsoft Windows and distributed with Cygwin and MinGW, to DOS by the DJGPP project, to Novell NetWare and to Android via various terminal emulation applications. In the late 1990s, Bash was a minor player among multiple commonly used shells, unlike presently where Bash has overwhelming favor. - Wikipedia

Recursion and Tail Recursion

Consider a simple factorial function
Here is a simple Java implementation that uses recursion:
1 2 3 4 5 6 7 8 9 10publicvoidfactorial(intn){if(n<=1){return1;}else{returnn*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.
1 2 3 4 5 6 7 8 9 10publicstaticintsum(inta,intb){if(a==0){returnb;}else{returnsum(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 mpapispublic key (might need gpg2) (see security)

gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
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&#…

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…

what is Groovy?

Groovy is an object-oriented programming language for the Java platform. It is a dynamic language with features similar to those of Python, Ruby, Perl, and Smalltalk. It can be used as a scripting language for the Java Platform, is dynamically compiled to Java Virtual Machine (JVM) bytecode, and interoperates with other Java code and libraries. Groovy uses a Java-like curly-bracket syntax. Most Java code is also syntactically valid Groovy.
source : Wikipedia

N Queen problem

My favorite algorithm which includes in Recursion and backtracking method is N Queen problem.I love this problem because it helped me to solve various other problem including "Sudoku". The solution for this problem typically easy one,There are three types of attacks for the Queen to each other

This can be achieved by,if i,j are the respective coordinates which represents x = i and y = j

There are three types of attack

1. a[i] == a[j] same column or row

2. (a[i] - a[j]) - (i-j) same major diagonal

3. (a[j]-a[i]) - (j-i) same minor diagonal

The code for this problem.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57publicclassQueens{/*********************************************************************** * Return true if queen placement q[n] does not conflict with * other queens q[0] through q[n-1] ***********************************************…

When i tested my voice>

It is pretty boring these days when i concentrated on learning new programming languages and technologies,i having spending for eight hours and more in front of the computer analysing nothing much series of code.I am frustrated and tired but being love what i love to do make me not having a regret.I always sing to my self while i am day i thought,i should check my voice and hear it.I bought a new microphone and installled audacity in my linux machine.I recorded and heard, it’s pretty convinced me.Here i am presenting for you guys what i heard.
my voice

moving your online data using

I got interested in because i can easily transfer my on-line storage data from one to another data storage space.Mover is fast and simple.When my Ubuntu one got expired i have to move one GB of data to another on-line storage,it is tedious task to download the whole content to your physical drive and again upload to another on-line drive.This is where it helps,moverio has api to interface between the cloud storages.I transfered my data from Ubuntu one to drop-box easily.

03-perl Numbers and Strings

Numbers in perl are pretty straight simply declares with variables as we talked before.For example

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23#!/usr/bin/perlusestrict;usewarnings;main(@ARGV);sub main{my$variable1=1234;my$variable2=01234;my$variable3=0x1ab7;my$variable4=0b10101010;my$variable5=12.345;my$variable6=12.4e34;print("$variable1\n");print("$variable2\n");print("$variable3\n");print("$variable4\n");print("$variable5\n");print("$variable6\n");}

In the above example variable1 will print 1234.Variable2 will print 668 because if a number with leading zero, perl will take it as octal and when printing convert in to decimal that gives you 668.Variable3 will print 6839 perl will take the value as hexadecimal because with a leading 0x and convert to decimal to base ten when printing.Variable4 will print 170 and 0b recognize as binary,perl will take it as binary and covert decimal ten.Varia…

02-perl Variables and Values

Variables represents the storage space in memmory.In perl variable are represented by beginning with a ‘$’ sign followed by variable name.for example $varible_name. values are assigned to this variables.

1$variables_name="Hello World"

we can store any kind of data type in varibles including null.Each statements in perl terminated by putting semicolon ‘;‘ at the end. Each subroutines in perl ,other languages considered as method starts with a curlybraces “{}” and ends with curly braces.
lets walk though a n example

1 2 3 4 5 6 7 8 9 10 11 12#!/usr/bin/perlusestrict;usewarnings;main(@ARGV);sub main{$variables_name="Hello World"print"$variables_name\n"}

In this program its starts with two imports of libraries from perl strict and warnings. strict is used for forcing perl to not alllow any bare words,un referenced declaration.Warnings helps you to find out errors on run time for example if you missed any semicolon or typo mistake in keyword declar…

Iterate through multidimensional array in perl

Its quite easy to declare one dimensional array in perl and iterate through them.for example
1 2 3 4 5my@array=(1,2,3,"Hell World");foreachmy$ar(@array){print("$ar\n");}
but when comes to multiple dimensional array,what will do?.Its quite challenging but easy to implement.Multiple deimensional means array inside an array for example my @array = ([1,2,3],[4,5,6]);
Here [1,2,3] is the first array and [4,5,6] is the second array,The strategy is to first iterate through arrays then iterate inside each arrays for example
1 2 3 4 5 6 7 8my@array=([1,2,3,4],[5,6,7,8]);foreachmy$ar(@array){foreachmy$arr(@$ar){print("$arr\n");}}

Generate binary string of n bits

This N bit algorithm is based on generating the subsets of given size of input,The running time of this particular algorithm can be calculated by 2^n.If n = 4 There should be 2^4 subset which is the number of cycle taken by this particular algorithm.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20classNbitStringdefinitialize(n)<1@a.each_slice(@n){|a,b,c|puts[a,b,c]*' '}else@a[n-1]=0genString(n-1)@a[n-1]=1genString(n-1)

Installing couchDB on Ubuntu 14.04

First of all install couchDB through apt-get install

update your repository : sudo apt-get update

install couchDB             :  sudo apt-get install couchdb

almost done but little configuration left, go to ' /etc/couchdb/ ' and open ' local.ini ' in a text editor,

sudo nano local.ini,add username and password in a format like
' username = password' under ' [admin] ' at the end of the file.

save and exit then restart the server by 'sudo service couchdb restart'

 to access db go to '' and login with the username and password you added in the local.ini file.

02.mysql database:create,show,rename,delete

For creating database use the command
For showing existing databases use the command
For rename database name is little bit a task,Actually you cannot rename a database.What we have to is back up our database then delete the database and create a new database import the backup database to the new database.

1.mysqldump -u username -p -v olddatabase > olddbdump.sql
2.mysqladmin -u username -p create newdatabase
3.mysql -u username -p newdatabase < olddbdump.sql

1.First create a backup,2.then create a new database,3.then import the backupdump.

In older Mysql version 5.1,There is a command RENAME db_name TO db_name;

but this has removed from 5.5 versions.

For delete a database use the command

01.Installing and configuring Mysql

Installing mysql is pretty much simple
for installing in ubuntu use:
sudo apt-get install mysql-server
When installation about to complete mysql ask's for to set root user password,then set it and finish the installation.

First enter in to your root account by command in your terminal

mysql -u root -p, then enter password.In the root terminal type this command to create new user. CREATEUSER'user_name'@'your_host' IDENTIFIED BY 'your_password';example:CREATEUSER'jerin'@'localhost' IDENTIFIED BY 'password';Next is to grant all privileges to use available commands in Mysql
GRANTALLPRIVILEGESON* . *TO'user_name'@'your_host';example:GRANTALLPRIVILEGESON* . *TO'jerin'@'localhost';Atlast reload the mysql setting by using FLUSH PRIVILEGES;

03.objects in ruby

In Ruby every thing is object.Unlike Java there is no primitive data-types in ruby,Java has some primitive data type which is not object.
For Example Java has int,String,boolean,float and double but in ruby every thing is object for example when we execute 2.class in ruby this will return Fixnum that means every thing that we type in ruby considered as object.If we execute the command nil.class gives you Nilclass ,nil is a null object using in ruby.

I you and others works for facebook,google,linkedin…

Data structure and Algorithms in computer world had significant role in the advancement technologies.Many technologies are implemented with the help of Computer Algorithms and other computation theories.Scientist and computer Geeks had developed many technologies that helps the common people not to worry about the implementation of technologies rather using it in their daily life.Internet age had started drastically fast and it has grown its peak.Now what ? Obviously the Internet business,The invention of WWW by the British scientist Tim Berners-Lee changed the world to a small.Introduction of Personal computing by Microsoft and the first GUI browser Mosaic by Marc Lowell Andreessen open a new world with cannon sound(literally they had implemented sound to hear on each download of mosaic by the people ) .Back in 1996 Two Stanford Phd students had introduced one of best and efficient search Engine and they Founded Google and along with another guy from Harvard who founded…

01-perl printing Hello World

Perl is a amazing and great programming language to study.Let us go through a simple program for printing the old dialog “Hello World

#!/usr/bin/perl use strict; use warnings; print"Hello, World!\n";
Here print statement will print “Hello world”.To run perl program make a file and save.Open your terminal and type the command perl

learn quicksort algorithm with Hungarian dance

Quicksort, or partition-exchange sort, is a sorting algorithm developed by Tony Hoare that, on average, makes O(n log n) comparisons to sort n items. In the worst case, it makes O(n2) comparisons, though this behavior is rare. Quicksort is often faster in practice than other O(n log n) algorithms - source

02.prerequisites and working with ruby.

The prerequisites for working with ruby are you need a working OS of least 256 ram and 4 GB hard-rive.Its no matter which OS you are using,you can use windows PC or Linux or mac.Installation of ruby should done before you working with ruby. Ruby is an fully object-oriented programming languages with sugar syntax which help developers to write program easily and fast with out doing extra works for creating new standard API's.
Working with ruby provides many options,you can work with console by executing ruby directly from the console.For example $ruby -e 'puts "Hello World"'

or you can work with ruby files,put the program inside a ruby file and save it as ruby file by saving file.rb after that run from console.for example

the third way to work with ruby is,Work wit irb(interactive ruby),ruby provides a environment you can executive ruby programs.To go to irb,type irb

01.RVM install ruby

The easiest way to install ruby is by using RVM(ruby version manager).If you use RVM you don’t have to worry about dependencies and libaries install with ruby,RVM will take care of that for lets install ruby,open your terminal and enter the command to update your system source list
sudo apt-get update
Next to install curl if you dont have in your system.
sudo apt-get install curl
Next is to install RVM,remember dont use sudo because this is installing in your home directory
\curl -L | bash -s stable

After it is done installing, load RVM. You may first need to exit out of your shell session and start up a new one.
source ~/.rvm/scripts/rvm
if any error appears showing rvm command not found after this,Enter these lines to ur .bashrc manually
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Next step is to install ruby,for that enter this command
rvm install ruby
note: if you want to install specific version you can choo…