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而要自己設置.

12/31/2009

如何檢視Linux系統distribution版本

cat /etc/*release
cat /etc/issue

12/30/2009

[Ruby] string format

"%.3f" % (1.0/7) # "0.143"
"%5.1f" % 345.6789 # "345.7"

"%05d" % 123 # "00123"
"%-5s" % "ID" # "ID "
"%04x" % 0xfc14 # "fc14"

"%6.2f, %05d" % [345.6789,123] # "345.68, 00123"
"%-5s: %04x" % ["ID", 0xfc14] # "ID : fc14"

12/28/2009

vi 復原跟做

in command mode, use u key to undo and Ctr-r key to redo.

[FUN]chrome 可以開幾個tab 呢?



a lot of tabs.

12/18/2009

[指令] WC - 印出文件 行數 字數 byte數

指令: wc
參數:
-c, --bytes               印出位元數
-m, --chars              印出字數 印出該文件有幾個字
-l, --lines                 印出該文件有幾行   
-L, --max-line-length 印出該文件最長的那行有幾字
-w, --words              印出單字數目
This is just a note to prevent me forgot it. :P

12/14/2009

[問題] switch 裡面放switch 時 default: 的問題

error: ‘default’ label in scope of identifier with variably modified type not containing enclosing switch statement

to be solved...

12/07/2009

解決在OS X 使用terminal遠端使用screen無法backspace的情況

In terminal program, choose preferences -> advanced;
select "Delete sends Ctrl+H"
done!

12/05/2009

About unistd.h

在unix-like的系統內, unistd.h所定義的介面大多由一些system call的函式所組成, 像是fork, pipe 以及一需 基本IO
(read, write, open, close) 等等

11/29/2009

malloc vs new

Difference between uses of new/malloc & delete/free:

(a) Operator new constructs an object (calls constructor of object), malloc does not.
(b) Operator new is an operator, malloc is a function.
© Operator new can be overloaded, malloc cannot be overloaded.
(d) Operator new throws an exception if there is not enough memory, malloc returns a NULL.
(e) Operator new[] requires to specify the number of objects to allocate, malloc requires to specify the total number of bytes to allocate.
(f) malloc() returns void *, which has to be explicitly cast to the desired type but new returns the proper type.
(g) Operator new/new[] must be matched with operator delete/delete[] to deallocate memory, malloc() must be matched with free() to deallocate memory.
(h) The new/delete couple does not have a realloc alternative that is available when malloc/free pair is used. realloc is used to resize the length of an array or a memory block dynamically.

reference:http://c.ittoolbox.com/groups/technical-functional/cpp-l/malloc-vs-new-1255507

11/14/2009

codeploy? It's hard to use it

Recently, I tried to use codeploy to upload my program to many planetlab nodes.
But seeing the setting instruction, it's too inconvenient.
There are too many parameter to set.
So I write a simple ruby script to implement this multiple upload function.

usage: ./multi-upload directly_you_want_to_upload

script:

#! /usr/bin/ruby

arr = IO.readlines("node_list")
arr.each { |x|
puts "node name:#{x.chomp}"
cmd = "scp -r #{ARGV[0]} ACCOUNT@#{x.chomp}:/home/ACCOUNT"
puts `#{cmd}`
}

See, 9 lines code can do the same thing.
Why don't use it?

10/25/2009

vim window tips

#define c-w Control + key W
對目前編輯檔案分割視窗:
分割垂直視窗: c-w
v
分割水平視窗: c-w
s
關閉視窗: c-w
q
留下目前視窗並且關閉其他視窗: c-w
o
於分割視窗開新檔案: c-w
n

切換:
切換到下方視窗: c-w
j
切換到上方視窗: c-w
k
切換到左方視窗: c-w
h
切換到右方視窗: c-w l
切換到下一個視窗:
調整大小
調整視窗垂直大小: c-w [+|-]
調整視窗水平大小: c-w [<|>]

10/21/2009

如何讓freeBSD開機就自動執行某個程式

很簡單, 寫個程式然後丟到/usr/local/etc/rc.d即可

10/16/2009

simulation vs experiment

這幾天研究遇到一個問題: 實驗和模擬跑出來的結果有個差別, 於是我就先畫出圖來比較, 重點就是我發現我跑decoder的程式是模擬用的程式, 而模擬的程式就是會故意把幾個voice frame拿掉, 於是我decode的時候, 拿實驗收到的frame file餵給他, 他可能就把它當成原始的voice frame, 然後在decode出可以聽的音效wav檔. 主要會發現的原因是我已經知道模擬的時候是把一些frame label起來 指定那些就是要loss的, 但是沒有想到這件事是在decode的時候做. 而我又把decoder模擬程式當成單純decode功能的程式, 如何證明說decoder參數設定會影響輸出wav的結果呢, 第一 看到模擬跑的script裡面只有出現decoder才會用的參數, 第二 實際用同樣的bit檔 去測試但是使用不同的模擬參數, 果然跑出來的wav效果不一樣. 目前先不管模擬loss, burst有沒有算對, 先把decode程式改成單純decode不吃任何參數. 在比較模擬與實驗的結果差異.

10/10/2009

Install mac fonts notes

1. put the font in /usr/share/fonts/fonddocument
2. # fc-cache -f -v

10/09/2009

FreeBSD is looking at you.

忘記root密碼 步驟

1. push "e"
2. push "e" on kernel option.
3. input "single"
4. push "b" on kernel option.
5. #passwd root
6. reboot