Thursday, March 29, 2018

Important GIT tricks


  1. To view the diff of the files using vimdiff, 
    1. Open ~/.gitconfig and append the following lines
      [diff]
        external = git_diff_wrapper
NOTE: you can also do it, by issuing "git config --global diff.tool vimdiff", but I have not tried.
References: https://technotales.wordpress.com/2009/05/17/git-diff-with-vimdiff/
https://stackoverflow.com/questions/3713765/viewing-all-git-diffs-with-vimdif

2. To ignore the cscope files showing from "git status [-s]", do the following.
- go to the working directory
- and add cscope file(s) in .gitignore file

Thursday, August 3, 2017

Logical Reasoning - Interview questions

There are 8 chemicals out of which one is poisoned. You have three lab rats to test them on. Each chemical takes 10 mins to work. How will you find out the poisoned chemical in the least possible time?



Thursday, August 20, 2015

Grep with function name (with different colors) recursively

#!/bin/csh

#

# Maximum can be any parameters (if user has given '*' as files)
#
if ( $#argv < 1 ) then
    echo "\n[USAGE]: $0 <pattern> <files>\n";
    exit
endif

#awk -v re=$1 '/^[[:alpha:]]/{f=FNR"-"$0} $0~re{printf "%s\n%d:%s\n--\n",f,FNR,$0; f="" }' $2
#awk -v re='CANMIC_MX_LOCK' '/^[[:alpha:]]/{f=FNR"-"$0} $0~re{printf "\033[1;31m%s\n\033[34m%d:\033[0m%s\n--\n",f,FNR,$0; f="" "\033[0m" }' *
#awk -v re=$1 '/^[[:alpha:]]/{f=FNR"-"$0} $0~re{printf "\033[1;31m%s\n\033[34m%d:\033[0m%s\n--\n",f,FNR,$0; f="" "\033[0m" }' $2
    foreach i (`find . -name "*" -type f -print`)
    awk -v re=$1 '/^[[:alpha:]]/{f=FNR"-"$0} $0~re{printf "\033[1;32m[%15s]\t\033[1;31m%-64s\t\033[34m%s\n--\033[0m\n",FILENAME,f,$0; f="" }' $i
    end

Output:
[./canmic/canmic_err.c] 53-canmic_state_set(int newstate, int *oldstate)                                CANMIC_MX_LOCK();
--
[./canmic/canmic_err.c] 77-canmic_stateful_write(char *blkdata, size_t blksize, int blknmbr)            CANMIC_MX_LOCK();
--
[./canmic/canmic_err.c] 93-canmic_stateful_dirty(scnMsg_t *scnmsg)                                      CANMIC_MX_LOCK();
--
[./canmic/canmic_err1.h]                                                                                #define CANMIC_MX_LOCK()        do {    \
--
[./canmic/canmic_err.h]                                                                         #define CANMIC_MX_LOCK()        do {    \

Tuesday, January 6, 2015

Samsung Secret codes to test

*#0*#  => To test all the available features in the Samsung phone
*#self# (or *#7353#) ==> To test the sensors and camera

References:
http://www.androidcentral.com/how-uncover-and-use-hidden-service-menu-galaxy-s3

Sunday, October 19, 2014

Hello World Assembly Programming

; Macros used in NASM assembler
%define SYS_EXIT    1
%define SYS_READ    3
%define SYS_WRITE   4
%define STDOUT      1
%define STATUS      0
%define SYS_INTR    0x80

section .data
    hello: db 'Hello World!', 10 ;NOTE This 10 is for new line
    ;hello: db 'Hello World!'
    helloLen: equ $-hello           ;This will have the length of helloLen
                                    ; Note unlike "hello", helloLen is not an address; but value

section .text
    global _start

_start:
        ;Printing Hello World String.
        mov eax, SYS_WRITE
        mov ebx, STDOUT
        mov ecx, hello
        mov edx, helloLen
        int SYS_INTR

        ;Exit from main program
        mov eax, 1
        mov ebx, 0
        int SYS_INTR
        ret                 ; This will not get executed at all

Command to Assemble:

nasm -f elf hello.asm

Command to Link:
ld -s -o hello hello.o -m elf_i386 (Note elf_i386 denotes that this needs to be linked for 32 bit application)

Friday, October 10, 2014

DAS, NAS, SAN (FC & ISCSI & FCOE)

LINKS:
http://www.stonefly.com/resources/watch.asp?vid=FCoE-vs-iSCSI,-What%27s-The-Better-Choice-For-You#video


DAS:

SERVER-SERVER: 
PHYSICAL: ETHERNET
PROTOCOL: TCPIP
SERVER-STORAGE:
PHYSICAL: SCSI (SATA CARDS)
PROTOCOL: SCSI
CONS:
Free Storage in one server could not be shared with other


NAS:

SERVER-SERVER: 
PHYSICAL: ETHERNET
PROTOCOL: TCPIP
SERVER-STORAGE:
PHYSICAL: ETHERNET
PROTOCOL: TCPIP
PROS:
- Centralized Storage
- Sharable
- Data can be accessed as \\12.11.1.2\file_name (means, the server or host knows the storage is not Local)
CONS:
- File Level Transfer, hence slower
- Did support all applications (like mail exchange, database so on)
But now it supports all the applications



SAN (with FC):

SERVER-SERVER: 
PHYSICAL: ETHERNET
PROTOCOL: TCPIP
SERVER-STORAGE:
PHYSICAL: Fiber Channel
PROTOCOL: Fiber Channel
PROS:
- Centralized Storage
- Block Level Transfer
- Data can be accessed as D:\ (which means, the server assumes the storage is local BUT IT IS NOT)
CONS:
- High Cost
- New deployment needed server to have HBA (new PCI card)



SAN (with iSCSI):

SERVER-SERVER: 
PHYSICAL: ETHERNET
PROTOCOL: TCPIP
SERVER-STORAGE:
PHYSICAL: Ethernet
PROTOCOL: ISCSI (NOT TCPIP; and hence supports BLOCK_TRANSFER)
PROS:
- Centralized Storage
- Block Level Transfer
- No need for HBA
CONS:
- NO CONS IDENTIFIED AS OF NOW (IT IS TAKING OVER FC MARKET)



SAN (with FCOE):

SERVER-SERVER: 
PHYSICAL: ETHERNET
PROTOCOL: TCPIP
SERVER-STORAGE:
PHYSICAL: Ethernet
PROTOCOL: Fiber Channel (NOT TCPIP or ISCSI)
PROS:
- Centralized Storage
- Block Level Transfer
CONS:
- FCOE HBA Cards are needed for servers



Monday, May 12, 2014

Screen Command in Linux

screen:
=========
Ctrl-a c Create new window (shell)
Ctrl-a k Kill the current window (could be ctrl+a <shift k>)
Ctrl-a w List all windows (the current window is marked with "*")
Ctrl-a 0-9 Go to a window numbered 0-9
Ctrl-a n Go to the next window
Ctrl-a Ctrl-a Toggle between the current and previous window
Ctrl-a [ Start copy mode
Ctrl-a ] Paste copied text
Ctrl-a ? Help (display a list of commands)
Ctrl-a Ctrl-\ Quit screen
Ctrl-a D (Shift-d) Power detach and logout
Ctrl-a d Detach but keep shell window open
Ctrl-a Esc TO SCROLL THROUGH THE PREVIOUS BUFFERS (V V USEFUL)

References:
http://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/
http://aperiodic.net/screen/quick_reference