Pages

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

8/10/2014

My favourite quote from Billgates

“I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it.”

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