Monday, January 25, 2016

some hacks to make life easier..

1. Typically when we switch between laptop to dell monitor, it is better to resize the VNC.
To resize the VNC without creating another VNC session, we can use xrandr. I generally use aliases to switch between laptop and monitor.
alias dellsize "xrandr -s 1920x1080"
alias lapsize "xrandr -s 1360x768

2. If we make set of TB/RTL changes in our local dir and if we want to review one by one against the SVN database, below command will be very useful.
svn diff --diff-cmd tkdiff


3. Vim tips:-

:g/pattern/z#.5|echo "==========" Display context (5 lines) for all occurrences of a pattern.
:g/pattern/normal@c Perform macro recorded at c on all the lines containing the pattern
:v/./,/./-j Merge all blank lines into single blank line
:g/^/m0 Reverse the file
:g/pattern/t$ Copy all the lines matching pattern to the end of the file
0"ay0:g/<pattern>/y A Yank all lines matching a pattern to register 'a'
:g/^/pu _ Double space the file
:.,$g/^\d/exe "normal! \<C-A>" Increment numbers from current line to end-of-document by one (this assumes the default behavior of Ctrl-A to increment a number; you might need :unmap <C-A> on Windows). 
:g/DEBUG/exe "norm! I/*\<Esc>A*/\<Esc>" Comment lines containing "DEBUG" statements in a C program.
:let i=0 | 'a,'bg/xyz/s/xyz/\=i/ | let i=i+1
Insert incremental numbers
:%s/\d\+/\=(submatch(0)+3)/
Increment all the integers by constant
:registers or :reg c Will display the contents of all the registers
:%s/^.*$/\U&/g Changing to Upper case letters
:%s/^.*$/\L&/g Changing to Lower case letters



4. Command line:-
perl -pi -e ’s/lookFor/replaceWith/g’ *.fileExtensionSingle line replace script
perl -n -e 'if ( /<tag/ .. /<\/tag/)' -e '{ print "$.:$_"; }' file.xmlMatch all the patterns from <tag> to </tag> and print
ls abc* | sed 's/\(abc_\)\(.*\)/cp "\1\2" "\2"/' |shCopy files with removing some prefix
echo | mutt -s "simple mail sending perl script but not working" -a send_mail.pl tgunasekaran@micron.comSending mail from Linux server with attachment file
pwd | rev | awk -F \/ '{print $1}' | revExtracting current directory from PWD
bcMathematical calculator in Linux

sed -i".bak" '/max_errors/d' *.pyRemove the line containing max_errors from all *py files. Then remove all *.bak files

1 comment: