Pages

12/15/2014

Basic linux commands



 System Info

date – Show the current date and time
cal – Show this month's calendar
uptime – Show current uptime
w – Display who is online
whoami – Who you are logged in as
finger user – Display information about user
uname -a – Show kernel information
cat /proc/cpuinfo – CPU information
cat /proc/meminfo – Memory information
df -h – Show disk usage
du – Show directory space usage
free – Show memory and swap usage

Keyboard Shortcuts

Enter – Run the command
Up Arrow – Show the previous command
Ctrl + 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 command
command  !$ – Repeats the last argument of the previous command
Esc + . (a period) – Insert the last argument of the previous command on the fly, which enables you to edit it before executing the command

Ctrl + A – Return to the start of the command you're typing
Ctrl + E – Go to the end of the command you're typing
Ctrl + U – Cut everything before the cursor to a special clipboard, erases the whole line
Ctrl + K – Cut everything after the cursor to a special clipboard
Ctrl + Y – Paste from the special clipboard that Ctrl + U and Ctrl + K save their data to
Ctrl + T – Swap the two characters before the cursor (you can actually use this to transport a character from the left to the right, try it!)
Ctrl + W – Delete the word / argument left of the cursor in the current line

Ctrl + D – Log out of current session, similar to exit
Learn the Commands

apropos subject – List manual pages for subject
man -k keyword – Display man pages containing keyword
man command – Show the manual for command
man -t man | ps2pdf - > man.pdf  – Make a pdf of a manual page
which command – Show full path name of command
time command – See how long a command takes

whereis app – Show possible locations of app
which app – Show which app will be run by default; it shows the full path

Searching

grep pattern files – Search for pattern in files
grep -r pattern dir – Search recursively for pattern in dir
command | grep pattern – Search for pattern in the output of command
locate file – Find all instances of file
find / -name filename – Starting with the root directory, look for the file called filename
find / -name ”*filename*” – Starting with the root directory, look for the file containing the string filename
locate filename – Find a file called filename using the locate command; this assumes you have already used the command updatedb (see next)
updatedb – Create or update the database of files on all file systems attached to the Linux root directory
which filename – Show the subdirectory containing the executable file  called filename
grep TextStringToFind /dir – Starting with the directory called dir, look for and list all files containing TextStringToFind

File Permissions

chmod octal file – Change the permissions of file to octal, which can be found separately for user, group, and world by adding: 4 – read (r), 2 – write (w), 1 – execute (x)
Examples:
chmod 777 – read, write, execute for all
chmod 755 – rwx for owner, rx for group and world
For more options, see man chmod.

File Commands

ls – Directory listing
ls -l – List files in current directory using long format
ls -laC – List all files in current directory in long format and display in columns
ls -F – List files in current directory and indicate the file type
ls -al – Formatted listing with hidden files

cd dir – Change directory to dir
cd – Change to home
mkdir dir – Create a directory dir
pwd – Show current directory

rm name – Remove a file or directory called name
rm -r dir – Delete directory dir
rm -f file – Force remove file
rm -rf dir – Force remove an entire directory dir and all it’s included files and subdirectories (use with extreme caution)

cp file1 file2 – Copy file1 to file2
cp -r dir1 dir2 – Copy dir1 to dir2; create dir2 if it doesn't exist
cp file /home/dirname – Copy the filename called file to the /home/dirname directory

mv file /home/dirname – Move the file called filename to the /home/dirname directory
mv file1 file2 – Rename or move file1 to file2; if file2 is an existing directory, moves file1 into directory file2

ln -s file link – Create symbolic link link to file
touch file – Create or update file
cat > file – Places standard input into file
cat file – Display the file called file

more file – Display the file called file one page at a time, proceed to next page using the spacebar
head file – Output the first 10 lines of file
head -20 file – Display the first 20 lines of the file called file
tail file – Output the last 10 lines of file
tail -20 file – Display the last 20 lines of the file called file
tail -f file – Output the contents of file as it grows, starting with the last 10 lines

Compression

tar cf file.tar files – Create a tar named file.tar containing files
tar xf file.tar – Extract the files from file.tar

tar czf file.tar.gz files – Create a tar with Gzip compression
tar xzf file.tar.gz – Extract a tar using Gzip

tar cjf file.tar.bz2 – Create a tar with Bzip2 compression
tar xjf file.tar.bz2 – Extract a tar using Bzip2

gzip file – Compresses file and renames it to file.gz
gzip -d file.gz – Decompresses file.gz back to file

Printing

/etc/rc.d/init.d/lpd start – Start the print daemon
/etc/rc.d/init.d/lpd stop – Stop the print daemon
/etc/rc.d/init.d/lpd status – Display status of the print daemon
lpq – Display jobs in print queue
lprm – Remove jobs from queue
lpr – Print a file
lpc – Printer control tool
man subject | lpr – Print the manual page called subject as plain text
man -t subject | lpr – Print the manual page called subject as Postscript output
printtool – Start X printer setup interface

Network

ifconfig – List IP addresses for all devices on the local machine
iwconfig – Used to set the parameters of the network interface which are specific to the wireless operation (for example: the frequency)
iwlist – used to display some additional information from a wireless network interface that is not displayed by iwconfig
ping host – Ping host and output results
whois domain – Get whois information for domain
dig domain – Get DNS information for domain
dig -x host – Reverse lookup host
wget file – Download file
wget -c file – Continue a stopped download
SSH

ssh user@host – Connect to host as user
ssh -p port user@host – Connect to host on port port as user
ssh-copy-id user@host – Add your key to host for user to enable a keyed or passwordless login

User Administration

adduser accountname – Create a new user call accountname
passwd accountname – Give accountname a new password
su – Log in as superuser from current login
exit – Stop being superuser and revert to normal user

Process Management

ps – Display your currently active processes
top – Display all running processes
kill pid – Kill process id pid
killall proc – Kill all processes named proc (use with extreme caution)
bg – Lists stopped or background jobs; resume a stopped job in the background
fg – Brings the most recent job to foreground
fg n – Brings job n to the foreground

Installation from source

./configure
make
make install
dpkg -i pkg.deb – install a DEB package (Debian / Ubuntu / Linux Mint)
rpm -Uvh pkg.rpm – install a RPM package (Red Hat / Fedora)

Stopping & Starting

shutdown -h now – Shutdown the system now and do not reboot
halt – Stop all processes - same as above
shutdown -r 5 – Shutdown the system in 5 minutes and reboot
shutdown -r now – Shutdown the system now and reboot
reboot – Stop all processes and then reboot - same as above
startx – Start the X system

12/13/2014

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

11/28/2014

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
10
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.
factorial(5)
5 * factorial(4)
5 * (4 * factorial(3))
5 * (4 * (3 * factorial(2)))
5 * (4 * (3 * (2 * factorial(1))))
5 * (4 * (3 * (2 * 1)))
120
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
10
public static int sum(int a,int b)
               {
                    if ( a == 0 )
                        {
                           return b;
                        }
                    else{
                           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)
15
In the tail-recursive case, with each evaluation of the recursive call, the b is updated.

11/22/2014

Robotframework running on jenkins CI

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


11/13/2014

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://keys.gnupg.net --recv-keys 
409B6B1796C275462A1703113804BB82D39DC0E3

Install RVM (development version):

\curl -sSL https://get.rvm.io | 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 https://get.rvm.io | 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". Animal.new 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 "barking.dog" .

10/16/2014

JetBrains Intellij IDEA 13 Ultimate keygen

Hi Fiends , i have wrote a small keygen application for JetBrains Intellij IDEA 13 . If you like  download keygen13

Prerequisites : jre should be installed in your system

To run the app use the command "java -jar keygen.jar" with out quotes.

10/09/2014

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

10/05/2014

Installing Groovy

For Any platform Groovy install by GVM tool.

Install GVM tool :
curl -s get.gvmtool.net | bash

After that install groovy by
gvm install groovy

9/05/2014

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
57
public class Queens {

   /***********************************************************************
    * Return true if queen placement q[n] does not conflict with
    * other queens q[0] through q[n-1]
    ***********************************************************************/
    public static boolean isConsistent(int[] q, int n) {
        for (int i = 0; i < n; i++) {
            if (q[i] == q[n])             return false;   // same column
            if ((q[i] - q[n]) == (n - i)) return false;   // same major diagonal
            if ((q[n] - q[i]) == (n - i)) return false;   // same minor diagonal
        }
        return true;
    }

   /***********************************************************************
    * Print out N-by-N placement of queens from permutation q in ASCII.
    ***********************************************************************/
    public static void printQueens(int[] q) {
        int N = q.length;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (q[i] == j) System.out.print("Q ");
                else           System.out.print("* ");
            }
            System.out.println();
        }  
        System.out.println();
    }


   /***********************************************************************
    *  Try all permutations using backtracking
    ***********************************************************************/
    public static void enumerate(int N) {
        int[] a = new int[N];
        enumerate(a, 0);
    }

    public static void enumerate(int[] q, int n) {
        int N = q.length;
        if (n == N) printQueens(q);
        else {
            for (int i = 0; i < N; i++) {
                q[n] = i;
                if (isConsistent(q, n)) enumerate(q, n+1);
            }
        }
    }  


    public static void main(String[] args) {
        int N = Integer.parseInt(args[0]);
        enumerate(N);
    }

}

source Robert Sedgewick and Kevin Wayne N queen

8/31/2014

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 coding.one 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 mover.io


I got interested in mover.io 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.

8/30/2014

03-perl Numbers and Strings



Numbers in perl are pretty straight forward.it 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/perl
 
use strict;
use warnings;
 
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.Variable5 will print a floating number.Variable6 will print exponential.

we can do any arithmetic operation on perl.using basic arithmetic operators like + – * / .

Lets talk about perl string.

string in perl represented by arguments inside ” ” and single quote ‘ ‘. for example “Hello world” this will considered as single string and as in single quotes too. For example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#!/usr/bin/perl
 
use strict;
use warnings;
 
main(@ARGV);
 
sub main
{
      my $variable1 = "Hello";
      my $variable2 = 'World';
      print($variable1);
      print($variable2);
}


String interpolation

String interpolation helps you to pass argument in side a string variable.Lets go though with an example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#!/usr/bin/perl
 
use strict;
use warnings;
 
main(@ARGV);
 
sub main
{
      my $variable1 = "Hello";
      print("$variable World\n");
}


This will print Hello World . value “Hello world” will pass inside the print statement.

This will work with only in double quotes not with single quote because single quote will not analyse the input and simply print, but double quote will analyse.

There is another way to do ” “ and ‘ ‘ using q and qq. q represents single quote and qq represents double quotes.lets look in to example how to implement it.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#!/usr/bin/perl
 
use strict;
use warnings;
 
main(@ARGV);
 
sub main
{     my $n         = "World";
      my $variable1 = q{Hello $n};
      my $variable2 = qq{Hello $n};
      print($variable1."\n");
      print($variable2."\n");
}


as i said q represents single quotes,the arguments can be placed in between any delemeter here its {} or you can use || leading with q in-front.In the above example variable1 will print Hello $n because single quote will not analyze the string argument.

qq represents double quotes,as said above we can implement with delemeters and variable2 will print Hello World. Because double quotes will analyze string argument.

string concatenation

string concatenation or join two strings or many by using dot “.” .We can concate any string dot but “+” cannot be use in perl for concatenation its strictly used for numerical operation .let look in to an example how to concatenate.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/usr/bin/perl
 
use strict;
use warnings;
 
main(@ARGV);
 
sub main
{
      my $variable1 = "Hello";
      my $variable2 = 'World';
      print($variable1." ".$variable2."\n");
}

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/perl
 
use strict;
use warnings;
 
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 declaration etc.

next is the main function main(@ARGV) as like in c and java.We can pass command line argument through main(@ARGV) here @ARGV is array type.we will look more details in array post.For now we can look how command line argument can be done.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#!/usr/bin/perl
 
use strict;
use warnings;
 
main(@ARGV);
 
sub main
{
    foreach my $arg (@ARGV)
    {
      print("$arg\n");
    }  
}


In this program we are iterating each element in the array @AGRV using foreach keyword in side the sub routine and each element are printed by using instance variable $arg.To run command line argument,copy the program and save in a file as some_name.pl.Type the perl command followed by argument perl same_name.pl Hi how are you.

Lets talk about variable scope. variable scope allows us to limit the scope of the variable in several places in side our program.There are global variables and method depended variables.Method depended variables scope are limited to the method they are not visible outside the method.Unlike method variables global variables scope has no limit.They are scoped every where.For example @AGRV is a global variable thats why they are available inside the method,but method variable which is declared by my key word means this is limited to this method only.For example my $arg this variable cannot be access out side the method.If you want make sure thats you self clear just run the program by printing $arg value outside the method.It will gives you a error

Global symbol “$arg” requires explicit package name at sample.pl

Then what about global variable, lets walk though an example.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/usr/bin/perl
 
use strict;
use warnings;
my $arg = "This is a global scope test";
main(@ARGV);
 
sub main
{
   my $arg = "method variable scope";
   print("$arg\n");
}
print("$arg\n");


in above example there is $arg variable is declared in global and method level scope,so this time the print after the sub routine will not produce any error because there is a global variable for that call.if we run this program this will result with printing

op:

method variable scope
This is a global test


next what happens if there is no variable declared in side the subroutine for example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#!/usr/bin/perl
 
use strict;
use warnings;
my $arg = "This is a global scope test";
main(@ARGV);
 
sub main
{
  print("$arg\n");
}
print("$arg\n");


if there is no matching variable for the print call it will look for the global variable.This will result in printing

op:

This is a global scope test
This is a global scope test


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
5
my @array = (1,2,3,"Hell World");
foreach my $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]);
1
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
8
my @array = ([1,2,3,4],[5,6,7,8]);
    foreach my $ar (@array)
    {
     foreach my $arr (@$ar)
     {
       print("$arr\n");
     }
    }

8/28/2014

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
20
class NbitString
    def initialize(n)
        @a = Array.new(n)
        @n = n
    end

    def genString(n)
        if n < 1
            @a.each_slice(@n) { |a,b,c| puts [a,b,c]*'  '}
        else
            @a[n-1] = 0
            genString(n-1)
            @a[n-1] = 1
            genString(n-1)
        end
    end
end

nbit = NbitString.new(3)
nbit.genString(3)

8/21/2014

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 'http://127.0.0.1:5984/_utils' and login with the username and password you added in the local.ini file.

8/17/2014

Installing JDK on ubuntu

Installing JDK on Ubuntu is simple task.Type the command in your terminal


sudo apt-get update 
This is update your system repository,Next is to install JDK

sudo apt-get install openjdk-7-jdk 
After installation you can check the version of your system by

java -version

8/13/2014

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

For creating database use the command
CREATE DATABASE IF NOT EXIST db_name;

For showing existing databases use the command
SHOW DATABASES;

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
DROP DATABASE db_name;


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.
CREATE USER 'user_name'@'your_host' IDENTIFIED BY 'your_password';
 
example:CREATE USER 'jerin'@'localhost' IDENTIFIED BY 'password'; 
 
Next is to grant all privileges to use available commands in Mysql

GRANT ALL PRIVILEGES ON * . * TO 'user_name'@'your_host';
 
example: GRANT ALL PRIVILEGES ON * . * 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.












8/11/2014

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 facebook now they are doing good business and their product are absolutely free to use. Now What’s the real business of Say Google and Facebook? is it only advertising?,Yes of course adds are part of the money making apart from that,They sell trends data for products company.Wait how is that happens? Google has advanced technologies to aggregate the latest trend data from their database and amazing part is their interface for collecting database is all their products including search engine,Normal users using their search engine as a part of their daily life.Facebook also serving the same interface that will make people use in their daily life.In Each search or like in facebook or Google we do,Actually we are collecting data for their business with out having any salary.I am not saying this is wrong actually i am appreciating their intelligence that make us doing it for Free.

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

  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. print "Hello, World!\n";

Here print statement will print “Hello world”.To run perl program make a file some_fle_name.pl and save.Open your terminal and type the command perl some_fle_name.pl

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 you.so 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 https://get.rvm.io | 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 choose install by

rvm list known #this will show you available version,pick version and install by

rvm install ruby-version

Now after installation to show installed versions use the command

rvm list

To set ruby version for the system use the command

rvm use ruby-version --default

Check Ruby version by typing

ruby -v

widget

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...