Monday, 12 May 2014

Unix Commands - All important commands which every developer should know

Unix Commands - All important commands which every developer should know

List all files and directory
$ ls

List all files and directory with their detail like permission, owner and created date
$ ls 
$ ls -l

List all files and directory with more option (when list is more than 1 page)
$ ls -l | more

Remove directory
$ rmdir dirname

Remove a file
$ rm filename

Remove a file without "confirmation"
$ rm -f filename

Remove a directory
$ rmdir filename

Copy source to destination
$ cp sourceFile destinationFile

Move a file from one location to another
$ mv source destination

Online manual (help) about command
$ man ls

Find a text in file and return that line
$ grep searchText fileName

Change the File/Directory Permission
$ chmod 644 fileOrDir

List the preprocessor
$ ps

Find text in List of processor
$ ps | grep STIME

Kill the process
$ kill 45555

Zip a file
$ gzip filename 

Unzip a file
$ ungzip filename.zip

List who is logged on your machine
$ who

List who is on the computer in the lab
$ finger

List of History you have done recently
$ history

Print the current Date
$ date

print the calendar for September 2000
$ cal 09 2013

See how much free disk space
$ df

Set the Alias for command
$ alias newc="ls -l";

Print system usage and top resource hogs
$ top

Logout from the putty/console
$ logout
$ exit

Progressively dump a file to the screen: ENTER = one line down SPACEBAR = page down  q=quit$ more filename

Show the firest few lines of a file
$ head filename
$ head -n  filename

Show the last few lines of a file
$ tail filename
$ tail -n  filename

Search the text and store the output in file
$ grep string filename > newfile
$ grep string filename >> existfile

Finds all the files named aaa.txt in the current directory or any subdirectory tree.
$ find . -name aaa.txt

Open a file in edit mode
$ vi filename

Open file in vi editor and go to line no 101 instant
$ vi +101 filename

Show the line number in front of each line in vi editor
:set number

Go to particular line number in vi editor
:14
:100
:5

Search text "searchme" in the vi editor
:/searchme
to search next press "n" and for previous "shift+n"

Come out from vi editor
"shift+:" and press "q" and then press "enter key"

Edit modes (These keys enter editing modes and type in the text of your document.)
i  Insert before current cursor position
I  Insert at beginning of current line
a  Insert (append) after current cursor position
A  Append to end of line
Open and put text in a new line below current line
O  Open and put text in a new line above current line
r  Replace 1 character
R  Replace mode
<ESC> Terminate insertion or overwrite mode


Deletion of text
x   Delete single character
dd  Delete current line and put in buffer
ndd Delete n lines (n is a number) and put them in buffer
J   Attaches the next line to the end of the current line (deletes carriage return).

Cut and paste
yy Yank current line into buffer
nyy Yank n lines into buffer
p  Put the contents of the buffer after the current line
P  Put the contents of the buffer before the current line

Cursor positioning  (symbol (^ )before a letter means that the <Ctrl> key should be held down while the letter key is pressed)
^d  Page down
^u  Page up
^f   move forward one screen
^b  move backward one screen
^g  Display current line number
:n   Position cursor at line n
:$  Position cursor at end of file


Give on which server you are on
$ uname
Linux

Give your hostname
$ uname -n;
$ hostname

Kill your task
$ kill 1202255

Command displays active processes
$ ps


Display today's CPU activity
$ sar

Change the File's timing (created, access and modification time);
$ touch file.txt
If file is not exist, If will create the file

set  the access and modify timestamp
$ touch -t 06151330 f1.c;

Get file stats
$ stat file.txt

Change the owner of file/folder
$ chown vivek demo.txt
Owner of demo.text is set to vivek

Change the owner & Group of file/folder
$ chown vivek:arun demo.txt
Owner of demo.text is set to vivek
Group of demo.text is set to arun

Change the group of file/folder
$chown :ftp demo.txt
Group of demo.text is set to ftp

Change the owner of folder
$chown root /folder
Owner of /folder set to root

Change the owner of folder and its subfolder
$chown -R root /folder
Owner of /folder and its sub folder, set to root

List of user
$ w
$ who

Number of files in folder
ls -l | wc -l

Number of files in folder including dot and hidden files
ls -lA | wc -l

List the files sort by date
ls -ltr

Execute URL in Lynx with credentials
lynx http://example.com/action.php -accept_all_cookies -auth=username:'password'

List the crontab in your application
$ crontab -l

Edit the crontab timings
$ crontab -e

Total files in Directory
ls -1 | wc -l

Get the Files size in MB (Mega bytes) in unix command
$ ls -lash

Show the list of files committed in revision 570 of SVN
svn log -r 570 -v

Show the list of previous 5 users who have commit the file in SVN
svn log -l 5

Show the previous 5 logs of AjaxController.php
svn log -l 5 AjaxController.php

Show the previous all logs of AjaxController.php
svn log AjaxController.php




Wednesday, 23 April 2014

Google Dynamic Charts - Bar Pie and Line Chart - code snippets

One image express thousand words, that's why we use images in our daily life, Personal & professional.
Reading full report is a difficult task and need hours to understand, but we get the chart of that report Its easy and need only few minutes to understand. That's why we use chart in our professional life.

Chart can have different types and each have its own quality. For Example
Pie Chart: It display percentage values as a slice of a pie.
Bar Chart: It display with rectangular bars with lengths proportional to the values that they represent. The bars can be plotted vertically OR horizontally.
line chart is a two-dimensional scatterplot of ordered observations where the observations are connected.


Google Create different types of chart on the fly. No installtion and no code download is required. Just pass all parameter and your desired chart is ready.

Its very quick. see below few examples. you will understand how Google make easy. 
Pie chart
Pie chart Example
<img alt="Pie chart Example" src="https://chart.googleapis.com/chart?chs=250x100&amp;chd=t:30,20,50&amp;cht=p3&amp;chl=Arun|Kuldeep|Ajit" title="Pie chart Example" />



Bar Chart

Bar chart Example
<img alt="Bar chart Example" src="https://chart.googleapis.com/chart?chs=320x200&amp;cht=bvs&amp;chd=t:_,30,-30,50,80,200&amp;chxt=y" title="Bar chart Example" />


Line Chart

Line chart Example
<img alt="Line chart Example" src="https://chart.googleapis.com/chart?chf=bg,s,FFFFFF00&amp;chxl=1:|16%2F04%2F2014|18%2F04%2F2014|20%2F04%2F2014|

21%2F04%2F2014|23%2F04%2F2014&amp;chxp=0,15,30|1,0,25,50,75,100&amp;chxr=0,0,30&amp;chxs=0,676767,11.5,0,t,676767|

1,6AA9E6,12,0,l,676767&amp;chxt=y,x&amp;chs=416x180&amp;cht=lc&amp;chco=6AA9E6&amp;chd=s:MWYYOOAKYKSWECEWCEEIQ1aESKIUMEEIOICECCCEEEMUYMMGQYQYKKOlWWIGECCCKGGGMMIfKGMKGGEOIGACAAtAGEEIQKMOMI

IQQIISGEECIACGAGUEUUUUcjMfOhKQYWIICGCIIGGIWjrKcjMMKCIMKCECCGIAGGUOSQrA&amp;chls=3&amp;chm=B,6AA9E664,0,0,0|h,E7E7E7,0,0.5,1,-1|h,AAAAAA,0,0,1,1|h,AAAAAA,0,1,1,1|

V,E7E7E7,0,0,1,-1|V,E7E7E7,0,42,1,-1|V,E7E7E7,0,84,1,-1|V,E7E7E7,0,126,1,-1|V,E7E7E7,0,168,1,-1
" title="Line chart Example" />