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

9/30/2009

X server not reponding

今天嘗試連到gateway然後再連到其他機器, 但是想要用ssh -X ip 的時候, 圖形好像傳不回來,並且出現下列訊息
Xlib: connection to "localhost:10.0" refused by server Xlib: PuTTY X11 proxy: MIT-MAGIC-COOKIE-1 data did not match Error: Can't open display: localhost:10
目前不知道原因,正在研究中.
p.s. 如果用ssh -Y ip 就好了.

9/26/2009

server移植日記

上禮拜花了大部分的時間在移植server, 先是看了一些document, and 開始安裝並設定完成, 當然還是會遇到許多問題, 一一慢慢去解決, 以往解決的方式是把錯誤訊息拿去google一下, 看有沒有人有遇到相同的問題, 或是重看一下設定參數定義, 後來我發現, 我找問題的方向錯誤了, 因為我一直以為yp無法在client端使用sudo是因為sudoers的設定問題, 後來想想, 我account都可以在client登入阿, 密碼也可以通過, 表示資料已經分享過去了, 再想想遇到的錯誤訊息是xxx user is not in the sudoers list, 但是我sudoers裡面明明已經設定好特定群組可以使用sudo, 我就想是不是group設定問題, 因為group是管理群組的, 果然就發現, 預設yp's group file's path is not the path 我想要設定的, 發現問題後馬上修改路徑重新make. It works. 所以有遇到沒遇過的問題時, 還是要好好思考可能會發生此種情況的各種可能性, 並且要先清楚知道設定參數的定義. 並且以官方的document為準.

9/18/2009

NIS or YP server setting

今天在設定yp的server跟client的時候, 因為要改client的hostname以及ip 就想說yp一定有一個地方是設定domain yp server 的ip address or hostname吧 然後就發現有yp.conf這個檔案可以設定.

但是有的說明文件卻說會broadcast不用設定, 我就想說那我不要設定好了,等他自己broadcast,
但是後來實在是等太久了, 忍不住去設了一下, 結果一下就抓到yp data了嬤,害我等那麼久.
還想說是不是哪裡設定錯誤勒.

所以結論是要快點看到YP設定是否成功 就設定一下yp.conf吧

9/17/2009

why one server connect two ethernet port?

Today, when I was fixing the UPS problme in machine room, I saw a strange setup. There are two ethernet line connect to one server. Can any body tell me what is it for?

9/15/2009

問題探討與解決

最近在研究與網路管理上遇到一些問題,也讓我體會到找到或是探討問題發生的原因比解決問題更重要,因為往後也有可以遇到相同的問題,如果沒有從前面問題學到經驗,就極有可以發生同樣的問題. 如果可以事先預防, 也不會再有同樣的問題會發生, 將使系統更加穩定運作.

所以現在想要訓練自己在遇到任何問題時,紀錄自己所做的每一步, 慢慢探討並發現問題的原因. 從前都是亂試一通問題就解決了, 但是也不知道為什麼解決了.