Wednesday, August 27, 2014

Networking commands - flushdns

Flushdns - Fire this command when you want to clear the DNS cache.

At times, when  a machine is not reachable/pingable, fire the following command.


C:\Users\Administrator>ipconfig /flushdns

Windows IP Configuration

Successfully flushed the DNS Resolver Cache.

Sunday, August 24, 2014

Destination Host Unreachable Error

Two things you could do :

1) On a windows machine go to C:\Windows\System32\drivers\etc\notepad hosts
(You would have to run this with admin rights )

Make sure you remove any prior mapping of your host file.
Try pinging the machine again.

2) On a command prompt, type arp -a
For a list of the currently available/reachable Ip's. 
See if the IP you are trying to ping is listed there.

For additional information, follow the stack overflow link here.

http://superuser.com/questions/453933/pinging-a-machine-on-my-local-network-gets-an-unreachable-response-from-my-own 

Tuesday, August 19, 2014

Importing a CSV file into database with SQL Server Mgmt Studio

Follow the link below to know how!
https://support.discountasp.net/KB/a1179/importing-csv-file-into-your-database-with-sql-server.aspx

And refer to the screen shots here.

SQL Alchemy!

The complete reference to SQL Alchemey!
http://www.sqlalchemy.org/library.html

Hibernat-ing!

Eclipse Install and Setup for Hibernate
http://kaanmutlu.wordpress.com/2011/07/30/hibernate-installationsetup-on-eclipse-ide/

Follow the link below for a sample Hibernate application using JPA (annotations) and XML.
http://kaanmutlu.wordpress.com/2011/07/30/sample-hibernate-application/

Renaming a table in different databases

Awesome JDBC Usage with Design Patterns

1) Follow the link below for a well written example on JDBC Singleton Connectivity.

http://theopentutorials.com/tutorials/java/jdbc/jdbc-examples-introduction/#Singleton_design_pattern

2) A simple JDBC Application
http://www.tutorialspoint.com/jdbc/jdbc-sample-code.htm

Build an Android App on BlueMix

Follow the link below to learn how to develop and deploy an android app on BlueMix!

https://www.ng.bluemix.net/docs/BuildingMobile.jsp

Sunday, August 17, 2014

Geo-Json the Google Doc

OGRE - ogr2ogr web client

Convert to GeoJSON
http://ogre.adc4gis.com/

Geo-Json external data

Loading external data into d3


Quick video that explains how to load external data eg: json into D3
https://www.youtube.com/watch?v=2S1AbEWX85o

D3JS Group element. - Transform etc

Difference between Datum and Data in D3

Add an image to D3

D3 Json Download Links

Here's the link to download the json's in the d3 examples.
http://static.cybercommons.org/js/d3/examples/data/

D3 visualization for CodeFlower

Here's the link to the D3 Code Flower Visualization
http://redotheweb.com/CodeFlower/

MAMP Server

Here's the link to download the MAMP Server.
http://www.mamp.info/en/downloads/

Geo Json Useful Links

1. The Geo-Json specification
http://geojson.org/geojson-spec.html

SVG Primer

A detailed document on SVG standards for today's brwsers from w3c.

http://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html

Access a DB from a Java Application

Follow the steps below to see how to access a DB from a Java web application

https://www.ng.bluemix.net/docs/#services/SQLDB/index.html#sqldb_002

Creating apps with Java Web Starter

Follow the tutorial below to find how to create an app with Java Web starter
https://www.ng.bluemix.net/docs/#starters/javawebstarter/index.html#javawebstarter

Installing the cf Command Line Interface

Follow the link below for easy steps on each OS.
http://docs.cloudfoundry.org/devguide/installcf/install-go-cli.html

Deploying on BlueMix using Eclipse

1) Download and Install Eclipse Kepler
2) Eclipse Market Place -> Download Blue Mix plugins from here
http://marketplace.eclipse.org/content/ibm-codename-bluemix-eclipse-kepler#.U7ZcfBDCe6M

Choose the following options  :
3) Video explaining how to deploy to BlueMix using Eclipse
https://www.youtube.com/watch?v=Ro0CSPeoFoY

4) Setting up Eclipse, Git and RTC Desktop to access DevOps services
https://hub.jazz.net/tutorials/clients

5) Using Eclipse to deploy an application to BlueMix
https://www.ibm.com/developerworks/community/blogs/msardana/entry/exploring_bluemix_exploring_bluemix_using_eclipse_to_deploy_your_application_to_bluemix?lang=en

6)Developing IBM Bluemix applications in Java with Eclipse and DevOps Services
https://hub.jazz.net/tutorials/jazzrtc

SQL DB Primer

D3Js maps!

Wednesday, August 13, 2014

BlueMix Trouble Shooting Links

Orient DB

D3JS - Data Driven!

The complete gallery
https://github.com/mbostock/d3/wiki/Gallery

http://bl.ocks.org/mbostock


D3-Dateline - demodata.json
https://github.com/pbinkley/D3-dateline/blob/master/demodata.json

Use de-tip to add a tooltip to a bar chart
http://bl.ocks.org/Caged/6476579

D3 - Source code
A Javascript visualization library for HTML and SVG
https://github.com/mbostock/d3




Let's recycle!

Execute BASH Online

Monday, August 11, 2014

vi

DBX Commands

The following snippets are as per the Oracle docs.
http://docs.oracle.com/cd/E19422-01/819-3683/command_ref.html#52675

1. source - The source command executes commands from a given file. It is valid only in native mode.

Syntax

source filename
Execute commands from file filename. $PATH is not searched.

2. where  - The where command prints the call stack.

Native Mode Syntax

where
Print a procedure traceback.
where number
Print the number top frames in the traceback.
where -f number
Start traceback from frame number.
where -h
Include hidden frames.
where -l
Include library name with function name
where -q
Quick traceback (only function names).
where -v
Verbose traceback (include function args and line info).

where:
number is a number of call stack frames.
Any of the above forms may be followed by a thread or LWP ID to obtain the traceback for the specified entity.

Java Mode Syntax


where [thread_id]
Print a method traceback.
where [thread_id] number
Print the number top frames in the traceback.
where -f [thread_id] number
Start traceback from frame number.
where -q [thread_id]
Quick trace back (only method names).
where -v [thread_id]
Verbose traceback (include method arguments and line information).

where:
number is a number of call stack frames.
thread_id is a dbx-style thread ID or the Java thread name specified for the thread.


3. cont Command

The cont command causes the process to continue execution. It has identical syntax and identical functionality in native mode and Java mode.

Syntax


cont
Continue execution. In an MT process all threads are resumed. Use Control-C to stop executing the program.
cont ... -sig signal
Continue execution with signal signal.
cont ... id
The id specifies which thread or LWP to continue.
cont at line [ id ]
Continue execution at line line. id is required if the application is multi-threaded.
cont ... -follow parent|child|both
If the dbx follow_fork_mode environment variable is set to ask, and you have chosen stop, use this option to choose which process to follow. both is only applicable in the Sun Studio IDE.

4. detach Command

The detach command releases the target process from dbx's control.

Native Mode Syntax


detach
Detach dbx from the target, and cancel any pending signals.
detach -sig signal
Detach while forwarding the given signal.
detach -stop
Detach dbx from the target and leave the process in a stopped state. This option allows temporary application of other /proc-based debugging tools that might be blocked due to exclusive access. For an example, see Detaching dbx From a Process.

DBX Debugger

Unix Debuggers

Watchdog Utilities in Unix

Loops and others in scripting

1. Returning a value from a function in shell script
http://stackoverflow.com/questions/8742783/returning-value-from-called-function-in-shell-script

2. If condition variables.
21. Test conditions in an If loop provided by the shell.

The tests below are test conditions provided by the shell: 

-b file = True if the file exists and is block special file. 
-c file = True if the file exists and is character special file. 
-d file = True if the file exists and is a directory. 
-e file = True if the file exists. 
-f file = True if the file exists and is a regular file 
-g file = True if the file exists and the set-group-id bit is set. 
-k file = True if the files' "sticky" bit is set. 
-L file = True if the file exists and is a symbolic link. 
-p file = True if the file exists and is a named pipe. 
-r file = True if the file exists and is readable. 
-s file = True if the file exists and its size is greater than zero. 
-s file = True if the file exists and is a socket. 
-t fd = True if the file descriptor is opened on a terminal. 
-u file = True if the file exists and its set-user-id bit is set. 
-w file = True if the file exists and is writable. 
-x file = True if the file exists and is executable. 
-O file = True if the file exists and is owned by the effective user id. 
-G file = True if the file exists and is owned by the effective group id. 
file1 –nt file2 = True if file1 is newer, by modification date, than file2. 
file1 ot file2 = True if file1 is older than file2. 
file1 ef file2 = True if file1 and file2 have the same device and inode numbers. 
-z string = True if the length of the string is 0. 
-n string = True if the length of the string is non-zero. 
string1 = string2 = True if the strings are equal. 
string1 != string2 = True if the strings are not equal. 
!expr = True if the expr evaluates to false. 
expr1 –a expr2 = True if both expr1 and expr2 are true. 
expr1 –o expr2 = True is either expr1 or expr2 is true.
http://www.unix.com/shell-programming-and-scripting/81862-how-check-if-file-exists-using-if-statement.html

2.2 If-else Tutorial
http://www.dreamsyssoft.com/unix-shell-scripting/ifelse-tutorial.php 

Signals and Traps

Sunday, August 10, 2014

AWK

1. The AWK Tutorial
http://www.grymoire.com/Unix/Awk.html

2. FS : The input field separator variable
Example Usage :
The following script is used to find the major and the minor version of the release kernel.
-bash-4.1$ uname -r
1.7.17(0.262/5/3)
-bash-4.1$ uname -r | awk ' BEGIN { FS="[ , .]"} {print $1 }'
1
-bash-4.1$ uname -r | awk ' BEGIN { FS="[ , .]"} {print $2 }'
7
-bash-4.1$ uname -r | awk ' BEGIN { FS="[ , .]"} {print $3 }'
17(0
-bash-4.1$ uname -r | awk ' BEGIN { FS="[ , .]"} {print $4 }'
262/5/3)
3. NF - Number of Fields
Be sure to take a look at the example in the tutorial here. Crisp explanation.
http://www.grymoire.com/Unix/Awk.html#uh-17

What is Darwin?

Unix special variables

How to find RAM utilization by a user in Linux

NSD - Notes System Diagnostic

NSD - Notes System Diagnostic
http://www-01.ibm.com/support/docview.wss?uid=swg21100917

Probably the best doc on NSD so far!
NSD - A practical guide overview 



Saturday, August 9, 2014

Shell Commands

1. Aliases - Update these values in .bash_profile file


          Example  : alias l='ls -l'
 
.bash_profile file is a shell script that is executed each time you log in 
 
2. type - Used to determine whether the command is an executable, an alias or a function.
Syntax :  type command

Example : 
Input :
function today {
echo "print data" 
}

>type today
 
output 
today is a function
today () 
{ 
    echo "print data"
}


3. bashrc - appropriate place to store functions and aliases. To read about syntax etc see here.

4. typeset
http://www.unix.com/unix-for-dummies-questions-and-answers/32178-typeset-ksh.html

5. tr - Used to replace/remove certain characters
http://en.wikipedia.org/wiki/Tr_%28Unix%29

6.  uname  - returns certain system information
http://en.wikipedia.org/wiki/Uname

(Taken from man )
SYNOPSIS
       uname [OPTION]...

DESCRIPTION
       Print certain system information.  With no OPTION, same as -s.

       -a, --all
              print  all  information,  in the following order, except omit -p
              and -i if unknown:

       -s, --kernel-name
              print the kernel name

       -n, --nodename
              print the network node hostname

       -r, --kernel-release
              print the kernel release

       -v, --kernel-version
              print the kernel version

       -m, --machine
              print the machine hardware name

       -p, --processor
              print the processor type or "unknown"

       -i, --hardware-platform
              print the hardware platform or "unknown"

       -o, --operating-system
              print the operating system

       --help display this help and exit

       --version
              output version information and exit


Example demonstrating usage of tr and uname :
-bash-4.1$ uname -s | tr -d /
CYGWIN_NT-6.1-WOW64
-bash-4.1$ uname -s | tr -d C
YGWIN_NT-6.1-WOW64
-bash-4.1$
7. Export - In a way, used to make variables global
http://www.cyberciti.biz/faq/linux-unix-shell-export-command/

8. which - Used to locate the executable for a command.
 http://www.computerhope.com/unix/uwhich.htm
Example usage :
/usr/bin/cat
-bash-4.1$ which -p cat
9. whereis - Locates the binary, source and manual page files for a command.
http://www.computerhope.com/unix/uwhich.htm

Example usage :  
-bash-4.1$ whereis cat
cat: /bin/cat.exe /usr/bin/cat.exe /usr/share/man/man1/cat.1.gz
10.env - used to print the env variables or to set  certain values temporarily.
http://www.computerhope.com/unix/uenv.htm

11. id - Print  real and effective ID's and GUIDs
http://linux.about.com/library/cmd/blcmdl1_id.htm
Example usage :
-bash-4.1$ id
uid=500(Administrator) gid=513(None) groups=513(None),545(Users)
-bash-4.1$ id -n
12. sed
http://www.grymoire.com/unix/sed.html

13. pmap - Memory utilization of a process
http://www.tutorialspoint.com/unix_commands/pmap.htm

http://www.cyberciti.biz/tips/howto-find-memory-used-by-program.html


14. svmon - AIX specific parameter that captures and analyses a snapshot of virtual memory.
http://ps-2.kev009.com/tl/techlib/manuals/adoclib/cmds/aixcmds5/svmon.htm

View an output screenshot here :
http://publib.boulder.ibm.com/infocenter/realtime/v2r0/index.jsp?topic=%2Fcom.ibm.softrt.aix32.doc%2Fdiag%2Fproblem_determination%2Faix_cmd_svmon.html

15. iconv - An API used to convert between different standard encodings
http://en.wikipedia.org/wiki/Iconv

16. who - Shows the currently logged in user
 (Taken from man)
SYNOPSIS
       who [OPTION]... [ FILE | ARG1 ARG2 ]

DESCRIPTION
       Print information about users who are currently logged in.

       -a, --all
              same as -b -d --login -p -r -t -T -u

       -b, --boot
              time of last system boot

       -d, --dead
              print dead processes

       -H, --heading
              print line of column headings

17. $$ - The process id of the current shell. Used when creating unique temporary file names.
Example usage :
-bash-4.1$ echo $$
3768
18. mktemp - The secure way of creating temporary files
tempfoo=`basename $0`
TMPFILE=`mktemp -t ${tempfoo}` || exit 1
echo "program output" >> $TMPFILE
 
-t is now deprecated. Use Use mktemp ${tempfoo}.XXXXXX
 
Read below for a discussion on mktemp against $$ for creating temporarily files. 
http://stackoverflow.com/questions/78493/what-does-mean-in-the-shell  
 
18. ps - Reports process status
(Taken from man)
OPTIONS
       -a, --all
              show processes of all users

       -e, --everyone
              show processes of all users

       -f, --full
              show process uids, ppids

       -h, --help
              output usage information and exit

       -l, --long
              show process uids, ppids, pgids, winpids


       ps -W : Shows windows as well as cygwin processes
       

       ps -p p_id : Details of a specific process

Example of ps -f:

-bash-4.1$ ps -f
     UID     PID    PPID  TTY        STIME COMMAND
Administ    3768    3916 pty0       Aug 10 /usr/bin/bash
Administ   12776    3768 pty0     07:16:48 /usr/bin/ps
Administ    3916       1 ?          Aug 10 /usr/bin/mintty

19. pid - Process id
20. ppid - Parent process id
21. pstree -  A program showing the relationship of all processes in a tree like manner.
22. htop - Simpler process management and a better UI.
http://delightlylinux.wordpress.com/2012/06/25/what-is-pid-and-ppid/

23. Use of  single quote (') - To treat it as a command.
Example usage :

Without quotes : 
-bash-4.1$ v=ps -a
-bash: -a: command not found

With quotes
-bash-4.1$ v='ps -a'
-bash-4.1$ $v
      PID    PPID    PGID     WINPID   TTY     UID    STIME COMMAND
     7368    3768    7368       3672  pty0     500 07:16:49 /usr/bin/ps
     3768    3916    3768       1492  pty0     500 08:14:12 /usr/bin/bash
     3916       1    3916       3916  ?        500 08:14:12 /usr/bin/mintty

24. Find the launching command for a particular PID.

-bash-4.1$ ps -a
      PID    PPID    PGID     WINPID   TTY     UID    STIME COMMAND
     7064    3768    7064       8664  pty0     500 07:19:06 /usr/bin/ps
     3768    3916    3768       1492  pty0     500 08:14:12 /usr/bin/bash
     3916       1    3916       3916  ?        500 08:14:12 /usr/bin/mintty

-bash-4.1$ ps -p 3916
      PID    PPID    PGID     WINPID   TTY     UID    STIME COMMAND
     3916       1    3916       3916  ?        500 08:14:12 /usr/bin/mintty

(Strips off the header)
-bash-4.1$ ps -p 3916 | grep -i -v COMM
     3916       1    3916       3916  ?        500 08:14:12 /usr/bin/mintty

25. lslpp -  Lists installed software products


Watch a detailed video here explaining details and usage.
https://www.youtube.com/watch?v=-9oJkRVFvTM

Read here for the text corresponding to the above video.
http://ps-2.kev009.com/tl/techlib/manuals/adoclib/cmds/aixcmds3/lslpp.htm#E088D37887joyc

A complete description of the commands.
http://www-01.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.cmds3/lslpp.htm?lang=en

26. /etc/issue - Used to customize your Unix Logon
http://www.linuxfromscratch.org/blfs/view/5.1/postlfs/logon.html

27. egrep - Extended Global regular Expressions
Make sure you go through the examples listed here to get a good feel about egrep.

Also it can be used using grep -E (see man)
http://www.cs.columbia.edu/~tal/3261/fall07/handout/egrep_mini-tutorial.htm

28. GDB/pstack and gstack
gdb - GNU Debugger
http://www.gnu.org/software/gdb/

pstack/gstack - Linux executable
It prints a stack trace of running processes

http://www.linuxcommand.org/man_pages/pstack1.html
http://linux.die.net/man/1/gstack

29. lsof - List open files
http://en.wikipedia.org/wiki/Lsof

30. declare - declare a variable as array, read-only, number only etc
http://www.linuxjournal.com/content/bash-declare-statement

31. kill - To kill a process
http://www.songsinhispresence.com/cdinfo.html#taken%20link

32. shift - This command takes one argument, a number. The positional parameters are shifted to the left by this number.
Read the link below for a good example on the same.
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_07.html

33. sleep - Sleep is used to delay for a particular amount of time.
http://www.computerhope.com/unix/usleep.htm

34. pgrep  - It searches for all the named processes that can be specified as extended regular expression patterns, and—by default—returns their process ID. Alternatives include pidof (finds process ID given a program name) and ps.

http://en.wikipedia.org/wiki/Pgrep
http://linux.die.net/man/1/pgrep

35. cut - Print selected parts of lines from each FILE to standard output.

http://www.thegeekstuff.com/2013/06/cut-command-examples/

http://www.folkstalk.com/2012/02/cut-command-in-unix-linux-examples.html

36. grep -  searches the named input FILEs (or standard input if no files are
       named, or if a single hyphen-minus (-) is given as file name) for lines
       containing  a  match to the given PATTERN.  By default, grep prints the
       matching lines.

-e PATTERN, --regexp=PATTERN
              Use  PATTERN  as  the  pattern.   This  can  be  used to specify
              multiple search patterns, or to protect a pattern beginning with
              a hyphen (-).  (-e is specified by POSIX.)

       -f FILE, --file=FILE
              Obtain  patterns  from  FILE,  one  per  line.   The  empty file
              contains zero patterns, and therefore matches nothing.   (-f  is
              specified by POSIX.)

       -i, --ignore-case
              Ignore  case  distinctions  in  both  the  PATTERN and the input
              files.  (-i is specified by POSIX.)

       -l, --files-with-matches
              Suppress  normal  output;  instead  print the name of each input
              file from which output would normally have  been  printed.   The
              scanning  will  stop  on  the  first match.  (-l is specified by
              POSIX.)

37. set - used to define and determine values of the system environment.
 -m  :
Background jobs will run in a separate process group and a line will print upon completion. The exit status of background jobs is reported in a completion message. On systems with job control, this flag is turned on automatically for interactive shells.

http://www.computerhope.com/unix/uset.htm
http://linux.about.com/library/cmd/blcmdln_set.htm

38. stty - Change and print terminal line settings
http://unixhelp.ed.ac.uk/CGI/man-cgi?stty

       -a, --all
       print all current settings in human-readable form

       -g, --save
       print all current settings in a stty-readable form

       -F, --file=DEVICE
       open and use the specified DEVICE instead of stdin

39. compress  - compacts the files so that it will become smaller.
http://www.computerhope.com/unix/ucompres.htm

40. tput - Utilizes the terminal capabilities
http://en.wikipedia.org/wiki/Tput











 
 

Shell Scripting - Learning the commands and looping structures.

Online Bash Editor
Execute shell script on the Web!

http://www.compileonline.com/execute_bash_online.php

Loops


1. For Loop
http://www.cyberciti.biz/faq/bash-for-loop/

Friday, August 8, 2014