Thursday, August 3, 2017

Computer Acronyms and jargon........

ACID: Atomicity, Consistency, Isolation, Durability (database properties)
ADT: Abstract Data Types
ANSI: American National Standards Institute
API: Application Program Interface (a set of routines, protocols, and tools for building software applications)
ARGC: Argument count
ARGV: Argument vector
ASCII: American Standard Code for Information Interchange
AWK: Aho Weinberger Kernighan
BOM: Byte order mark
CGI: Common Gateway Interface (Standard environment for web servers to interface with executable programs)
CLI: Command Line interface
CLI: Common Language Infrastructure
CLISP: Common LISP
CMS: Content Management Systems (e.g. WordPress, Joomla, Drupal, Xibo)
DBM: Database management
DNS: Domain Name System
endl:  End of line (used for flushing the stream in C++)
EOF: End of file
EVM: Earned Value Management (tracks progress and future of a project)
fdisk: Fixed disk or format disk (used to create, resize, delete, change, copy and move partitions on a hard drive)
FIFO: First-in first-out
FOSS: Free and Open Source Software
FS: Field separator
FSF: Free Software Foundation
FTP: File Transfer Protocol
GCC: GNU Compiler Collection. A  compiler system (gcc)
GIMP: GNU Image Manipulation Program
GPL: General Public License
GUI: Graphical User Interface
GUID: Globally Unique Identifier
HRF: Human Readable Format
HTML: HyperText Programming Language
IDE: Integrated development environment
IFS:  Internal Field Separator  (Used by the parser for word splitting after expansion)
IGV: Integrative Genomics Viewer (Visualizing results)
IP: Internet Protocol
ISO: International Standards Organization
JSON: JavaScript Object Notation (a lightweight data-interchange format)
JVM: Java Virtual Machine
LAMP: Linux, Apache, MySQL, PHP
LAN: Local Area Network
LDAP: Lightweight Directory Access Protocol 
LIFO: Last-in first-out
LISP: LISt Processing
MD5: Message-Digit Algorithm (to create hash value)
MPI: Message Passing Interface
NF: Number of Fields
NoSQL: Not only SQL
NR: Number of Records
OFS: Output Field Separator
ORS: Output Record Separator
PAN: Personal Area Network
PID: Process Identification Number
RDBMS: Relational Database Management System
Scala: Scalable Language
sed: stream editor
SLOC: Source lines of code
SRA: Short Read Archive (Store NGS dataset)
SSH: Secure Shell (encrypted network protocol)
stdin : standard input
SVG: Scalable Vector Graphics
varchar: Variable-length Characters
VoIP: Voice over IP
##############Computer Jargon###############
Who said computation is boring?..Difficult sure it is but fun element is not lacking..
I like Greek mythology and literature...knowledge fascinates me..and so does computation jargons.
Access modifier: private (visible only inside class), protected (visible only inside subclass), public (can be accessed from anywhere)
Apache: A software foundation, most widely used web server
Balkanization: Fragmentation  into many smaller, uncooperative regions
Buffer: A hunk of memory to hold data
Clobbering: Overwriting the contents of a file or computer memory
Cloning: copying the exact version
Crawler: A program that visits websites and reads their pages
Currying: Translating functions with tuple arguments into function with single arguments
Cron: A job scheduler (cron job is task performed at regular intervals).
Daemon: In multi-tasking operating systems, it runs in the background
Data wrangling (data munging ): Changing data formats from one form to another, manipulating clumsy data
Defragmentation: To improve I/O operations (e.g loading, extracting)
Dependencies: Subordinate but essential things
Deprecated: Disapproved
Didactic: Intended to teach
Docker: It packages all softwares with all dependencies, i.e. enterprise application into one self-contained container, which runs on any environment. 
filehandles: A number that the operating system assigns temporarily to a file
fsck: File system consistency check
Globbing: Finding some patterns
GNU: GNU not Unix
Heuristic:From experience
inode: A data structure used to represent a filesystem object
Iterable: Any list, file, string which can be manipulated with for loop is iterable
Iterator: Can be iterated only once
MapReduce:  Software for processing and generating large data sets in parallel-manner
Metadata: Ancillary information, software revision information
Netfilter : A Linux OS firewall, controlled by iptables
Operator: a symbol to perform a job (arithmetic, relational, logical, bitwise, assignment)
Overhead: Excess computation time, memory, bandwidth and other resources for a rather simple goal
Overriding: Replacing a parent-implemented method by child class in Java
Parsing: Analyzing code into parts and describing their syntactic roles
Pipeline: Many commands put together in a script to achieve a result.
Readme file: contains information about other files in a directory or archive and is commonly distributed with computer software
Refactoring: The process of cleaning up a program to make it more usable or easier to understand or less complicated
regex: Language to describe patterns in strings
Regular expression: A pattern that describes a set of strings
Router: A device acting as a gateway,connecting two networks (e.g. connecting LAN to WAN)
Segmentation fault: when the program attempts to access memory it has either not been assigned by the operating system, or is otherwise not allowed to access.
shebang:  #!/bin/sh -x (Simple text files become Bash scripts when adding a shebang line as first line, saying which program should read and execute this text file)
Stub: Generated something, but left to be filled up
subroutine: A sequence of codes that perform a specific task and can be used in other programs
tarball or tarfile: A group or archive of files that are bundled together using the tar command and usually have the .tar file extension. If the tarfile is compressed using gzip command the tarball will end with tar.gz.
Webinar: web conferencing
Variable: Reserved memory locations to store values
VMware: Cloud and virtualization software
VoIP: Technologies for the delivery of voice communications and multimedia sessions
Zombie : A Process is  ‘Zombie’ if it has stopped but still active in process table
------------------------------------------------------------------------------------------------------

Tuesday, August 1, 2017

Shebang/script/metacharacters/comments/PATH/execution..........

bang or shebang line is path to interpreter
---------------------------------------------------------
#! /usr/bin/sh
#Shebang line 
date
hostname

#!/usr/bin/env perl
#!/usr/bin/env python
##################################################
To execute .sh script
 sh script.sh

To direct the standard output (monitor display) of the code into a file, the following one-liner can be used. Here the regular execution command for the .sh file has been piped to tee command. The file data_file is generated. Its pretty useful.


sh script.sh |& tee output_file

Show top 100 lines only
sh script.sh | head -100
---------------------------------------------------------
#Metacharacters
^ $ .; [ ] { } - ? * + ( ) | \
All others are literals
---------------------------------------------------------
#Newline
    \n
#Multi-line statement
total_items = item1 +     \
                      item2 +     \
                      item3

Commenting style vary from single line to multi-line (block comments); also vary for different languages.
For C, C++, Java, SQL
// Line comment for C, C++, Java, SQL, php
--Single line comment for SQL
/*  block comment for C, C++, C# Java, SQL, php */
-----------------------------------
For Shell, Python, Perl, php
# Line comment for shell, python, perl, php, ruby

'''  block comment for python'''

: <<‘END’
block comment for shell/Linux/Bash
‘END’

<<COMMENT1
block comment for shell/Linux/Bash
COMMENT1

: '
block comment for shell/Linux/Bash
'

=begin comment
block comment for perl
=cut

=begin
block comment for ruby
=end
-----------------------------------
For MATLAB
% Line comment
; symbol at the end of statement suppresses display of the output.
-----------------------------------
For Lisp
; Line comment
-----------------------------------
For HTML
<!- Comment ->
-----------------------------------
For Haskell
-- Line comment
{-comment line1
comment line2 -}
-----------------------------------
echo $PATH
PATH=$PATH:$HOME/bin
Here PATH is modified to add the directory $HOME/bin to the end of the list.(Parameter expansion)
PATH=~/bin:$PATH:.

Debugging/Keys to excel in programming...

Code debugging is  such a difficult, tedious but intellectually-stimulating part of programming.
Code can stop working for silliest of reasons.
The script name, an alphabet case, a comma, a parentheses, the path name, an underscore, ...
All sorts of thing...
Hell of a job it is to find the issue..
But, when its caught, fixed and code works, what a relief it is!
--------------------------------------------------------------
#Learning from others codes (so many freely available)
#Asking peers
#Follow convention (because the rules are tested and proven)
#Elaborate documentation and commenting
#Review, optimize codes based on critiques
#Stringent testing of the code
#Keeping latest copy of the source code
#Keeping frequently-used commands handy
---------------------------------------------------------------------
Common coding errors......
#######PERL###########
Global symbol "@F" requires explicit package name at perl.pl line 20.
Missing right curly or square bracket at code_check.pl line 5, at end of line
syntax error at code_check.pl line 5, at EOF
Execution of code_check.pl aborted due to compilation errors.
Can't open file: No such file or directory at code_check.pl line 4.

Software testing/Software development (scrum).............

Evaluating software components and showing lacunae.
SDLC: Software Development Life Cycle (unit coding, integration coding, system testing)
Acceptance testing levels: User, Business, Alpha, Beta
Deviation between actual and expected result is defect which must be fixed by developers before testing it again.
Adhoc testing (informal): can be buddy, pair or monkey testing
Age testing:to find future defect possibility (defect age)
Agile testing: change to software as per customer needs
Alpha testing; Internal company testing (by in-house developers, QA team)
Backward compatibility testing: Data from older system can be migrated to newer version in hassle-free manner
----------------------------------------------------------------------------------
Software development loop: requirement, coding, testing, product
Conventional method...criteria fixed before development
Waterfall model
Iterative incremental model
Unconventional method...criteria amenable to change as demand crops up
Agile model (rapid modification to the software as per customer feedback). Its based on iteration model , but is faster.Its variations are :
            Dynamic System Development Methodology (DSDM)
            Scrum
            Extreme Programming (XP)
Scrum (an order arrangement of players)
Scrum in computer jargon that means  a framework where each member has  a part and which brings regularity to the system of software development. Its  a part of the agile model of software development, which caters to customer demand and takes rapid action.
Each member of scrum team has their associate roles. The framework strives to produce best result in minimum time.

Scrum has a Sprint (a short  tentative time frame), at the end which review is done. After finding the deficiencies and further requirements, another sprint is started.

System administration information, programming system, software installation, cluster job...

Software are kept in repositories and distributed in packages.
Package management involves installing and updating software.
#Installing software that come bundled up with the OS system
preference--->synaptic package manager------->search----->bioperl----->mark for installation
------------------------------
Operating Systems: Android, iOS, OS X, Windows,Linux
Web page writing languages: C++, Javascript, C, CSS, XUL, XBL 
Top web browsers: Google Chrome, Firefox, Opera, Chromium, Midori
Linux distributions: Debian (.deb), Ubuntu (.deb), Red Hat, Fedora (.rpm), Gentoo, OpenSuse, Mint, Ubuntu, CentOS (.rpm), Arch, Elementary, Manjaro, Mageia
Linux Desktop Environments: Gnome, Kde, xfce
User applications: Apache, MySQL, FTP
System performance log management: Graylog2, Logcheck, Logwatch
Command line text editor: vi/vim, nano, pico, emacs
Web server: Apache, Nginx or Lighttpd
Steps of programming: problem, algorithm, pseudocode, code
------------------------------
echo $SHELL
bash −−version
echo $BASH_VERSION
init-getty-login-bash-$user
Globbing is a form of wildcards


chown - change file owner and group


chmod 600 file – owner can read and write
chmod 700 file – owner can read, write and execute
chmod 666 file – all can read and write
chmod 777 file – all can read, write and execute

Linux can be of 2 major types based on packages.
Debian “.deb” e.g. Debian, Ubuntu
Red Hat “.rpm”e.g.  Fedora, CentOS
Commands to install, update and removal vary based on the package type.

Ubuntu------Applications---------Software Center------------Install rkward
#To check if  a package is installed in Ubuntu and Debian
aptitude show vim | grep -i state
dpkg -s vim | grep -i status
apt-cache policy vim | grep -i installed

For .deb (examples)
sudo apt-get install debian-goodies
apt-get utility is a powerful and free package management command line program, that is used to work with Ubuntu’s APT (Advanced Packaging Tool)
apt-cache command line tool is used for searching apt software package cache.
apt-cache pkgnames
#To find out package name and description
apt-cache search vsftpd
# To check Package Information
apt-cache show netcat

As with every upgrade, you will need to create a backup of your important files.


sudo apt-get install dpkg
apt-get update
apt-get install
apt-get remove
apt-get install screen

aptitude search package
aptitude safe-upgrade apache2
apt-get install lynx
sudo apt-get install vim 
For .rpm (examples)
yum update
yum search
yum erase
yum install screen

yum search all package
yum -y install lynx
yum -y install sysstat
yum install unrar
yum update httpd (for Apache)
yum update && yum install yum-utils
#To create a database, MySQL/MariaDB server must have been installed on the system.
If not, the code below can do it.
yum install mysql mysql-server
create database xyz;
-----------------------------------
Obtaining  to installing a software
#Source code download
wget url_name
wget http://nchc.dl.sourceforge.net/project/fsh/fsh.jar

#One file download
wget http://www.cyberciti.biz/here/lsst.tar.gz

#Multiple file download
wget http://www.cyberciti.biz/download/lsst.tar.gz ftp://ftp.freebsd.org/pub/sys.tar.gz ftp://ftp.redhat.com/pub/xyz-1rc-i386.rpm


URLS=”http://www.cyberciti.biz/download/lsst.tar.gz \
ftp://ftp.freebsd.org/pub/sys.tar.gz \
ftp://ftp.redhat.com/pub/xyz-1rc-i386.rpm \
http://xyz.com/abc.iso"
for u in $URLS
do
 wget $u
done
#to download all files
wget -i /tmp/download.txt
#Decompress and extract the files
tar xvf zip_file
#Change into the directory and run configure 
./configure
#To compile source code
make
#To check if the built is good
make check
Install the software
sudo make install
Verify its installation
which software_name
**************************
#Install remark
cd /tmp
wget http://savannah.nongnu.org/download/regex-markup/regex-markup_0.10.0-1_amd64.deb

sudo dpkg -i regex-markup_0.10.0-1_amd64.deb
**************************
#Compile geany
cd geany-1.22/
./configure
make
#Install geany
sudo make install
#Start geany
geany
#Tools > Plugins Manager
#To search for plugin (apt-cache search geany-plugin)
sudo apt-get install geany-plugin-vc

**************************
#install php
# yum install php-pecl-ncurses                    [On CentOS/RHEL]
# dnf install php-pecl-ncurses                    [On Fedora]
sudo apt-get install php5-dev libncurses5-dev   [On Debian/Ubuntu]

#Now compile the php extension as follows
$ wget http://pecl.php.net/get/ncurses-1.0.2.tgz
$ tar xzvf ncurses-1.0.2.tgz
$ cd ncurses-1.0.2
$ phpize # generate configure script
$ ./configure
$ make
$ sudo make install

#run the commands below
sudo echo extension=ncurses.so > /etc/php5/cli/conf.d/ncurses.ini
php -m | grep ncurses
cd /var/www/html/linfo/
./linfo-curses
**************************
#Install LAMP (Linux, Apache, MariaDB or MySQL and PHP) Stack on Debian 9
# aptitude update && aptitude install apache2 mariadb-server mariadb-client mariadb-common php php-mysqli

# aptitude update && aptitude install apache2 mysql-server mysql-client mysql-common php php-mysqli
#systemctl may be used to introspect and control the state of the " systemd " system and service manager
systemctl is-active apache2
systemctl is-active mariadb
#should return active for both. Otherwise, start both services manually:
systemctl start {apache2,mariadb}
#verify the version of Apache being used
apache2 -v
Xcreating and Populating a Database
mysql -u root -
#create a database named SPDB
MariaDB [(none)]> CREATE DATABASE SPDB;
and add two tables named AuthorsTBL and BooksTBL:

MariaDB [(none)]> USE LibraryDB;
CREATE TABLE AuthorsTBL (
AuthorID INT NOT NULL AUTO_INCREMENT,
FullName VARCHAR(100) NOT NULL,
PRIMARY KEY(AuthorID)
);

MariaDB [(none)]> CREATE TABLE BooksTBL (
BookID INT NOT NULL AUTO_INCREMENT,
AuthorID INT NOT NULL,
ISBN VARCHAR(100) NOT NULL,
Title VARCHAR(100) NOT NULL,
Year VARCHAR(4),
PRIMARY KEY(BookID),
FOREIGN KEY(AuthorID) REFERENCES AuthorsTBL(AuthorID)

);
**************************
#Compile and install it using source code
cd /tmp
wget http://savannah.nongnu.org/download/regex-markup/regex-markup-0.10.0.tar.gz
tar -xvf regex-markup-0.10.0.tar.gz
cd regex-markup-0.10.
 ./configure
make
sudo make install
stdin (keyboard)

stdout (screen)
-----------------------------------

#monitoring system load average including uptime which shows how long the system has been running, number of users together with load averages
uptime

#display a real-time state of a running Linux system

top

#To find out the system’s OS type
uname -a
arch
file /sbin/init

#View currently installed kernel
uname -r

#Tells shell type
echo "$0"

#Tells full path for installed shell 
type -a bash

#To now whether operating system is 32-bit or 64-bit
dpkg --print-architecture
getconf LONG_BIT

#To identify user
hostname

#Default command line MySQL client
mysqladmin -u root -p version

#List active and inactive memory
vmstat -a

#To find disk usage of files and directories
#du (disk usage) Commands
du  path
du -h path
du -sh path

#df (disk filesystem) Commands
df
df -a
df -h
df -k #Dispaly in kilobyte
df -m #Dispaly in megabyte

#Killing of processes is essential part of System Administartion
pidof chrome
pidof firefox

#Using ID to kill a process
pidof gimp-2.8
kill 9378
pidof gimp-2.8

#Using signal number to kill a process
pidof banshee
kill -9 9647
pidof banshee

#To kill multiple processes
pidof gimp-2.8
pidof vlc
pidof banshee
kill -9 9734 9747 9762
-----------------------------------
To process jobs in queue through cluster
 -R (Running), -Q (Waiting), -S (Suspended), -E(exiting after being run),  -H(held)

pbs script
parameters: -j oe, -o output_file, -m abe, -M email_id,

#First login to node is needed
ssh compute-1 -1

#Submit  a job
qsub pbs_script
e.g. qsub cluster_job.sh
qsub job.sh

#To check status of job (flags: -n, -u, -f)
qstat job-id
e.g. qstat -f (status of all computers)
       qstat -j (job)
checkjob job-id

To delete or kill a job (flags: -f) (qsig is sending signal to  a job)
qdel job-id
qsig -sNULL job_id

To hold  ajob, then release it
qhold job-id
qrls job-id

To see job while its running
qpeek

To delete or kill all running or queued jobs
qselect -u $USER -S -R | xargs adel
qselect -u $USER -S -Q | xargs qdel
----------------------------------------------------
#Secure shell
ssh <user>@ <host>
ssh -x seema@rohan.sdsu.edu (connecting to the host rohan)
ssh -x peema@alborz.sdsu.edu (connecting to the host alborz)
~//ssh -x peema@alborz.sdsu.edu : /home/pseema/file

#Copy file from local to remote
scp ./Desktop/file pseema@alborz.sdsu.edu
-----------------------------------
#PATH
# Set path
e.g.
export PATH=$PATH:/usr/local/bin:/home/pseema/bin

e.g.
export JAVA_HOME=/usr/local/jdk1.7.0_71
export PATH=PATH:$JAVA_HOME/bin

export HADOOP_HOME=/usr/local/hadoop
export YARN_HOME=$HADOOP_HOME
-----------------------------------
#Check software version
java -version
javac -version
scala -version
hadoop version
-----------------------------------
#Handling .jar file
hadoop jar .jar
-----------------------------------
make 
#The ‘make‘ command uses the ‘makefile‘ database . Its used to compile
make
sudo make install
----------------------------------
#Use of virtual box (this mount helps use other OS in a system)
Create  a virtual hard drive
VDI (Virtual disk image)
fixed size
start
browse
ubuntu
start
--------------------------------------
#Copy a folder to user home
cp -r path_to_dir .

cd dir
RANDOM...
init: Short for initialization is the first daemon process that starts during booting and runs till shut down.
22 is the default SSH port
Web and cloud developers 
Gui opposite is console-based
GNU Make is a development utility
Get – which downloads one or more files from a remote machine.
Put – which uploads one or more files to a remote machine.
 col =1 or "white" or "#FFFFFF"
termlet: terminal software

Learning the terminal text editors: vi/vim, emacs...

#Create a text file
vi /tmp/download.txt
#vim is improved vi

#To switch backup creation, add to the vimrc
set nobackup
set nowritebackup

#Create a directory in your home directory called vimtmp 
set backupdir=~/vimtmp
set directory=~/vimtmp

i: to start typing (inserting)


Esc: to move from insert mode to normal mode
#The following commands work in Esc or normal mode
x: to remove current character
X: to remove character to the left
A: to insert text at the end of line
u: undo action
0: cursor goes to start of the line
$: cursor goes to end of the line
^: cursor goes to first non-blank line
w: start
b: end

h: go left
l: go right
k: go up
j: go down
R: overwrites
:w Enter: save
:q Enter: quit

Linux/ installation of some important softwares....

#To read Linux info documentation in colors
apt-get install pinfo
pinfo page
pinfo grep

#To show difference in colors
yum install colordiff
sudo apt-get install colordiff

colordiff file1 file2
diff -u file1 file2 | colordiff
diff -u file1 file2 | colordiff | less -R
diff file1 file2 | remark /usr/share/regex-markup/diff

grc diff file1 file2

#To convert HTML to pdf
sudo apt-get install wkhtmltopdf
sudo ln -s /usr/bin/wkhtmltopdf /usr/local/bin/html2pdf

Laboratory tools and reagents (Micro-pipettes)...

Micro-pipettes are essential tools of R & D labs, and integral part of Good Laboratory Practices (GLPs) Micro-pipetting methods include ...