cat /etc/*release
cat /etc/issue
All hardware and software things including network, system, UI, maintaining tools and the information security field
12/31/2009
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"
"%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
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
(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
分割水平視窗: c-w
關閉視窗: c-w
留下目前視窗並且關閉其他視窗: c-w
於分割視窗開新檔案: c-w
切換:
切換到下方視窗: c-w
切換到上方視窗: c-w
切換到左方視窗: c-w
切換到右方視窗: c-w
切換到下一個視窗:
調整大小
調整視窗垂直大小: c-w
調整視窗水平大小: c-w
10/23/2009
10/21/2009
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
10/09/2009
忘記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
問題探討與解決
最近在研究與網路管理上遇到一些問題,也讓我體會到找到或是探討問題發生的原因比解決問題更重要,因為往後也有可以遇到相同的問題,如果沒有從前面問題學到經驗,就極有可以發生同樣的問題. 如果可以事先預防, 也不會再有同樣的問題會發生, 將使系統更加穩定運作.
所以現在想要訓練自己在遇到任何問題時,紀錄自己所做的每一步, 慢慢探討並發現問題的原因. 從前都是亂試一通問題就解決了, 但是也不知道為什麼解決了.
8/05/2009
if computer is not made for human
如果電腦或是程式不是設計被人使用,那會變成什麼樣的結果?從電影魔鬼終結者我們可以清楚的看見,其劇情重點在於電腦背叛產生敵對人類的意識,但是電影中我們卻看到天網自己本身發展的基地還有人機介面,還有機器人按介面輸入這些事,顯然是不合理的。
所以如果電腦設計不是給人用的話,也許就不用GUI,也不用人看的懂的程式語言。那可能會省去很多原本需要考量效能消耗的地方。
所以如果電腦設計不是給人用的話,也許就不用GUI,也不用人看的懂的程式語言。那可能會省去很多原本需要考量效能消耗的地方。
6/11/2009
perl: read and write data
read data from file:
open(open_file,"test.txt") or "open file error";
while()
{
chomp;
print "$_\n";
}
close(open_file);
write data to file:
open(write_file,"test.txt") or "open file error";
my $data = "the data I want to write";
print write_file "$data";
close(write_file);
open(open_file,"test.txt") or "open file error";
while(
{
chomp;
print "$_\n";
}
close(open_file);
write data to file:
open(write_file,"test.txt") or "open file error";
my $data = "the data I want to write";
print write_file "$data";
close(write_file);
6/04/2009
how to connect to android phone
今天本來想要想要讓openmoko手機可以透過連接usb上網, 結果發現想要ssh openmoko phone的時候, 顯示connection refused, 目前解決方法是改用 ./adb shell去連到手機
6/03/2009
4/08/2009
screen on freeBSD
指令:
//進入screen程式
# screen
//以下^A表示同按"Ctrl + A"鍵
# ^A c //Create,開出新的 window
# ^A n //Next,切換到下個 window
# ^A p //Previous,前一個 window
# ^A ^A //在兩個 window 間切換
# ^A w //Windows,列出已開啟的 windows 有那些
# ^A 0...9 //切換到第 0..9 個 window
# ^A t //Time,顯示目前的時間,與系統的 load
# ^A K //kill window,強制關掉目前的 window
# ^A ? //Help,顯示簡單說明
# ^A d //detach,將目前的 screen session (可能含有多個 windows) 丟到背景執行
當按了 ^A d 把 screen session detach 掉後,會回到還沒進 screen 時的狀態,此時在 screen session ?每個 window 內跑的 process (無論是前景/背景)都在繼續執行,即使 logout 也不影響。
# screen -ls //顯示所有的 screen sessions
# screen -r [keyword] //挑個 screen session 回來 (撿回來)
更多說明請參考原作者發文:
http://www.freebsd.org.hk/html/bsd/9/3/3.html
//進入screen程式
# screen
//以下^A表示同按"Ctrl + A"鍵
# ^A c //Create,開出新的 window
# ^A n //Next,切換到下個 window
# ^A p //Previous,前一個 window
# ^A ^A //在兩個 window 間切換
# ^A w //Windows,列出已開啟的 windows 有那些
# ^A 0...9 //切換到第 0..9 個 window
# ^A t //Time,顯示目前的時間,與系統的 load
# ^A K //kill window,強制關掉目前的 window
# ^A ? //Help,顯示簡單說明
# ^A d //detach,將目前的 screen session (可能含有多個 windows) 丟到背景執行
當按了 ^A d 把 screen session detach 掉後,會回到還沒進 screen 時的狀態,此時在 screen session ?每個 window 內跑的 process (無論是前景/背景)都在繼續執行,即使 logout 也不影響。
# screen -ls //顯示所有的 screen sessions
# screen -r [keyword] //挑個 screen session 回來 (撿回來)
更多說明請參考原作者發文:
http://www.freebsd.org.hk/html/bsd/9/3/3.html
4/07/2009
how to set freeBSD ls color
it's just the normal note.
not so big deal.
1. frist install gnuls:
cd /usr/ports/misc/gnuls
make all install clean
2. vi ~/.tcshrc and add the following line
alias ls 'gnuls --color=auto --show-control-chars'
3. login again and finish.
not so big deal.
1. frist install gnuls:
cd /usr/ports/misc/gnuls
make all install clean
2. vi ~/.tcshrc and add the following line
alias ls 'gnuls --color=auto --show-control-chars'
3. login again and finish.
3/28/2009
我要的是在USB上可以跑作業系統
昨天弄了好久看了很多如何製作live USB的文章,最後想想,這根本不是我要的阿!live USB是說可以讓USB drive跟 live CD一樣,但是我只是要裝作業系統在USB上阿,那不就直接安裝時硬碟選擇USB不就ok了,而且live USB還有容量限制呢。為何大家都在討論live USB。
3/27/2009
在windows下 製作 ubuntu live USB
1.download the sysinstall zip file and extract to some place.
2.insert your USB device and format to the FAT32.
3.use cmd and cd to the syslinux-3.72 directory. ex: cd C:\syslinux-3.61\win32
4.type the command: syslinux E: (E: is my usb drive location)
5.mount your ubuntu iso file.
6.copy all the file inside the dir isolinux to your USB drive.
7.goto your USB and rename files isolinux.cfg and isolinux.bin to syslinux.cfg and syslinux.bin.
8.restart your computer and set the bios to boot form USB.
9.finish.
2.insert your USB device and format to the FAT32.
3.use cmd and cd to the syslinux-3.72 directory. ex: cd C:\syslinux-3.61\win32
4.type the command: syslinux E: (E: is my usb drive location)
5.mount your ubuntu iso file.
6.copy all the file inside the dir isolinux to your USB drive.
7.goto your USB and rename files isolinux.cfg and isolinux.bin to syslinux.cfg and syslinux.bin.
8.restart your computer and set the bios to boot form USB.
9.finish.
訂閱:
文章 (Atom)