Q: What is the difference between these two shell statements?
$cmd >> $logFile 2>&1
And
$cmd 2>&1 >> $logFile
Answer:
The first one is right and second one is wrong.
first one redirects any output from the $cmd to the $logFile. The second one just redirects the output and not the STDERR to the $logFile.
Reference:
http://www.linux-mag.com/id/5103
Friday, November 13, 2009
Sunday, November 01, 2009
Moral Dilemma
Q: How to decide if an action is morally right or wrong? E.g.
1. Taking a personal prinout using office printer?
2. Making a phone call using office phone ?
3. Stealing salad from the salad bar at office canteen?
4. Keeping the IPOD nano 4 GB found on a street at halloween pary on franklin street with urself?
Ans: If you can tell all your friends and family members about the action then the action should be morally right.
1. Should be OK.
2. Should be OK.
3. WRONG.
4. Dicey.
1. Taking a personal prinout using office printer?
2. Making a phone call using office phone ?
3. Stealing salad from the salad bar at office canteen?
4. Keeping the IPOD nano 4 GB found on a street at halloween pary on franklin street with urself?
Ans: If you can tell all your friends and family members about the action then the action should be morally right.
1. Should be OK.
2. Should be OK.
3. WRONG.
4. Dicey.
Thursday, October 15, 2009
It is Democracy...So why not create own phrases, sentences and syndromes like others. So here is one from me:
Finish it syndrome.
The syndrome is one in which the DIET conscious person end up eating more in following scenario:
1. Person end up taking more cereal as he wanted to finish the contents of the cereal box. Why not use it next item it is not going to get perished.
2. Person end up taking more serving as he did not wanted the food to be wasted. Why not use the zip- lock bags..:-)
Finish it syndrome.
The syndrome is one in which the DIET conscious person end up eating more in following scenario:
1. Person end up taking more cereal as he wanted to finish the contents of the cereal box. Why not use it next item it is not going to get perished.
2. Person end up taking more serving as he did not wanted the food to be wasted. Why not use the zip- lock bags..:-)
Thursday, October 08, 2009
Motivation for fast running
I always wanted to run fast but was never motivated. But then I found something which motivated me.
I read somewhere that running fast makes your abs and who does not want to have six pack abs.
Six pack abs are enough reason for me to be motivated for fast running.
I read somewhere that running fast makes your abs and who does not want to have six pack abs.
Six pack abs are enough reason for me to be motivated for fast running.
Sunday, July 05, 2009
GDB handy commands
Multi-threaded
info threads
Signals
info signals
// To pass the signal from GDB to the process.
handle SIGINT pass
To Debug a running process using GDB
gdb
info threads
Signals
info signals
// To pass the signal from GDB to the process.
handle SIGINT pass
To Debug a running process using GDB
gdb
Tuesday, May 19, 2009
VIM : Comments lines with a pattern in a file
The lines in a file containing a specific pattern can be commented in VIM using the :g command.
:g command is used in following form
:g/[patern]/[cmd]
Example:
:g/JR/normal I //
explanation
Pattern : JR
Cmd : normal I //
"I" is used in VIM to start insert mode at the start of line and "//" is the comment character used in PHP.
Enjoy VIM. Check out the help :g if you have more questions.
:g command is used in following form
:g/[patern]
Example:
:g/JR/normal I //
explanation
Pattern : JR
Cmd : normal I //
"I" is used in VIM to start insert mode at the start of line and "//" is the comment character used in PHP.
Enjoy VIM. Check out the help :g if you have more questions.
Monday, March 30, 2009
Toggle Comment in VIM in one line using perl
There are lot of scripts in VIM which can toggle comments for you. But interestingly there is not a one liner which I can execute on systems where I do not have my vimrc file.
try this mapping
:map F2 V:!perl -nle 'if (/^\s*\/\//) { s/\s*\/\/\s*(.*)/$1/g; print } else {print "//".$_}'^Mj
You can map Alt+C or Ctrl+T something which is faster than F2
This mapping will comment and uncomment the C-style comment. I have tried this on Ubuntu and VIM 7.1 and works fine for me
Note: The map command may not work on copying as the VIM may not recognize the Ctrl - M character. You have to Ctrl- V and then Enter to make it work
try this mapping
:map
You can map Alt+C or Ctrl+T something which is faster than F2
This mapping will comment and uncomment the C-style comment. I have tried this on Ubuntu and VIM 7.1 and works fine for me
Note: The map command may not work on copying as the VIM may not recognize the Ctrl - M character. You have to Ctrl- V and then Enter to make it work
Friday, March 13, 2009
Singleton versus Static
These are rules which I use to decide where or not my class will be a Singleton or Static:
- Control over construction. Timing issues.
- Polymorphism.
- One versus multiple instances.
Tuesday, March 10, 2009
Formatting XML in VIM - xmllint --format -
XML text can be formatted in VIM by running the xmllint command over the selected text.
!xmllint --format -
Note the hyphen at the last.
Tried searching for sorter options for --format but did not found any.
!xmllint --format -
Note the hyphen at the last.
Tried searching for sorter options for --format but did not found any.
Monday, March 09, 2009
VNC not working on locked PC
Problem:
---------
I found that the VNC was not working on my PC(Windows XP) when it was locked using Ctrl+Alt+Del. Interestingly it did worked when the PC was not locked.
Solution:
---------
While installing VNC make sure that you select the option to install it as a service so it can be seen in services.msc
On installing VNC, it provides an option to install as a service. If it is not installed as an service, the VNC cannot be done on a locked PC.
Reason:
--------
This is what as told by one of my colleagues. Seems to be logical.
Windows uses API from gina.dll which provides the capabilities for locking/unlocking the workstation. API from gina.dll are accessible only by the windows services and not by other programs.
---------
I found that the VNC was not working on my PC(Windows XP) when it was locked using Ctrl+Alt+Del. Interestingly it did worked when the PC was not locked.
Solution:
---------
While installing VNC make sure that you select the option to install it as a service so it can be seen in services.msc
On installing VNC, it provides an option to install as a service. If it is not installed as an service, the VNC cannot be done on a locked PC.
Reason:
--------
This is what as told by one of my colleagues. Seems to be logical.
Windows uses API from gina.dll which provides the capabilities for locking/unlocking the workstation. API from gina.dll are accessible only by the windows services and not by other programs.
Subscribe to:
Posts (Atom)