Friday, June 22, 2012

FAQ

FAQ
Q: cifs_mount failed w return code 22 on Ubuntu 11
A: apt-get install smbfs

Q: mount command on Mac
A: sudo mount_smbfs "//bjcheny:zhao&123@bjcheny-work/301" /Volumes/  # for Mac

Q: gdb on Mac
A: different from what's on linux

  1. gdb -arch i386 301/IBM\ Lotus\ Symphony.app/
  1. b IniParser::IniParser
  1. r
  1. (opt) kill # and then build and replace dylib
  1. (opt) r    # gdb will re-read dylib
cat /etc/passwd | wc -l
  • useradd -d [home directory]
  • userdel -r
CentOS release 5.2 (Final)

http://developer.apple.com/library/mac/#technotes/tn2124/_index.html

Q: if [ -s /etc/redhat-release ]
A: size is no zero

http://tldp.org/LDP/abs/html/fto.html

Q: list all users on Linux
A: cat /etc/passwd | cut -d":" -f1
Also, to find out the total number of accounts, enter:

Q: useradd & userdel
A: 
http://linux.die.net/man/8/useradd 

http://linux.die.net/man/8/userdel


Q: Is /etc/redhat-release existing on CentOS
A: Yes, as below:
[root@www ~]# cat /etc/redhat-release


Q: can I throw an exception in constructor?
A: yes, throwing an exception from the failed constructor is the standard way of doing this. See below:
http://stackoverflow.com/questions/810839/throwing-exceptions-from-constructors
http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.8

Q: switch tabs in terminal on Mac
A: cmd + {

Q: class A {operator int(){}};
A: class obj; obj.operator int(); int n = obj;



Q: Howto man c lib functions on ubuntu?
A: apt-get install manpages-dev


man 3 <function> 
eg: man 3 printf 
man -k <keyword>  - list related function
eg: man -k printf

Q: config blinking cursor on ubuntu
A: alt-f2; gconf-editor; desktop-gnome-interface-cursor_blink

Q: IB Vs UB 
A: 
IB: Implementation-defined behaviour. The standard leaves it up to the particular compiler/platform to define the precise behaviour, but requires that it be defined.
Using implementation-defined behaviour can be useful, but makes your code less portable.
UB: Undefined behaviour. The standard does not specify how a program invoking undefined behaviour should behave. Also known as "nasal demons" because theoretically it could make demons fly out of your nose.
Using undefined behaviour is nearly always a bad idea. Even if it seems to work sometimes, any change to environment, compiler or platform can randomly break your code.
Q: Some unexpected comments
A:

 We should know that in C++ source code, if compiled with GCC, "<:" means "[", ":>" means "]", "<%" means "{", "%>" means "}", "%:" means "#", "%:" means "##". If compiled with MSVC, "??=","??/","??'" means "#", "\", "^".

    Please pay attention that if you write:
int a = 1; // some comments ??/
a++;
printf("%d", a );

    Compiled with MSVC you'll get print result is "1" but not "2" as you expected. This is because the "??/" is replaced as "\", which means the comments will extend to the next line, the same as:
int a = 1; // some comments \
a++;
printf("%d", a );



No comments:

Post a Comment