2011年6月30日 星期四

C++ warm up

1. private/protected/public
Protected 的成員可被後代存取, private不行

2. friend
朋友可以存取朋友的所有member

3. virtual function (有點類似interface??)
若為virtual function, 在base型別被呼叫時, 搜尋順序為 derived > based
若非virtual function, 在base型別被呼叫時, 只會搜尋based.
若非virtual function, 在derived型別被呼叫時, 搜尋順序為 derived > based

4. virtual inheritance
多重繼承發生時, 若有相同的基底時, virtual的基底只會生出一份.
e.g. B繼承A, C也繼承A, D同時多重繼承B和C, 若A非虛擬則會生出兩份A, 建構子被呼叫兩次, 若為虛擬則只會生出一份A, 建構子只被呼叫一次.

class A{
public:
int AA;
}

class B: public class A{
public:
int BB;
}

class C: public class A{
public:
int CC;
}

class D: public B, C {
public:
int DD;
}



A---->B---+
|--->D
A---->C---+

+->B---+
A--| |--->D
+->C---+


5. const
const變數繼承時只有一份, 不能更改值.
const函式只能acess const變數.

2011年6月8日 星期三

Waited to be read.

  • Thread Local Variable
http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Thread-Local.html
  • Linux Kernel Thread
http://linux.sheup.com/linux/linux7553.htm
  • Kernel Boot
http://adrianhuang.blogspot.com/2009/12/introduction-to-linux-kernel-booting.html
http://duartes.org/gustavo/blog/post/kernel-boot-process
  • DRAM
http://www.embeddedlinuxprimer.com/dram_basics

Nexus S recovery menu

1. Power off
2. Press PWR+VOL UP
3. Select Recovery. Use VOL UP/DOWN to move cursor and PWR to select.
4. You will see ! and Android Robot
5. Following step 4, press PWR for a while and then press VOL UP without releasing PWR.
6. After Step 5, recovery menu pops up.
Ref. Manually update your Nexus S or Nexus One to the latest OTA update

2011年3月10日 星期四

Paste Code Block

Ref: formatmysourcecode

<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>Code... Code... Code...

</code></pre>

2011年3月9日 星期三

Folder Color When ls

1. Linux use the shell variable, LS_COLORS to set the colors when you `ls`.
2. A program dircolors is designed to help users set the variable LS_COLORS elegantly. According to the man page, the syntax of dircolors is as following.
dircolors [option] ... [file]
The file is a configuration specifying the output colors. Dircolors parse the file and output the corresponding statements used in shell scripts. Here is an example output for bash shell.
littletake@littletake-desktop [~] [16:26] dircolors -b .dircolors
LS_COLORS='rs=0:di=01;36:ln=01;36;44:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:
cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:
ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:
*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:
*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:
*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:
*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:
*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:
*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:
*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:
*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:
*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:
*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:
*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:';
export LS_COLORS
3. What should I do? First of all, generate the output file by the following command and modify .dircolors to fit my need. It is simple if you take some time to read the comments in .dircolors.
littletake@littletake-desktop [~] [16:45] dircolors -p > .dircolors
4. Add the following lines, that can be found in /etc/skel/.bashrc, to your .bashrc
#
# Directory Colors (.dircolors can be created by dircolors -p > ./.dircolors)
#
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
fi

2011年3月8日 星期二

Debian Linux Chinese Xwindow


1. Debian GNU/Linux 中文桌面環境 快速入門指南
2. 在 GNU/Linux 上設定字型 (上)
3. 在 GNU/Linux 上設定字型 (中) - 安裝與設定 X11 字型
4. 在 GNU/Linux 上設定字型 (下) - 安裝與設定 Xft

sudoer

Quick note here.

The fundamental entries of /etc/sudoers is as follwoing.
USER TRUSTED_HOST: (RUN_AS_USER) COMMANDS.
  • USER indicates a list the names on which the rule applies.
  • TRUSTED_HOST is typically a list of networks or IPs, i.e. 192.168.1.0/255.255.555.0. When USER login from the trusted network or IP, USER can execute COMMANDS.
  • RUN_AS_USER is a list of user. In this way, USER can execute COMMANDS as one of user in the list
  • COMMANDS is a list of commands the USER is allowed to run.
To sum up, the entry means USER can can COMMANDS from TRUSTED_HOST as RUN_AS_USER.