Mar 26, 2015

Git and Github

Git/Github is a helpful documentation technique when u are changing a file frequently, mostly in the programming language code and you may need to toggle and compare between the various edits. Also, it really helps when multiple users are working on the same file and we want to trace the update by various users.

First thing first,

One needs to get a account in www.github.com. You need to get a username and password for a registered email id. After having the github account we need to install git in our computer.

For linux, we install it as:

sudo apt-get update
sudo apt-get install git

Then we need to setup Git:

git config --global user.name "our_username"
git config --global user.email  "our_emailid"

we can see our configuration later as

git config --list

Having set up the git, we need to have a folder where we will work or say assign a git work-space folder. For that:
First create a folder and change directory to that folder
$ mkdir ~/git/userfolder_name       
$ cd ~/git/userfolder_name

We may create a sample file
~/git/userfolder_name $ touch file_name

Next convert it to the workspace environment
~/git/userfolder_name $ git init

To add the files in the folder to the git repository, we use
~/git/userfolder_name $ git add .

Whenever we make a change to our repository we need to make a commit message
~/git/userfolder_name $git commit -m "My_commit" -a
~/git/userfolder_name $git commit -m "My_commit" file_name


Upto now, we have worked with out local server.
~/git/userfolder_name $git remote add origin ssh://git@github.com:user_name/repository_name.git
~/git/userfolder_name $git remote -v

Mar 13, 2015

GNU Octave

GNU octave is a high level language for numerical computation. It is pretty much similar to Matlab, but it is free. From the version 3.8 onward, the octave supports GUI as well.

To install Octave in Linux Environment, do following in terminal:

$ sudo add-apt-repository ppa:octave/stable
$ sudo apt-get update
$ sudo apt install octave

or 

$ sudo apt-get install octave

(I used the 2nd one, so not sure about the first one, but it should work)

After installing octave, you can find the octave in search bar or under menu-> Science & Engineering-> GNU Octave or, from terminal as:

$ octave

Following octave command prompt will appear:


We can start Octave in GUI mode by forcing the GUI mode by following command:
At terminal:

$ octave --force-gui

Then, GUI appears as follow:



The programming construct are pretty much similar. Code are likely to be compatible with matlab. It has plot functions and array pretty similar with matlab. 

Here is a sample of octave script - test.m

#! bin/octave -qf
clear;
clc;

N=[2,4,5,6,7,4,3,6]
lengthN = length(N);
sum=0.0;
for i = N
  sum += i;
  endfor
meanN=sum/lengthN;
printf("The mean  = %f \n", meanN);
printf("The median  = %f \n", median(N));
printf("The variance = %f \n", var(N));
printf("The standard deviation = %f \n", std(N));

bar(N)
axis([0,10,0,10]);
title("The traffic load");
xlabel("Time Slot");
ylabel("Number of customer")
grid on;

Enjoy!



Feb 27, 2015

Powerful awk

Awk is really a powerful script language. We can perform a large tasks within a few line of codes. Just for example:

Consider we have a sample spreadsheet with the information as below:

test_awk.csv

Consider we want to find how many different records are in the 3rd column, we can use the following command in the terminal or bash:

           awk '{print $3}' test_awk.csv | sort -n | uniq -c

Output:

       1 x121REB000
     12 x121REB227
      6 x131REB198
      4 x131REB205
     20 x131REB221
      4 x131REB254
      3 x131REB294
      1 x131REB317
      5 x131REB392


And, consider we want to find number of TRUE and number of FALSE, for each uniuqe record in the column 3, we can run following commands:

          awk '{print $3, /TRUE/, /FALSE/}' test_awk.csv | sort -n | uniq -c

Output:

 Count   Code         T  F 
      1  x121REB000 0 1
     11 x121REB227 0 1
      1  x121REB227 1 0
      1  x131REB198 0 1
      4  x131REB198 1 0
      1  x131REB198 1 1
      3  x131REB205 0 1
      1  x131REB205 1 0
     17 x131REB221 0 1
      3  x131REB221 1 0
      2  x131REB254 0 1
      1  x131REB254 1 0
      1  x131REB254 1 1
      2  x131REB294 0 1
      1  x131REB294 1 0
      1  x131REB317 0 1
      4  x131REB392 0 1
      1  x131REB392 1 0

Lastly, for each record in column no. 3,  to find the unique record in field number 2, we can use the command:

          awk '{print $3, $2}' test_awk.csv | sort -n | uniq

Output:

Code-3 Code-2
x121REB000 5921
x121REB227 5724
x121REB227 9087
x131REB198 1443
x131REB198 1841
x131REB198 2339
x131REB198 5261
x131REB198 7284
x131REB198 9758
x131REB205 1446
x131REB205 1958
x131REB205 2285
x131REB205 5999
x131REB221 3866
x131REB221 6171
x131REB221 9616
x131REB221 9898
x131REB254 4732
x131REB254 6078
x131REB254 7679
x131REB254 9112
x131REB294 1025
x131REB294 3369
x131REB294 6006
x131REB317 6452
x131REB392 4045
x131REB392 4898



Feb 21, 2015

Cant hear their Mother

Reference: International Mother Language Day, Feb21.  

Mother is the first teacher of every child. Children start to learn, hearing their mother and exchange words in mother-language. But those who are born with inborn hearing impairment are deprived of this. They learn with the help of sign language.

Below, a girl puts up her thumb, index finger and pinkie finger, while keeping her ring finger and your middle finger down to express word 'Love'. They need our love.


Feb 16, 2015

Lets keep it simple

I imagine it would be better if we all think that "I am a human being first". Only after that we may be a Christian, Buddhist, Muslim, Hindu or, Chinese, Latvian, American or whatsoever. You may be richer than I am or you may have less, but my friend! when we die all of us will take the same amount of money with us. 

Lets make a better and peaceful world to live in. 

We need Love and Peace because we deserve it. 

Feb 9, 2015

Install Oracle Java for Netbeans

I was trying to install Netbeans in Ubuntu 14.0.4. But default Java for this version of Linux is OpenJDK7, which was not compatible with the netbeans. So I had to install the Oracle Jave so that the installation of Netbeans can be continued.

Here is the process to install Oracle Java:

Linux Terminal:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
 
After that, Netbeans will install in Ubuntu.
 
Process to install Netbeans in Ubuntu can be seen in this Site of Netbeans.  

Feb 5, 2015

Budapest Trip - Night Heaven

Budapest is simply awesome. At night it looks like heaven on Earth. The parliament building, Buda Castle, Castle Hill, Parliament and the Basilica of St. Stepen are the beautifully illuminated at night. Millenary Monument and the zechenyi Bath are the attractions at the some eastern part of the Budapest city. There are a lot of natural hot baths in this classical city. 


The official currency of Hungary is Hungarian Forint (HUF) and 1 HUF nearly equals 0.0033 euros. You need the currency to buy the tickets from machines. The transportation map for the Budapest can be downloaded from this site