10/15/2010

如何在cmd之下大量改變檔案之副檔名

example
rename *.txt *.c

5/05/2010

vi 編輯完檔案 發現忘記按sudo編輯 之 解決方法

:w !sudo tee %

有時候沒有注意編輯檔案的權限, 等到全部編輯完才發現忘記打sudo,

我可不想跳出去再重新編輯一次, 這時候在vi 指令模式下用以上指令即可儲存.

5/04/2010

在eeebox b202, FreeBSD 8.0 release 安裝 wireless card driver

This is the process to setup eeebox's wireless driver on FreeBSD:
The eeebox's wireless chip is rt2860 made by the company - ralink.

method 1(WARNING: this method is NOT success in my trial):
convert windows driver for rt2860 to FreeBSD kernel module.

download windows version driver: rt2860.inf, rt2860.sys
put kernel module generated from ndisgen which is rt2860_sys.ko to /boot/modules
edit /boot/loader.conf add rt2860_sys_load="YES"

result -> fail -> the strange error message keep output to screen
"ndis0 if_input should not be called"

accidently find there are already a driver for rt2860 for FreeBSD 7.0 and 8.0 release
so I abandon method 1 and turn to method 2.

method 2 (SUCCESS): find the kernel module.
Surprisely, someone has write the rt2860/rt2870 driver for FreeBSD.
http://repo.or.cz/w/ralink_drivers/rt2860_fbsd8.git
use git clone links to download whole source code
make
cp rt2860.ko/ rt2860.ko.module to /boot/kernel
set rt2860_load="YES" in /boot/loader.conf
reboot system.

Loading rt2860.ko/rt2870.ko will create the hardware interface rt28600/rt28700 respectively but since version 8 of FreeBSD, these are not controlled directly for the usual settings but with a virtual interface that must created either manually like:

wlans_rt28600="wlan0"
ifconfig_wlan0="WPA DHCP"

network={
ssid="freebsdap" (ssid)
psk="freebsdmall" (password)
}
#/etc/rc.d/netif start # restart the network interface
SUCCEED!!

reference:
"FreeBSD wireless handbook" -
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-wireless.html

file path summary:
/boot/loader.conf -> setting which module to boot when starting the system.
/boot/defaults/loader.conf -> default modules to boot.
/boot/modules -> put the custom kernel modules .ko to here
/boot/kernels -> put your .ko .ko.symbols to here

快速移動游標 in console

快速移動游標 in console

ctrl+a -> 移到最前面 (= home)
ctrl+e -> 移到最後面 (= end)

4/22/2010

如何刪除幾天以前的舊檔案

指令如下

find /path/to/files* -mtime +5 -exec rm {} \;

o. /path/to/files* 是你所要刪除檔案的所在資料夾

o. -mitme 後面接的是檔案距離上次修改的時間. 如果打+5代表刪除所有五天以前的檔案

o. 最後的rm就是刪除. 如果要刪除的檔案是資料夾請加 -r.

o. 注意rm, {} , \ 之間有空格.

3/12/2010

make your own ls color

o. add this three line to your ~/.bashrc
alias ls='ls --color'
LS_COLORS='di=1:fi=0:ln=31:pi=5:so=5:bd=5:cd=5:or=31:mi=0:ex=35:*.rpm=90'
export LS_COLORS

o. parameter meaning:
di = directory
fi = file
ln = symbolic link
pi = fifo file
so = socket file
bd = block (buffered) special file
cd = character (unbuffered) special file
or = symbolic link pointing to a non-existent file (orphan)
mi = non-existent file pointed to by a symbolic link (visible when you type ls -l)
ex = file which is executable (ie. has 'x' set in permissions).
o. color number:

0 = default color
1 = bold
4 = underlined
5 = flashing text
7 = reverse field
31 = red
32 = green
33 = orange
34 = blue
35 = purple
36 = cyan
37 = grey
40 = black background
41 = red background
42 = green background
43 = orange background
44 = blue background
45 = purple background
46 = cyan background
47 = grey background
90 = dark grey
91 = light red
92 = light green
93 = yellow
94 = light blue
95 = light purple
96 = turquoise
100 = dark grey background
101 = light red background
102 = light green background
103 = yellow background
104 = light blue background
105 = light purple background
106 = turquoise background

3/04/2010

scientific method [FYI]

In the scientific method, you go through the following steps:

  1. You make observations.
  2. You develop hypotheses to explain these observations.
  3. You suggest experimental ways to test these hypotheses.
  4. You predict the results of the experiments.
  5. You run the experiments.
  6. You compare the results of your experiments to your predictions.
  7. You publish all your results.

2/24/2010

The process of Learning a "tool"

1. To know why to Learn? (motivation)
2. To Learn how to run.
3. To learn how to use it's basic functions.
4. To learn how to apply this tool to your work.
5. Practice makes perfect.
6. To understand the theory behind this tool.

2/14/2010

array pointer and pointer array

#define COLS 5 /* assume array size = 5*/
int (*xptr)[COLS];  /* this is an array's pointer */
int *xptr[COLS]; /* this is a pointer array */

function pointer example

#include
#include


void func(int);

main(){
void (*fp)(int);

fp = func;

(*fp)(1);
fp(2);

exit(EXIT_SUCCESS);
}

void
func(int arg){
printf("%d\n", arg);
}

2/12/2010

illustrate a[x] means *(a+x) equals *(x+a) equals x[a]

code:
int main(void)
{
char a[4]="123";
a[2]='x';
puts(a);
2[a]='y';
puts(a);
return 0;
}
executive result:
12x
12y

2/03/2010

[Research] List the keyword

List the keyword:

o. write a sentence about your topic

o. pull out the keywords and phrases in the sentence above and list them separately.

o. start expanding the list with related terms and synonyms.

o. Are there any larger categories that might lead you to information?

o. Are there any words or phrases that are more specific?

o. now you have a beginning list of key words and phraeses to begin searching for
information.

o. Synonyms and Related Terms
o. Larger Categories
o. Smaller Categories

2/02/2010

skype codec policy

最近想要去驗證skype的一個機制, 通常如果要驗證, 就會想要自己製造出同樣的環境來模擬skype的環境, 理想上要製造出一模一樣的環境, 這樣結果當然會是最正確, 但是既然是模擬, 就不可能一模一樣, 因為一模一樣就不叫模擬了, 叫做實現.
現在問題就是, 我到底可以做到多像, 多接近skype本身的codec policy. 首先, 我要先研究skype的機制, 目前已經初步判定他可能的機制, 接下來要製造出和實驗一模一樣的設定值, 然後套用在模擬的環境中, 在各方面設定都相同的情況下, 做出的結果理論上也應該要相似.
目前所遇到的難點在於, 不是非常確定skype codec的環境設置, 如此一來, 模擬跟實驗的結果就理當會有差異了. 我們先假設skype有按照codec的標準走, 而我們的模擬也要確定有按照codec標準走, 先做到這樣, 再看看結果,

1/31/2010

some ways to recover loss packet

o. FEC (forward error correction)
o. Interleaving
o. Packet Repetition
o. Interpolation

1/28/2010

memset 問題

Function: void * memset ( void * ptr, int value, size_t num );

Today, when I use memset function to initialize a buffer to "0" , I found that the number of byte must to the actually byte of the buffer+1..

However, The third variable of memset is Number of bytes to be set to the value.

Still don't know the reason of this

1/17/2010

如何在codeblocks設定連結winsock library

exec codeblocks

Settings > Compiler and Debugger > Linker Settings > Add >

Go to CodeBlocks Folder (normally C:\Program Files\CodeBlocks)

then MingW then libs and find libws2_32.a and add it.

1/10/2010

what is analysis exactly?

Analysis is the process of breaking a complex topic or substance into smaller parts to gain a better understanding of it.
(from wikipedia)

1/08/2010

製作強制關機捷徑 on windows

1. 在桌面按右鍵->新增->捷徑
2. 在輸入項目的位置處 輸入 shutdown -s -t 50 -c "shutdown message"意思是系統會在50秒內強制關機
3. 按下一步完成
4. 點選剛剛新增好的捷徑測試

warning: 請先存檔尚未儲存的檔案

1/07/2010

very humorous R example code

fun <- function() {
ANSWER <- readline("Are you a satisfied R user? ")
if (substr(ANSWER, 1, 1) == "n")
cat("This is impossible. YOU LIED!\n")
else
cat("I knew it.\n")
}
fun()

1/06/2010

[LOOP] loop problem

問題:
mac address 衝突 產生 loop message - loop(1) xx.xx.xx.xx.xx.xx to ex1 from ex0. (active)

解決過程:
先看到錯誤訊息, 把訊息中ip mac 傳送的source and destination 畫出來.

發現從不同網卡傳送的封包具有相同的mac address. 結果發現ap 與我的電腦的mac address竟然一樣.

就發現當初在設定ap的時候有個功能是複製你的PC的mac address. 這個功能可能是為了方便填寫mac.

然後你自己要在修改mac address. 不知道為什麼ap 沒有自己預設的mac address而要自己設置.