This area is my sharing area. Include some technical/believing/life experiences. Hope you can enjoy with me. God bless you. :)
2009年12月22日 星期二
httptunnel usage
A.
# ./configure --enable-debug --prefix=/usr/local/httptunnel
Afterwards, you will find the DEBUG config turn on in the config.h
# cat config.h | grep DEBUG
#define DEBUG_MODE 1
// Then you can compile the httptunnel package as usual to produce a debug-version program
# make clean all
// Test Cases as following examples
// Non-Proxy example
// In server side, listen on port 80, telnetd (port 23) is the real service
# ./hts -F localhost:23 -D 4 80
// In client side, listen on the port 23 (for user fully transparency), redirect to the server port 80 using HTTP POST as the intermediate protocol
# ./htc -F 23 -D 4 Server-IP:80
2009年12月18日 星期五
Linux Command - hostname
// hostname will print the name of the system as returned by the gethostname(2) function.
# hostname
// "-a", Display the alias name of the host (if used).
# hostname -a
// "-f", Display the FQDN (Fully Qualified Domain Name). A FQDN consists of a short host name and the DNS domain name. Unless you are using bind or NIS for host lookups you can change the FQDN and the DNS domain name (which is part of the FQDN) in the /etc/hosts file.
# hostname -f
http://www.faqs.org/docs/securing/chap9sec95.html
example /etc/hosts file:
IPAddress Hostname Alias
127.0.0.1 localhost deep.openna.com
208.164.186.1 deep.openna.com deep
208.164.186.2 mail.openna.com mail
208.164.186.3 web.openna.com web
The leftmost column is the IP address to be resolved. The next column is that host's name. Any subsequent columns are alias for that host. In the second line, for example, the IP address 208.164.186.1 is for the host deep.openna.com. Another name for deep.openna.com is deep.
2009年12月16日 星期三
Linux Command - cvs tar/rtag/branch
# cvs tag abc123
T turn/lib/TurnClient.hxx ==> mark as "T" label
T turn/lib/TurnHmac.cxx
T turn/lib/TurnHmac.hxx
T turn/lib/TurnMsg.cxx
T turn/lib/TurnMsg.hxx
T turn/lib/log.cxx
// Mark a cvs tag "abc456" on a existing cvs branch
# cvs tag -r sipBranch abc456
# cvs st -v Makefile
userName@1.2.3.4's password:
===================================================================
File: Makefile Status: Up-to-date
Working revision: 1.38
Repository revision: 1.38 /home/cvs/XXX/Makefile,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
Existing Tags:
abc456 (revision: 1.32) ==> This is produced by cvs tag
abc123 (revision: 1.38) ==> This is produced by cvs tag
sipBranch (branch: 1.32.2) ==> This is produced by cvs rtag -b
main (revision: 1.1.1.1) ==> This is produced by cvs import
vendor (branch: 1.1.1) ==> This is produced by cvs import
# cvs rtag -r branchABC -b branchABC_123 myProjectName
userName@1.2.3.4's password:
cvs rtag: warning: cannot open /home/cvs/CVSROOT/val-tags read/write: Permission denied
cvs rtag: Tagging myProjectName
cvs rtag: Tagging myProjectName/AutoTestAgent
cvs rtag: Tagging myProjectName/AutoTestAgent/AutoTestAgent
// cvs revision/branch 版號的制定邏輯請見下面分析
// 查看目前local 端skype 檔案的目前狀態,目前client 端工作版本為1.3.2.1.2.1, CVS Server 端的版本為1.3.2.1.2.1 (一樣),
目前client 端的檔案是隸屬於ID_1_6 這個branch的分支
// 另外在下面有列出目前隸屬於skype 這個檔案所有的tag name, branch name, 由這邊可知,
目前共存在有3個branch
[root@nestlin-7 l7fw]# cvs st -v ./skype
userName@1.2.3.4's password:
===================================================================
File: skype Status: Up-to-date ==> client 與server 的檔案一致
Working revision: 1.3.2.1.2.1 ==> Client 端, Working Directory revision
Repository revision: 1.3.2.1.2.1 ==> Server 端, Repository Directory revision
Sticky Tag: ABC_123 (branch: 1.3.2.1.2) ==> 目前Working Directory 的branch/revision
Sticky Date: (none)
Sticky Options: (none)
Existing Tags:
PPP_1_6 (branch: 1.5.2)
ABC_123 (branch: 1.3.2.1.2)
III_123 (branch: 1.3.2)
# cvs log ./skype
userName@1.2.3.4's password:
RCS file: /home/cvsroot/X/Y/Z/skype,v
Working file: skype
head: 1.6
branch:
locks: strict
access list:
symbolic names:
PPP_1_6: 1.5.0.2
ABC_123: 1.3.2.1.0.2
III_123: 1.3.0.2
keyword substitution: kv
total revisions: 13; selected revisions: 13
[omit]
----------------------------
revision 1.3
date: 2005/03/04 09:59:51; author: userName; state: Exp; lines: +3 -3
branches: 1.3.2; ==> 從這邊可以知道有切一個branch 1.3.2, 參考上面cvs st -v 的指令可知道,其branch name 為III_123
User Commit Descriptions
----------------------------
[omit]
revision 1.3.2.1
date: 2005/03/09 09:06:03; author: userName; state: Exp; lines: +1 -0
branches: 1.3.2.1.2; ==> 從這邊可以知道有切一個branch 1.3.2.1.2, 參考上面cvs st -v 的指令可知道,其branch name 為ABC_123
User Commit Descriptions
----------------------------
[omit]
# cvs st -v Makefile
userName@1.2.3.4's password:
===================================================================
File: Makefile Status: Up-to-date
Working revision: 1.38
Repository revision: 1.38 /home/cvs/XXXXX/Makefile,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)
Existing Tags:
branch_1_32_branch_20091216 (revision: 1.32)
tag456 (revision: 1.38)
branch_1_32 (branch: 1.32.2)
main (revision: 1.1.1.1)
vendor (branch: 1.1.1)
# cvs log Makefile | more
userName@1.2.3.4's password:
RCS file: /home/cvs/XXXXX/Makefile,v
Working file: Makefile
head: 1.38
branch:
locks: strict
access list:
symbolic names:
branch_1_32_branch_20091216: 1.32
tag456: 1.38
branch_1_32: 1.32.0.2
main: 1.1.1.1
vendor: 1.1.1
keyword substitution: kv
從上面的情況可知
原先在main trunk上面有切了一個branch III_123 (branch 1.3.2), 後來又在該branch (1.3.2) 上面又切了一個branch ABC_123(1.3.2.1.2), 這裡可以做出下面的結論
1. main trunk 的revision 是從1.1, 1.2, 1.3開始的
2. 如果從main trunk 切branch, 則branch 會變成1.X.Y (e.g. 如果從1.3切branch, 則新版號為1.3.2), 如果是從第一層branch 要切第二層branch, 則版號會是1.3.2.M.N (e.g. 譬如上面從III_123 branch 1.3.2 的子版本1.3.2.1 切出來, 版號會變成1.3.2.1.2
所以
main trunck 的revision main number 為1(1碼), main+sub revision number為1.M(2碼, 從1.1開始)
第一層branch 的revision main number 為1.M.2(3碼), main+sub revision number為1.M.2.N(4碼, 從1.M.2.1開始)
第二層branch 的revision main number 為1.M.2.N.2(5碼), main+sub revision number為1.M.2.N.2.O(6碼, 從1.M.2.N.2.1開始)
==> 結論cvs revision 奇數碼數為branch (如1.3.2), 偶數碼數為tag (如1.32), 只有偶數碼才是真正的revision number, 奇數碼只是main trunk/branch 的base而已
3. symbolic names 和 Existing Tags的關係如下
Existing Tags 表示該branch/tag是從哪一個原先的版號切出來的
Symbolic names 則是一個CVS 內部版號link mark(不確定是否正確), 碼數固定為偶數碼, 其規則如下
a. branch 將原先的Existing Tag 尾碼 .2 改成 .0.2, 例如上面branch branch_1_32 1.32.2, 其Symbolic name為1.32.0.2
b. revision 的Existing Tag 和 Symbolic 的revision完全相同
c. 上面a點所描述的情形中, 唯一會有例外的是vendor branch, 這是利用cvs import 所產生的imitial project(將既存的project import到cvs repository當中), 如下所示
cvs import -m "initial" project-name vendor main
會發現vendor 這個branch在 Existing TAG 和 Symbolic Name 上面的revision 完全相同, 而且這是一個branch, 可能這個vendor branch 對cvs而言有特別的意義?
2009年12月14日 星期一
Public STUN servers
* stun.ekiga.net (alias for stun01.sipphone.com)
* stun.fwdnet.net (no XOR_MAPPED_ADDRESS support)
* stun.ideasip.com (no XOR_MAPPED_ADDRESS support)
* stun01.sipphone.com
* stun.softjoys.com (no DNS SRV record) (no XOR_MAPPED_ADDRESS support)
* stun.voipbuster.com (no DNS SRV record) (no XOR_MAPPED_ADDRESS support)
* stun.voxgratia.org (no DNS SRV record) (no XOR_MAPPED_ADDRESS support)
* stun.xten.com
* stunserver.org see their usage policy
* stun.sipgate.net:10000
* numb.viagenie.ca (http://numb.viagenie.ca) (XOR_MAPPED_ADDRESS only with rfc3489bis magic number in transaction ID)
* stun.ipshka.com inside UA-IX zone russsian explanation at http://www.ipshka.com/main/help/hlp_stun.php
Linux Command - update password
Last password change : Dec 14, 2009
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
2009年12月10日 星期四
Linux Development - Makefile, gcc
-include $(TARGET_HOME)/.config
-include $(TARGET_HOME)/release.mak
==> while we add the prefix sign "--" in front of include statement, it means that if the include file is not exist, this statement is still ok without any error
Sample Makefile:
all: testLibiptcless1
testLibiptcless1: testLibiptcless1.c
gcc -Wall -Wunused -DNETFILTER_VERSION=\"1.2.6\" -rdynamic -o $@ $< \
/usr/local/lib/iptables.o /usr/local/lib/libiptc.a -ldl ==> We can link the other object file directly in the gcc command, remember be aware put all the linked libraries after the source code/output executed files
Sometimes we need some parameters inside the function (maybe for further usage). But that parameter is currently not used. So we can declare the attribute after the unused parameter. The attribute is declared as following usage.
#if defined(__GNUC__)
# define dlna_unused __attribute__((unused)) ==> define the dlna_unused
#else
# define dlna_unused
#endif
void
soap_device_callback( IN http_parser_t * parser dlna_unused, // we tag the dlna_unused here to quiet the gcc produce the Warning messages
IN http_message_t * request,
INOUT SOCKINFO * info )
-Wunused causes gcc to complain about unused parameters. This is often a good thing, if it makes you check twice whether you mistyped a variable name or forgot to implement something. But sometimes you really need to have a parameter which is not used, perhaps because the function needs to match a particular prototype.
gcc has a __attribute__((unused)) thing you can apply to paramters to quieten the warning. This actually means possibly unused: if you do use the parameter, gcc doesn't complain. So with unused alone, you can make errors in the opposite direction.
Linux Development - ccache
# readlink -f $(which gcc)
/usr/bin/ccache
# which gcc
/usr/lib/ccache/gcc
# ls -la /usr/lib/ccache/gcc
lrwxrwxrwx 1 root root 16 2008-02-27 01:05 /usr/lib/ccache/gcc -> ../../bin/ccache ==> Actually the gcc was link as a ccache
ccache
ccache is a compiler cache. It acts as a caching pre-processor to C/C++ compilers, using the -E compiler switch and a hash to detect when a compilation can be satisfied from cache. This often results in a 5 to 10 times speedup in common compilations.
The idea came from Erik Thiele wrote the original compilercache program as a bourne shell script. ccache is a re-implementation of Erik's idea in C with more features and better performance.
2009年12月3日 星期四
Linux Development - Cross Compilation
>> Before compile the package. We need to setup the related tools as the cross compiler toolchain tools as following.
# set | grep arm
AR=arm-linux-uclibc-ar
AS=arm-linux-uclibc-as
BUILD='-Os -mtune=arm9e -march=armv5te'
CC=arm-linux-uclibc-gcc
CROSS_TARGET=arm-linux-uclibc
CXX=arm-linux-uclibc-g++
LD=arm-linux-uclibc-ld
RANLIB=arm-linux-uclibc-ranlib
READELF=arm-linux-uclibc-readelf
STRIP=arm-linux-uclibc-strip
# ac_cv_linux_vers=2 ./configure --host=arm --build=arm-linux --prefix=/usr/local/libpcap
How to instruct the configure to build the crosscompile code version of iperf
For example of ARM device target
# ./configure --host="armeb-linux" --enable-debuginfo --prefix=/pat/prefix
Linux Service - Monitoring tools
* http://www.cacti.net/
* written in PHP
MRTG
* http://oss.oetiker.ch/mrtg/
* written in Perl
Embedded Linux - scratchbox/MontaVista
A brief summary of features:
* Scratchbox is used by Maemo development platform (Nokia 770). But it is not restricted to that use.
* Supports ARM and x86 targets (PowerPC, MIPS and CRIS targets are experimental)
* Especially Debian is supported, but Scratchbox has also been used to cross-compile eg. Slackware for ARM.
* Provides glibc and uClibc as C-library choices
* Uses either QEMU or a real target hardware to execute cross-compiled binaries (extremely useful when cross-compiling software which uses autoconf & co.)
MontaVista Linux
http://www.mvista.com/
2009年12月2日 星期三
Linux Command - source
# source script files
e.g.
# source $HOME/.bashrc
# source $HOME/.cshrc
# source crosstools-env.sh
Network Routing and IP info
http://www.dheart.net/ip/
http://ipid.shat.net/
http://www.ip-adress.com/
Show the routing info in Taiwan (from TWNIC)
http://map.twnic.net.tw/bwimages/dirFDCy2009s1m1/pageDisplayConnect.htm
Show the ip geography and your ip info
http://dir.twseo.org/ip-check.php
Linux Command - man, less
e.g.
# man -S 1 ls
Show all man pages
# man -a netstat
specified the man page to display, less is the default PAGER/BROWSER of man
# /usr/bin/less -is pure-ftpd.8
man config file
/etc/man.config
2009年12月1日 星期二
Linux Command - rdesktop
http://www.rdesktop.org/
>> install the remote desktop client
# yum install rdesktop.i386
>> connect to Windows Server
# /usr/bin/rdesktop IP:port
e.g. /usr/bin/rdesktop 1.2.3.4:5678
Linux Command - readlink
Just display the real program, not the soft link
# readlink -f $(which gcc)
/usr/bin/ccache
# readlink -f $(which tcpdump)
/usr/sbin/tcpdump
2009年11月30日 星期一
Linux Development - gcc
# /usr/bin/gcc34 --version <== use "yum install compat-gcc-34.i386" to install gcc 3.4
version gcc34 (GCC) 3.4.6 20060404 (Red Hat 3.4.6-8) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# /usr/bin/gcc-4.1.2 --version
gcc-4.1.2 (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Two different version series of gcc * gcc 3.4.X * gcc 4.1.X gcc 4.1.X provides stdc++ library. So we can use -lstdc++ as compiling parameter to compile program e.g. LFLAGS = -lstdc++ -lpthread But in gcc 3.4.X, the "stdc++" library is not yet support. So can not link the library while using gcc 3.4.X version. While compile the binutils of arm toolchain, it will generate error
[root@localhost binutils-build]# make all Configuring in libiberty configure: loading cache .././config.cache checking whether to enable maintainer-specific portions of Makefiles... no checking for makeinfo... makeinfo checking for perl... perl checking build system type... i386-pc-linux-gnu checking host system type... i386-pc-linux-gnu checking for i386-pc-linux-gnu-ar... (cached) arm-linux-uclibc-ar checking for i386-pc-linux-gnu-ranlib... (cached) arm-linux-uclibc-ranlib checking whether ln -s works... yes checking for i386-pc-linux-gnu-gcc... arm-linux-uclibc-gcc checking for C compiler default output... a.out checking whether the C compiler works... configure: error: cannot run C compiled programs.==> After the help of "google", I found that this is because I don't setup the proper g++ (version 3.4) compiler
If you meant to cross compile, use `--host'.
See `config.log' for more details.
make: *** [configure-libiberty] Error 1
Original g++ version
# /usr/bin/g++ --version
g++ (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
install g++ version 3.4
# yum install compat-gcc-34-c++.i386
Before compile the program, make sure the default cc is correct
Use either one of the following two methods
1. readlink -f $(which gcc)
2. echo $CC
Linux Command - e2fsck
指令:e2fsck
使用權限 : 超級使用者
使用方式 : e2fsck [-pacnydfvFV] [-b superblock] [-B blocksize] [-l|-L bad_blocks_file] [-C fd] device
說明 : 檢查使用 Linux ext2 檔案系統的 partition 是否正常工作
參數 :
device : 預備檢查的硬盤 partition,例如:/dev/sda1
-a : 對 partition 做檢查,若有問題便自動修復,等同 -p 的功能
-b : 設定存放 superblock 的位置
-B : 設定單位 block 的大小
-c : 檢查該partition 是否有壞軌
-C file : 將檢查的結果存到 file 中以便查看
-d : 列印 e2fsck 的 debug 結果
-f : 強制檢查
-F : 在開始檢查前,將device 的 buffer cache 清空,避免有錯誤發生
-l bad_blocks_file : 將有壞軌的block資料加到 bad_blocks_file 裡面
-L bad_blocks_file : 設定壞軌的block資料存到 bad_blocks_file 裡面,若無該檔則自動產生
-n : 將檔案系統以[唯讀]方式開啟
-p : 對 partition 做檢查,若有問題便自動修復
-v : 詳細顯示模式
-V : 顯示出目前 e2fsck 的版本
-y : 預先設定所有檢查時的問題均回答[是]
例子 :
檢查 /dev/hda5 是否正常,如果有異常便自動修復,並且設定若有問答,均回答[是] :
# e2fsck -a -y /dev/hda5
# e2fsck -c -y /dev/sda1
Notice: here the device name must have the full string, not only /dev/sda (this type of string will result fail)
注意 :
大部份使用 e2fsck 來檢查硬盤 partition 的情況時,通常都是情形特殊,因此最好先將該 partition umount,然再執行 e2fsck 來做檢查,若是要非要檢查 / 時,則請進入 single user mode 再執行。
Linux Command - useradd/userdel/groupadd/groupdel
# useradd -m -G groupname newUsername
// Delete the specified user and the data of his/her home directory
# userdel -r userName
// Add the specified group, and make it as a system group (usually group id lower than 500, often 470 by default)
# groupadd -r groupName
# cat /etc/group | grep groupName
groupName:x:470:
# modify userABC as a mail/ftp user without login ability
/usr/sbin/usermod -s /sbin/nologin userABC
userABC:x:508:508::/home/userABC:/sbin/nologin
The command to change the permission flags is "chmod". Only the owner of a file can change its permissions.
The command to change the group of a file is "chgrp". Only the owner of a file can change its group, and can only change it to a group of which he is a memberSo we need to set the user into multiple groups if we wish the user is a member of the specified group.
2009年11月29日 星期日
Linux Command - dd
This utility is ``useful for making an image copy of any media. An image copy is an exact byte-for-byte copy" [8, p. 80,].
dd [if=input-file] [of=output-file] [option]
where both input-file and output-file are optional. If omitted, input-file will default to the standard input, whereas output-file will default to the standard output.
option can be one or more of:
bs (block size): default is 512 bytes.
conv=arg... where arg is one or more of the following, separated by commas:
ascii: convert EBCDIC to ASCII.
ebcdic: convert ASCII to EBCDIC.
swab: swap every pair of bytes.
noerror: do not stop processing on detecting an error.
sync: pad every input record to (default) 512 bytes.
see your system manual for more details.
To read an older Silicon Graphics tape on a Sun, the dd command is:
dd if=/dev/tape conv=swab,noerror,sync | tar xf -
The input of dd is the file on the cartridge tape. dd converts that file by swapping every pair of bytes, and padding every record to 512 bytes (while not stopping if an error occurs). The resulting output file is fed (through the pipe) to tar, which then reads the file.
When a hyphen (-) is used instead of a file name on the tar command, the input is taken from the standard input on the extract and put to the standard ouput on the create function.
我的經驗
dd -if
My experience
複製Target image 到 target machine 的memory 中,然後利用dd 寫到 compact flash上的方法
首先第一步先將compact flash unmount下來
# umount /flash/
再來建立一個子目錄
# mkdir /tmp2
並且把/tmp2 device mount 到 /tmp2
# mount -t tmpfs /tmp2 /tmp2/
將target image 檔案下載放到新建的目錄/tmp2目錄下
# cd /tmp2
# ftp 192.168.XX.XX
get image file myImage.img
檢查系統資訊
# df
Filesystem 1k-blocks Used Available Use% Mounted on
/dev/root.old 1766 684 1082 39% /initrd
/dev/ram1 58093 35785 22308 62% /
/mnt 32768 212 32556 1% /mnt
/tmp2 254248 62788 191460 25% /tmp2
# mount
/dev/root.old on /initrd type ext2 (rw)
/dev/ram1 on / type ext2 (rw)
/proc on /proc type proc (rw)
/mnt on /mnt type tmpfs (rw)
/tmp2 on /tmp2 type tmpfs (rw)
再來檢查要將compact flash 是掛在系統的哪一個device file上,這裡是XXX-5000, compact flash 是屬於/dev/hdc這一個file
# dmesg | grep hdc
hdc: SanDisk SDCFB-64, CFA DISK drive
hdc: attached ide-disk driver.
hdc: task_no_data_intr: status=0x51 { DriveReady SeekComplete Error }
hdc: task_no_data_intr: error=0x04 { DriveStatusError }
hdc: 125440 sectors (64 MB) w/1KiB Cache, CHS=490/8/32
hdc: hdc1
hdc: hdc1
hdc: hdc1
hdc: hdc1
hdc: hdc1
hdc: hdc1
hdc: hdc1
最後實際執行dd command bs (block size)為 512k
# dd if=myImage.img of=/dev/hdc bs=512k
122+1 records in
122+1 records out
sync 將記憶體的資料寫到flash中
# sync
# sync
# sync
Suggestions & Advices for Christians
Suggestions & Advices for Christians
1.下次如果覺得自己了不起時,試試行在水上。
2.當魔鬼提起你的過去時,請提醒牠的未來。
3.你不是幸運,是蒙福。
4.若想要真正活著,得先徹底死去。
5.機會也許只敲一次門,但試探與誘惑卻總是在按門鈴。
6.我們常在強壯時,忘了 神。
7.那些只在星期天呼喚"天父"的人,在一星期餘下的日子中活得像孤兒。
8.不要以自我為中心,要以基督為中心。
9..沒有基督,沒有平安;認識基督,得到平安。
10.為什麼我們不常向朋友提起神?因為我們不常向 神提起我們的朋友。
11.當把你的一切獻給基督,因為他把他的一切都給了你。
12.你現在所追求的,值得基督為它死嗎?
13.使你向 神靠近的人,是你真正的朋友。
14.神愛我們,不是因為我們是怎樣一個人,而是因為他是怎樣一位神。
15.神的應許像夜空中的星星。夜越深,星星的光芒越亮。
16.沒有基督的生命,是無望的盡頭。有基督的生命,是無盡的盼望。
17.我雖不知道未來掌管著什麼,但我知道誰掌管著未來。
18.把你的重擔交給主,讓它留在主那裡。
19.不要畏懼明天,因為神已在那裡。
20.當你除了 神,一無所有時,你將知道神就是你全部的需要。
21.放手交給神,別再向神講述你的風暴有多大,當向風暴講述你的神有多大。
22.能夠滿足人心的,是造人心的那一位。
23.請常常保持著你心中的光,因為你不知道,誰會藉著這光走出黑暗。
24.當我們只顧工作的時候,我們獨自工作;當我們祈禱的時候,神工作。
25.神無所不在,所以我們可以隨處禱告。
26.一個沒有需要的人永遠見不到神蹟。
27.敬拜提醒我們生命的價值,但世界卻使我們忘記它。
28.步履艱難的時候,別一味的禱告,卻不邁向神要你走的路。
29.禱告會為我們作很多事,憂慮同樣可以。
30.神祝福你,是要你成為別人的祝福。
2009年11月19日 星期四
TCP segmentation offload (TSO)
This is a technology that shift the data segmentation effort from CPU to NIC-CPU. So the checksum will also generated by the NIC-CPU.
In Linux OS, we can disable this function by issue the following command:
# ethtool -K eth0 tso off
show all the offload information for a specified interface
# ethtool -k eth0
Large segment offload
http://en.wikipedia.org/wiki/TCP_segmentation_offloading
In computer networking, large segment offload (LSO) is a technique for increasing outbound throughput of high-bandwidth network connections by reducing CPU overhead. It works by queuing up large buffers and letting the NIC split them into separate packets. The technique is also called TCP segmentation offload (TSO) when applied to TCP, or generic segmentation offload (GSO).
When large chunks of data are to be sent over a computer network, they need to be first broken down to smaller segments that can pass through all the network elements like routers and switches between the source and destination computers. This process is referred to as segmentation. Segmentation is often done by the TCP protocol in the host computer. Offloading this work to the network card is called TCP segmentation offload (TSO).
For example, a unit of 64KB (65,536 bytes) of data is usually segmented to 46 segments of 1448 bytes each before it is sent over the network through the network interface controller (NIC). With some intelligence in the NIC, the host CPU can hand over the 64 KB of data to the NIC in a single transmit request, the NIC can break that data down into smaller segments of 1448 bytes, add the TCP, IP, and data link layer protocol headers -- according to a template provided by the host's TCP/IP stack -- to each segment, and send the resulting frames over the network. This significantly reduces the work done by the CPU. Many new NICs on the market today support TSO.
Some network cards implement TSO generically enough that it can be used for offloading fragmentation of other transport layer protocols, or by doing IP fragmentation for protocols that don't support fragmentation by themselves, such as UDP. This is not as useful, though, as other protocols aren't commonly used for transmitting large amounts of data.
TCP checksum offload (
2009年11月5日 星期四
static variable
Difference Between Static & Global Variable
6/10/2002 By ITtoolbox Popular Q&A Team for ITtoolbox as adapted from CPP-L discussion group
What is the difference between static & global variable in C++?
1) Adapted from response by Smit on Fri, 7 Jun 2002
http://Groups.ITtoolbox.com/archives/archives.asp?l=cpp-l&i=101470
Variables defined local to a function disappear at the end of the function scope. So when we call the function again, storage for variables is created and
values are reinitialized. So if we want the value to be extent throughout the life of a program, we can define the local variable as "static." Initialization is performed only at the first call and data is retained between func calls.
Had it been gloal variable, it would have been available outside the scope of the function, but static variable is not available outside the scope of a function (helpful in localizing errors - as it can't be changed outside the func
scope).
2) Adapted from response by Meraj on Fri, 7 Jun 2002
http://Groups.ITtoolbox.com/archives/archives.asp?l=cpp-l&i=101471
Static and global variable differ a lot in their behaviour to life and scope. First, let me distinguish between life and scope. Life of an object determines whether the object is still in the memory (of the process) whereas scope of the object is whether can I know the variable by its name at this position. It is possible that object is live, but not visible (not in scope) but not that object is not alive but in scope (except for dynamically allocated objects where you refer object through pointers).
Static variables are local in scope to their module in which they are defined, but life is throughout the program. Say for a static variable inside a function cannot be called from outside the function (because it's not in scope) but is alive and exists in memory. The next time this function is entered (within the same program) the same chunk of memory would be accessed now retaining the variables old value and no new memory is allocated this time for this variable like other variables in the function (automatic variables). So basically the variable persists throughout the program. Similarly if a static variable is defined in a global space (say at beginning of file) then this variable will be
accessible only in this file (file scope).
On the other hand global variables have to be defined globally, persists (life is) throughout the program, scope is also throughout the program. This means such variables can be accessed from any function, any file of the program.
So if you have a global variable and u r distributing ur files as a library and you want others to not access your global variable, you may make it static by just prefixing keyword static (of course if same variable is not required in other files of yours).
2009年11月1日 星期日
Linux Command - file
"programA": ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
# file programB
"programB": ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
32 bits program can be run on the 64 bits platform.
But 64 bits program can not run on the 32 bits platform
Add -m 32 in the CFLAG to compile a 32 bits program in the 64 bits platform for backward compatbility.
# The following target was ARM-chipset device
$ file core
core: ELF 32-bit MSB core file, ARM, version 1 (SYSV), SVR4-style, from 'programARM'
$ file programARM
programARM: ELF 32-bit MSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
# The following target was X86 PC
# file programX86
programX86: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
How to completely remove ActiveX from WindowsXP
2. Remove all the already downloaded ActiveX from the "C:\Windows\Downloaded Program Files" folder
(include strange number objects)
3. Re-Enable the selected ActiveX
2009年10月30日 星期五
Linux init script
/etc/rc.d/rc0.d
/etc/rc.d/rc1.d
/etc/rc.d/rc2.d
/etc/rc.d/rc3.d
/etc/rc.d/rc4.d
/etc/rc.d/rc5.d
/etc/rc.d/rc6.d
We can put soft-link between the above folders to link to the real script under the /etc/rc.d/init.d/
2009年10月22日 星期四
Windows XP - Fix various woes
I ever happen an urgent error in my NB (Microsoft Windows XP). The message was as bellow
STOP: c000015 Hard Error
Hard Error
Finally I fix this problem use the following procedures.
1. Reboot the NB and use M.S. Windows XP CD to boot the system.
2. Important: Don't select the Repair the Windows at the beginning. Select the "Setup Windows" first.
3. Press F8 to allow the Windows License
4. Select the "Repair Windows"
Q2. Add Environment Variable Path into Windows XP system. The procedure can refer the following diagram
2009年10月20日 星期二
WANem Tips
1. First, connect to the WANem config page, e.g. http://172.16.0.252/WANem/
2. Configure the following parameters, include
Delay - e.g. Delay time(ms): 4, Jitter(ms): 4, Correlation(%): 5
Loss - e.g. Loss(%): 5, Correlation(%): 5
Duplication - None
Packet reordering - None
Corruption - None
Bandwidth - Choose BW "Choose the data by yourself", Other: Specify 1024 BW(Kbps)
If you choose "Other", than the bandwidth will adopt the afterwards value
3. Click "Apply settings"
4. Click "Refresh settings"
5. Click "Check current status"
Linux Command - vi with various tips
/〔pattern〕<return>
或
?〔pattern〕<return>
其中 / 表示前向搜尋,?表示背向搜尋。
我們可以用”n”來繼續同向搜尋,若用”N”,表示反向動
作,而於現在列搜尋字元,可使用下列方式:
f<char> 正向搜尋
F<char> 背向搜尋
t<char> 正向
T<char> 背向
F、f 指令表示移動游標到<char>上
T、t指令表示移動游標到<char>前
調整游標位置(重要)
z[Enter] position line with cursor at top
z. position line with cursor at middle
z- position line with cursor at
% goto matching parenthesis () {} []
vim 才有顏色 (syntax on in the $HOME/.vimrc, setting after finish install vim) 並且delete /sbin/vi ln -s /usr/local/sbin/vim /sbin/vi or set "vi" command alias
vi 並沒有顏色
安裝vi 6.3 時,需同時download 下面四個檔案(很重要,不要只有download 一個檔案,我曾經因此找了很久才發現原因)
-rw-r--r-- 1 vincent vincent 1423701 Dec 9 16:38 vim-6.3-rt1.tar.gz
-rw-r--r-- 1 vincent vincent 1132075 Dec 9 16:38 vim-6.3-rt2.tar.gz
-rw-r--r-- 1 vincent vincent 1397231 Dec 9 16:38 vim-6.3-src1.tar.gz
-rw-r--r-- 1 vincent vincent 560845 Dec 9 16:38 vim-6.3-src2.tar.gz
將四個檔案都解壓縮後
drwxr-xr-x 5 1000 1000 4096 Dec 10 11:48 vim63
再利用
1. make run configure, compile and link
2. make install installation in /usr/local
即可完成安裝
如果是安裝vim 7.2版就不用download 4個files, 只要download 1個file即可
ftp://ftp.vim.org/pub/vim/unix/
ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2
# vi --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Mar 30 2010 10:37:54)
vi search / replace regular expression
vi 不support "+" metacharacter
下面這些方法都可以work
:%s/\(--l7proto.*\)\(-j RETURN$\)/\1${IPGROUP}${SRC}${DST}\2/c
:%s/\(--l7proto[ a-z]*\)\(-j RETURN$\)/\1${IPGROUP}${SRC}${DST}\2/c
:%s/\(--l7proto \w* \)\(-j RETURN$\)/\1${IPGROUP}${SRC}${DST}\2/c
:%s/ \(${\w*}\)\(-j\)/\1 \2/c
下面這些方法不work (vi 不support unicode?)
:%s/\(--l7proto[\w ]*\)\(-j RETURN$\)/\1${IPGROUP}${SRC}${DST}\2/c
:%s/\(--l7proto[\w\x20]*\)\(-j RETURN$\)/\1${IPGROUP}${SRC}${DST}\2/c
:%s/\(--l7proto\x20\w*\x20\)\(-j RETURN$\)/\1${IPGROUP}${SRC}${DST}\2/c
search / replace 從特定行數到檔案結尾
:244,$s/MSN/FASTTRACK/g
對某一特定行做字串替換
:79,79s/MSN/SOULSEEK/g
將空白行(empty line) 刪除
:g/^[ ^I]*$/d
command mode
"#" 會自動搜尋目前游標的字串, 並且把該字串標示為反白
How to copy data from vi and paste the buffer into another file
Solution1:
1. Put the cursor on the first line you want to copy out.
2. Press "ma", i.e., "m" followed by "a"
3. Go to the last line you want to copy out.
4. Press ":'a,.w filename"
In step 2, you are marking the first line you want to write out with the "a" marker. In step 4, you are selecting all the lines from the "a" marker to the current line, inclusive, and writing them out to "filename".
Solution2:
If you know the starting and ending line numbers, say 1 to 100...
:1,100w newfile
2009年10月8日 星期四
2009年10月2日 星期五
Antivirus software
http://www.eset.com.tw/
While I extended my personal SONET broadnetwork license, the SONET gave me one-year ESET (NOD32) free license. So ESET is the same as NOD32.
THE ESET program is "ESET Smart Security4"
license account:EAV-45911320
license password:6hnkre7t7x
upgrade pattern serial number web site
http://www.nod328.com/
Free antivirus software introduction
http://briian.com/?p=243
Windows XP needs to install service-pack (until 2010.12 the version is service pack 3)
『免費掃毒網址』 (Free web site to scan virus)
賣咖啡 Mcafee
http://www.mcafee.com/myapps/mfs/default.asp
熊貓 Panda
http://www.pandasoftware.com.tw/freescan/activescan.htm
Panda ActiveScan
http://www.pandasoftware.com/activescan/com/activescan_principal.htm
F-Secure Online Virus Scanner
http://support.f-secure.com/enu/home/ols.shtml
2009年9月28日 星期一
感恩再感恩 台灣晨曦會25周年 - 節錄吳獻章牧師的短講
吳獻章提到五個關鍵:(只有四個?)
1. 在別人的需要上看到自己的責任;
2. 在自己的軟弱上看到神的大能;
3. 在平凡的塵世中讓異象帶來突破;
4. 在短暫的文化中尋找永恆的舞台。
要認清自己的軟弱,40歲時的摩西覺得可以靠拳頭打倒埃及帝國,直到80歲他告白人的有限。然而摩西甘願撇棄皇宮生活,進入曠野與民同苦,便是他尋求上帝對其一生的永恆舞台。吳老師強調,「人生下半場才真正要開始,五十歲不是句號,而是逗點,將來在神手中更要成為驚嘆號。」
2009年9月22日 星期二
Linux Command - screen, change scrollback buffer
http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/
GNU Screen: Working with the Scrollback Buffer
By Chris Pettitt | March 11th, 2007
GNU Screen is a UNIX tool that allows multiple console applications to be run, each in its own “window”, from the same terminal. In a single Screen session, you can run interactive shells, mail programs, SSH sessions, and other console based applications, and you can easily switch between these using hotkeys. You can even split up the Screen display so that multiple Screen windows can be viewed at the same time.
If you’ve never used Screen, but frequently use console applications, it is definitely a tool worth exploring. An introduction to Screen can be found on the Kuro5hin website.
In this article I share my experience with one of my favorite screen features: its scrollback buffer. As you interact with a Screen window, Screen stores a configurable number of lines of history in its scrollback buffer. The scrollback buffer makes it easy to browse or even search through the history of your windows. In addition, it makes it easy to copy and paste any section of text from the history.
Configuring the Scrollback Buffer
By default, the scrollback buffer only keeps the last 100 lines of text, which is not enough for my typical interaction with Screen. I’ve found a setting of 5000 lines to be more than adequate for my usage. The number of scrollback lines can be configured in your $HOME/.screenrc file, by adding the following line:
defscrollback 5000
This sets the scrollback to 5000 lines.
You can also override this default value when starting screen using the -h [num] option, where num is the number of scrollback lines.
Finally, if you want to change the number of lines of scrollback for a single window, using the “scrollback” command. Hit C-a (Ctrl-A) : to go to the Screen command line and type "scrollback num", where num is the number of scrollback lines.
How to do it?
1. Enter scrollback command mode: Ctrl+A :
2. change scrollback buffer size: scrollback num
You can check the number of scrollback lines in your window. Hit C-a i to display window information. You will see a status line with information similar to the following:
(27,42)/(186,42)+20 +flow UTF-8 3(bash)
In this case, my scrollback is 20 lines (it is displayed as +20 in the output above).
Entering Scrollback Mode and Navigating
To enter scrollback hit C-a [. A status line will indicate that you've entered copy mode. To exit scrollback mode, hit the escape button.
Navigating in scrollback mode will be pretty familiar to VI users. Here are some of the most common navigation keys (taken from the screen manpage):
h - Move the cursor left by one character
j - Move the cursor down by one line
k - Move the cursor up by one line
l - Move the cursor right by one character
0 - Move to the beginning of the current line
$ - Move to the end of the current line.
G - Moves to the specified line
(defaults to the end of the buffer).
C-u - Scrolls a half page up.
C-b - Scrolls a full page up.
C-d - Scrolls a half page down.
C-f - Scrolls the full page down.
I often use the page up and page down commands to quickly scroll back through the window's history.
In addition to traditional navigation, Screen allows you to search the scrollback buffer using the following commands:
/ - Search forward
? - Search backward
Search is a very useful feature. For example, you could run a script and search for keywords in the output (such as Error), without having to redirect the output.
Copy and Paste
Scrollback mode is also know as copy mode and it allows you to copy any section of text into a copy buffer. To copy text, move the cursor to the start of the text you want to copy, hit spacebar, move the cursor to the end of the text you want to copy (Screen will highlight the text to be copied as you move), and again hit spacebar. Screen will indicate the number of characters copied into the copy buffer.
To paste text, simply hit C-a ].
Copying to the Mac Clipboard
While copying and pasting in a terminal is very useful, I also find that I often want to copy some text from a terminal into my clipboard. This next tip will show you how to do this for Mac OSX, but I'm sure it can be easily modified to work with other operating systems.
Open $HOME/.screenrc and add the following line:
bind b eval "writebuf" "exec sh -c 'pbcopy < /tmp/screen-exchange'"
This line tells Screen to write its copy buffer to a temporary file (defaults to /tmp/screen-exchange), and then sends that file to pbcopy, a Mac OSX utility that copies text into the Mac clipboard. In this case, I’ve bound the command to C-a b, but you can change to best suit your own environment.
Conclusion
This wraps up my review of Screen’s scrollback buffer. I hope this tutorial is useful, especially to those that frequently work in terminal windows.
Do you have interesting ways of using Screen’s scrollback buffer, or Screen in general?
* How to delete scrollback buffer?
In the window whose scrollback you want to delete, set the scrollback to zero, then return it to its normal value (in your case, 15000).
If you want, you can bind this to a key:
bind / eval "scrollback 0" "scrollback 15000"
You can issue the scrollback 0 command from the session as well, after typing C-a :.
My experience
>> Show the scrollback buffer size
C+a i
will show the buffer size in the title
2009年9月1日 星期二
Linux Command - ls
# ls -la -h /root/
show the files sorted by the date reversely
# ls -latr
2009年8月26日 星期三
Linux debug by using strace
Another point is that you can find which configure file was opened by the specified program. Does the specified program open the wrong configuration files not as you expected?
# strace ./myprog -l 1234 -d 4
execve("./tsa", ["./myprog", "-l", "1234", "-d", "4"], [/* 53 vars */]) = 0
brk(0) = 0x9adb000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=108397, ...}) = 0
mmap2(NULL, 108397, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7f7e000
close(3) = 0
open("/lib/libpthread.so.0", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 \30l\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=131528, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f7d000
mmap2(0x6bd000, 98784, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x6bd000
mmap2(0x6d2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14) = 0x6d2000
mmap2(0x6d4000, 4576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x6d4000
close(3) = 0
open("/lib/libm.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\20\344h\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=210324, ...}) = 0
mmap2(0x68b000, 163952, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x68b000
mmap2(0x6b2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26) = 0x6b2000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
2009年8月24日 星期一
讓我們一起飛吧 張茂松 2008-06-08 賽40: 27~31
基督徒有
a. 禱告的翅膀
b. 信心的翅膀
c. 屬天的翅膀 (支取上帝的祝福)
d. 屬靈的翅膀
2. 跟雞在一起, 不知道可以飛
3. 因為從來沒用過翅膀, 所以不會飛
4. 因為害怕, 所以不敢飛
5. 因為沒願景, 就隨便飛
6. 沒熱情就懶的飛
7. 因為不在靈風中, 就靠自己飛
2009年8月13日 星期四
匈牙利命名法 (For reference)
變數名稱 = 屬性+類型+描述
屬性
" g_ 全域變數
" c_ 常數
" m_ 成員變數
類型
" n/ui int/unsigned int
" l/ ul long/unsigned long
" sh/us short/unsigned short
" f float
" d double
" ld long double
" ch char
" b boolean
" p pointer
" h handle
" str String
" w/dw WORD/DWORD
" b byte/unsigned char
" bl BOOL
描述
" Custom 自訂
" Src 來源
" Dst 目的
" Tmp 暫時
Other Reference:
Prefix | Data Type | Prefix | Data Type |
c | char, TCHAR | bt | TBYTE, BYTE, |
uc | UCHAR | | |
s | short | us | USHORT |
w | WORD | n | int, INT |
u | UINT | l | LONG, long |
dw | DWORD | ul | ULONG |
fl | float | db | double |
b | BOOL | f | bitwise flag fields |
sz | ANSI string, terminated with a \0 character. | psz | PSTR |
h | HANDLE | hmem | HGLOBAL, HLOCAL |
hwnd | HWND | hfile | HFILE |
hdc | HDC | hpen | HPEN |
hfont | HFONT | hbmp | HBITMAP |
hpal | HPALETTE | hmenu | HMENU |
hicon | HICON | hinst | HINSTANCE |
hcur | HCURSOR | hbr | HBRUSH |
pt | POINT | rc | RECT |
tm | TEXTMETRIC | lf | LOGFONT |
bmp | BITMAPINFO | pal | PALETTEENTRY |
cls | WNDCLASS | msg | MSG |
rgb | RGBQUAD | clr | COLORREF |
of | OFSTRUCT | ps | PAINTSTRUCT |
cb | count of bytes | cx, cy | length in pixels |
p | added for pointer to any type, e.g., ps, pdw, phicon, pof, ..., etc. | a | added for array of any type, e.g., as, adw, auc, ... |
C | a big C in front of all C++ class names, the rest of the class name is a mix of big and small letters | m_ | added in front of all C++ class member variables. |
str | string | | |
st | structure | | |
2009年8月3日 星期一
張茂松牧師 - 打造一個精品、塑造一個達人
1. 熟記
2. 思想
3. 禱告
4. 遵行
讀聖經時, 常常問為什麼?
如何預備被祝福?(汝矣島純福音教會主任牧師趙鏞基妻子 金聖惠總長)
1. 正向思考
2. 有異象, 異夢
3. 盡力去做
4. 倚靠聖靈
2009年7月14日 星期二
Show the memory usage of specified process id
# in the following examples, the 22405 is the process id
# top -p 22405
# pmap -d 22405
show memory details
# pmap -x 22405
b5fdb000 10240 - - - rw--- [ anon ]
b69db000 4 - - - ----- [ anon ]
b69dc000 10240 - - - rw--- [ anon ]
b73dc000 4 - - - ----- [ anon ]
b73dd000 10240 - - - rw--- [ anon ]
b7ddd000 2048 - - - r---- locale-archive
b7fdd000 8 - - - rw--- [ anon ]
b7fe6000 28 - - - r--s- gconv-modules.cache
b7fed000 16 - - - rw--- [ anon ]
bf972000 268 - - - rw--- [ stack ]
anon is a large size memory? [FIXME]
2009年6月28日 星期日
xargs experience
change to the directory which the tcpreplay file was located.
# ls | awk '{print "echo filename:"$1" ; tcpdump -nv host 207.46.2.152 -r "$1}' | sh
# ls | xargs -n 1 tcpdump -nv host 207.46.2.152 -r
Disable the write permission of all the directory include the sub-directory
# find -type d | xargs chmod a-w
Delete all the files that are below the CVS directory
# find ./* -name CVS | xargs -n 1 rm -rf
Delete all the found *.la files
# find /PathTOHere/puma5_toolchain/src/buildroot-2009.02/project_build_armeb/puma5/root/lib -name '*.la' | xargs rm -rf
2009年6月22日 星期一
Signal type
e.g.
This will terminate the specified process (SIGKILL)
# kill -9 process-id
This will reload the specified process (SIGHUP)
# kill -1 process-id
The reference of the SIGNAL(7) man page
Signal Value Action Comment
-------------------------------------------------------------------------
SIGHUP 1 Term Hangup detected on controlling terminal
or death of controlling process
SIGINT 2 Term Interrupt from keyboard
SIGQUIT 3 Core Quit from keyboard
SIGILL 4 Core Illegal Instruction
SIGABRT 6 Core Abort signal from abort(3)
SIGFPE 8 Core Floating point exception
SIGKILL 9 Term Kill signal
SIGSEGV 11 Core Invalid memory reference
SIGPIPE 13 Term Broken pipe: write to pipe with no readers
SIGALRM 14 Term Timer signal from alarm(2)
SIGTERM 15 Term Termination signal
SIGUSR1 30,10,16 Term User-defined signal 1
SIGUSR2 31,12,17 Term User-defined signal 2
SIGCHLD 20,17,18 Ign Child stopped or terminated
SIGCONT 19,18,25 Cont Continue if stopped
SIGSTOP 17,19,23 Stop Stop process
SIGTSTP 18,20,24 Stop Stop typed at tty
SIGTTIN 21,21,26 Stop tty input for background process
SIGTTOU 22,22,27 Stop tty output for background process
2009年6月15日 星期一
ActiveX HowTo
Change path to the ActiveX directory, unregister DLL component by using the regsvr32 program with -u parameter
C:\WINDOWS\Downloaded Program Files>regsvr32 -u XXX.dll
C:\WINDOWS\Downloaded Program Files>regsvr32 -u XXX.ocx
After successfully unregister the ActiveX component, it will show a pop-up message that shows the following descriptions:
DllUnregisterServer at XXX.dll success.
2009年6月4日 星期四
wincvs tutorial
1. What is the first step?
A. Login to the cvs server via wincvs
Admin -> Login -> Login settings -> enable CVSROOT field, fill the string as following type
:ssh:user-name@CVS-server-address:port:cvs-folder-path
set the global settings in the Tab: Globals
Enable the following setting
Checkout text files with Unix LF (0xa)
2. How to checkout cvs modules?
A. You can use the manually isuue command (procedure 3) or simply run the following command
Remote -> Checkout modules (Must specify the module name first)
3. How to update (sync) the CVS code of working directory?
A. Admin -> Command Line -> Enter the command line
Input the submit cvs command
e.g
cvs -q up
4. How to issue other command (e.g. like checkout other branches of module..)?
A. Following the previous procedure 3 instructments, then issue the following command
cvs co -r cvs_branch module-name
AJAX - JQuery introduction
JQuery的主要功能包括 * 不同平台的browser顯示的畫面具有一致性 * 可以有AJAX 做到local端動態只有更新某一個division顯示畫面的功能
Google Map API 底層有包AJAX API
AJAX 的目的是讓Browser User unaware 去update web pages的某一些部份(some division), 不用手動去做page refresh, 底層是利用Java Script 去切割成一塊一塊的division, 然後利用event trigger的方式,當某一塊division被event trigger 需要update時, 那一塊division就會主動連到server去做page refresh
Linux Command - dos2unix, Windows Linux difference endline code
Windows / MS-Dos: [CR][LF] 0d 0a
Mac: [CR] 0d
Unix/Linux: [LF] oa
// You will find many "0x0a 0x0d" hex code pattern in the dump of windows file
# hexdump File.h.win32 | grep 0a0d
0000010 3e68 0a0d 6923 636e 756c 6564 3c20 7473
[omit]
0000220 6365 3b74 0a0d 0a0d 2a2f 202a 7546 636e
0000260 3b29 0a0d 6f76 6469 4220 6675 6566 4d72
0000280 6820 6e61 6c64 7265 3b29 0a0d 6e69 2074
// after we convert the file from windows file mode to unix file mode, we will no more see the pattern "0a0d"
# dos2unix -n File.h.unix File.h.win32
# hexdump File.h.unix | grep 0a0d
We can use dos2unix command to do the code translation, the command format is as following
# dos2unix -n Windows-text-original-file Unx-text-destinated-file
Linux System - Tuning Linux server performance before adopting the server production
Modify the system settings
sysctl -w net.core.rmem_max=8388608
sysctl -w net.core.wmem_max=8388608
sysctl -w net.ipv4.tcp_moderate_rcvbuf=1
sysctl -w net.ipv4.tcp_rmem="32768 87380 8388608"
sysctl -w net.ipv4.tcp_wmem="16384 65536 8388608"
sysctl -w net.ipv4.tcp_mem="8388608 8388608 8388608"
sysctl -w net.ipv4.tcp_syncookies=0
ulimit -n 65535
ulimit -s unlimited
ulimit -u unlimited
# increase Linux TCP buffer limits
sysctl -w net.core.rmem_max=8388608
sysctl -w net.core.wmem_max=8388608
# increase Linux autotuning TCP buffer limits
sysctl -w net.ipv4.tcp_moderate_rcvbuf=1
sysctl -w net.ipv4.tcp_rmem="32768 87380 8388608"
sysctl -w net.ipv4.tcp_wmem="16384 65536 8388608"
sysctl -w net.ipv4.tcp_mem="8388608 8388608 8388608"
# stop syn blocking
sysctl -w net.ipv4.tcp_syncookies=0
# maximum number of open file descriptors (modify the open files number per process)
# This parameter is the important factor that determine the process can open how many file descriptor / socket number.
ulimit -n 65535
How to modify the configure file to make the modification effectiveness after
reboot
Ans:
We can modify the /etc/sysctl.conf to make the new setting effective after system reboot.
In the /etc/security/limits.conf, add
* soft nofile 8192 (modify to the max value of soft)
* hard nofile 20480 (modify to the max value of hard)
After this modification, relogin and type "ulimit -a" will show the open fd size of per process
suspend some seconds in the Linux/Windows
- sleep(n), , suspend n seconds
- usleep(n), suspend n * 10(-6) seconds
Windows
- Sleep(n) , suspend n * 10(-6) second
We can also use select to suspend n seconds m 10(-6) seconds
struct timeout tv;
tv.tv_sec = n;
tv.tv_usec = m;
select(0, NULL, NULL, NULL, &tv);
Then this function will suspend n seconds m 10(-6) seconds
2009年6月3日 星期三
Some action after the network is becoming disconnected
2. Sometime the host is strange in the network connection. Try to restart the network interface (e.g. service network restart, ifdown eth0; ifup eth0...). Or we can try to restart the OS
3. Try to change to use another network line, another pc to test the network line, another switch/hub to distinguish the real point of network failure.
My experience of facing the network disconnected in the company :
Find the network root line, e.g. if the lab is network disconnected, we can test the network root line directly. Sometimes the real problem is that the foreign network device was down (e.g. switch, router) or the foreign network line/socket was not connected well causing the network unstable.
2009年5月27日 星期三
Microsoft Word Tips and Questions
如果要編排有章節的文件,使用"項目符號及編號"/清單樣式
"項目符號及編號"/編號 以及 "項目符號及編號"/大綱編號 都設定為"無"即可
Currently I have the following confused/doesn't understand well topics
標題與編號的設定
自動變數的設置
版面樣式的設置
在編寫"STP" 測試文件時,有下面的問題
選取插入->參照->標號, Enable 編號方式->包含章節編號
就會出現如上的錯誤訊息,並且插入的資料出現下面的字樣
Table 錯誤! 所指定的樣式的文字不存在文件中。
如果不勾選"編號方式->包含章節編號", 就可以插入編號
但是只會有"Table 1"的字樣,不包含標號index
其他文件似乎不會
Word Learing Site
http://www.yesgood.com.tw/contents/word2007.aspx
2009年5月21日 星期四
Java experience
A. Go to java website to download the java run time enviroment
From the website of taiwan
http://www.java.com/zh_TW/download/manual.jsp
jre-6u13-windows-i586-p-iftw.exe
jre-6u13-windows-i586-p-s.exe
from the official site
Download Java SE Runtime Environment 6u13 for Windows, Multi-language
https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewFilteredProducts-SingleVariationTypeFilter
jre-6u13-windows-i586-p.exe
Show the java version
c:\JAbin-20090520>java -versionjava
version "1.6.0_13"Java(TM) SE Runtime Environment (build 1.6.0_13-b03)Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
2009年5月12日 星期二
2009年5月7日 星期四
Network Packet handling (receiving/sending) architecture
while (ExistFlag is not set) {
sleep(very-short-term-time); /* make the CPU not too busy, So CPU can context-switch to service other tasks */
select (rfds, long term timeout); /* the CPU will busy polling all the specified rfds, so the cpu was very busy? */
if (retval of select > 0) {
recv(specified-fd);
}
} /*while*/
Sending (in a single thread/process)
while (ExistFlag is not set) {
/* No-need to sleep to speedup the response time of sending packets */
select (wfds, long term timeout); /* the CPU will busy polling all the specified rfds, so the cpu was very busy? */
if (retval of select > 0) {
send(specified-fd);
}
} /*while*/
Win32 portable program API
recv, send (Win32 doesn't support the read/write functions)
Sleep(1000) means pause 1 second (Linux use sleep(1) function call)
2009年4月22日 星期三
Microsoft Visual Studio 2008 Tips
Select Project > Project-Name-Property (Alt-F7) > Configuration Property > Debug > Command-Parameter
Input the command parameter here and it will redirect to the execution file while debugging
e.g -a 123
* How to set the definition in the preprocessor
Select Project > Project-Name-Property (Alt-F7) > Configuration Property > C/C++ > Preprocessor > Preprocessor definition
Set the definition here
WIN32;DEBUGMODE
* How to run and debuging test in the MVS
Debug F5
Run without debugging Ctrl + F5
Updated 2009/06/04
* What is the system architecture in the Microsoft Visual Studio?
A. .sln ==> Solution file
.vcproject ==> VC project file
a VC solution consists multiple VC projects
How to distinguish a Win32 AP or other form (e.g. static library or dll ..) in the MVS
A. In the Project Property page
The Default values of project
Configuration type: Application(.exe), static library
The usuage of MFC: Use the standard windows library
ATL usuage: No use ATL
Word Set: Use MultiByte Sets, Use UnicCode Sets
What is the execution file output foler path?
Win32 Application (.exe): Project Property page -> Configuration Property -> Linker -> Command line
Static library: Project Property page -> Configuration Property -> Manager -> Command line
The general settings can be found in the Linker/Manager=>General=>Output Directory
How to link the static library while tring to build a Win32 Application (.exe)?
A.
1. Set the include directory to include the header files of the static library prototype
Project Property page -> Configuration Property -> C/C++ -> other include directory -> set the header file path (Note: the path is dependency to the vc project file)
2. Set the library path and name
Project Property page -> Configuration Property -> Linker -> Input -> Other dependency -> set the library file path (Note: the library path is dependency to the vc project file)
2009年4月9日 星期四
Linux Service - NFS
Edit the config file
/etc/exports
/usr/local/src/folder *(ro,insecure)
We can use exportfs to display the current exported file folder
# exportfs -rv
Client side
# mount -t nfs IP-Address:exported-folder mount-folder
e.g.
# mount -t nfs 172.17.11.100:/usr/local/src/folder /mnt/nfs
2009年4月6日 星期一
network interface configuration
/etc/rc.conf
ifconfig_le0="inet X.X.X.X netmask 255.255.255.192"
ifconfig_le1="inet 192.168.102.254 netmask 255.255.255.0"
defaultrouter="Y.Y.Y.Y"
Ubuntu Linux (1 public NIC, 2 private NICs)
/etc/network/interfaces
auto eth2
iface eth2 inet static
address X.X.X.X
netmask 255.255.255.224
gateway X'.X'.X'.X'
auto eth3
iface eth3 inet static
address 192.168.102.254
netmask 255.255.255.0
auto eth4
iface eth4 inet static
address 172.17.11.251
netmask 255.255.0.0
How to restart the Ubuntu Linux network interface setting
# /etc/init.d/networking restart
# sudo ifconfig
2009年4月5日 星期日
How to view the ipf rules status?
Refer from http://www.freebsd.org/doc/en/books/handbook/firewalls-ipf.html
When supplied with either -i
for inbound or -o
for outbound, it will retrieve and display the appropriate list of filter rules currently installed and in use by the kernel.
ipfstat -in displays the inbound internal rules table with rule number.
ipfstat -on displays the outbound internal rules table with the rule number.
The output will look something like this:
@1 pass out on xl0 from any to any
@2 block out on dc0 from any to any
@3 pass out quick on dc0 proto tcp/udp from any to any keep state
How to view the ipf rules status?
Refer from http://www.freebsd.org/doc/en/books/handbook/firewalls-ipf.html
When supplied with either -i
for inbound or -o
for outbound, it will retrieve and display the appropriate list of filter rules currently installed and in use by the kernel.
ipfstat -in displays the inbound internal rules table with rule number.
ipfstat -on displays the outbound internal rules table with the rule number.
The output will look something like this:
@1 pass out on xl0 from any to any
@2 block out on dc0 from any to any
@3 pass out quick on dc0 proto tcp/udp from any to any keep state
How to cancel the denied IPs which was blocked by the denyhost
(e.g. /usr/share/denyhosts/data/hosts-restricted)
2009年1月15日 星期四
nonblocking socket connect to handle the conditions of TCP RST and successful established
socket call sequence:
socket ==> OK
fcntl (set nonblocking mode) > OK
connect (immediately return because the file descriptor is in the nonblocking mode) ==> OK
select write socket (verify if the write socket is available or not) ==> OK
a1. select read socket (verify if the read socket is available or not) ==> OK (if the server will first send the data to the connected client)
a2. recv (recv the data) ==> OK (if the server will first send the data to the connected client)
b1. select read socket (verify if the read socket is available or not) ==> Failed (if the server doesn't send the data to the connected client)
b2. recv (recv the data) ==> No need to call the recv because the recv socket is not ready
Connect to the server which doesn't listen data on the specific port
socket call sequence:
socket ==> OK
fcntl (set nonblocking mode) ==> OK
connect (immediately return because the file descriptor is in the nonblocking mode) ==> OK
select write socket (verify if the write socket is available or not) ==> OK
select read socket (verify if the read socket is available or not) ==> OK
recv (recv the data) ==> return -1
2009年1月14日 星期三
Library in compiler time and execution time
static library
link with *.a file
dynamic library
link with *.so file
Execution time
static library
No need to link libraries
dynamic library
link to the specific libraries files *.so.X (Can use ldd to display the real libraries)
2009年1月13日 星期二
Default linux kernel header source path
built their own kernel and ran 'make modules_install'),
/lib/modules/`uname -r`/build
Above path points to the correct kernel headers.