標籤

C++ (12) Linux (6) MacOSX (4) Makefile (3) Matlab (3) Ubuntu (3) Android (2) C (1) Refactoring (1)

2011年10月30日 星期日

[Ubuntu] Terminal裡長長的路徑

修改 ~/.bashrc
找到裡面的這行:PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
把最後面的小寫w改成大寫的W

小寫w是 絕對路徑
大寫W是 當前目錄

更改後重開Terminal就OK了

2011年10月29日 星期六

[HTK] Compile & Build

環境:Ubuntu 11.04 (64 bits)

下載HTK解壓縮後

一定會遇到一堆error
因為缺了一堆lib沒安裝

64 bits下


sudo apt-get install build-essential libc6-i386 libc6-dev-i386 xorg-dev libx11-xcb-dev ia32-libs



2011年10月27日 星期四

[C++] Forward Declaration and Definition

如果要給函式default argument或是在class 的 constructor 進入函式前就先初始化data member
都只要加在Definition的地方就好(Implementation)
不需要在forward declaration補上
如下:

class A {
public:
    A(int a = 10): _a(a) {}
private:
    int _a;
};

可以拆開成

// File: *.h

class A {
public:
    A(int a);
private:
    int _a;
};

// File: *.cpp
A::A(int a = 10): _a(a) {
    // TODO
}

2011年10月20日 星期四

[Signal Processing] Spectral Density Estimation

開wiki看到的

估計的方法有兩種
1) Parametric Approach
2) Non-Parametric Approach

其中parametric 比較有趣
"assume that the underlying stationary stochastic process has a certain structure which can be described using a small number of parameters"
就是假設random process背後其實有一些結構與機制
想辦法去找出那些parameter來理解random process的產生方式與原因
進一步估計Spectral Density Estimation

不知道這樣理解對不對??

2011年10月14日 星期五


cd r8168-8.025.00/
sudo rmmod r8169
sudo mv /lib/modules/`uname -r`/kernel/drivers/net/r8169.ko ~/r8169.ko.backup
make clean modules
sudo make install
sudo depmod -a
sudo insmod ./src/r8168.ko
sudo mv /initrd.img ~/initrd.img.backup
sudo mkinitramfs -o /boot/initrd.img-`uname -r` `uname -r`
sudo echo "r8168" >> sudo /etc/modules
lspci -v
sudo reboot

2011年10月13日 星期四

[C++] 用fstream , string , substr, find來讀檔

每次遇到要用fstream讀檔案時
都覺得很麻煩
尤其是string的find和substr
每次Google每次忘記
所以這次要把它記下來!!

fstream query_file;
query_file.open("OOVquery.syl.txt", fstream::in);

while(!query_file.eof()) {

    char buffer[256];
    query_file.getline(buffer, 256);
    string eachLine = string(buffer);
    text.append(" ");

    int pos = 0;
    int pos2 = 0;

    while((pos2 = text.find(" ", pos)) != string::npos) {
        string subsyl = text.substr(pos, pos2 - pos);

        //這裡記得要+1,不然會一直找到第一個" "
        pos = pos2+1;         
    }
}

2011年10月12日 星期三

[Linux] Asrock Z68 Pro3 主機板網路卡很慢的問題

如果你是用華擎Z68系列的主機板
而且有灌完Ubuntu 11.04之後
網路慢到爆炸的問題
(連檢查更新套件只有1Byte都要好多秒...)

可以用以下的方法修復網路問題
(筆者試過已成功解決)

『轉載自Ubuntu 11.04 Network speed fix for Z68 boards
(把r8169換成新版的r8168)

1. 先按下Ctrl + Alt + t 進入Terminal(終端機)
2. 輸入ifconfig指令,檢查網路是否有大量dropped package的問題(如下所示)

RX packets:98254 errors:0 dropped:98254 overruns:0 frame:98254
TX packets:72648 errors:0 dropped:113 overruns:0 carrier:0



3. 如果有,請打 wget http://www.foxhop.net/attachment/r8168-8.023.00.tar.bz2 來下載新的驅動程式。

4. 一樣繼續在Terminal輸入 tar jxvf r8168-8.023.00.tar.bz2

5. 安裝前,先檢查是不是有個內建的驅動程式已經在執行(有問題的那個)

    lsmod | grep r8169

6. 如果打完上述指令後,有任何output跳出,代表有在執行(所以要先關掉)。這會暫時關閉網卡。

    sudo rmmod r8169
    (如果有詢問密碼,那就打入自己的使用者密碼吧! )

7. cd r8168-8.023.00

8. sudo ./autorun.sh

9. echo "blacklist r8169" >> /etc/modprobe.d/blacklist.conf

10. 確定新的驅動程式r8168有成功安裝並執行

    lsmod | grep r8168

這樣就大功告成囉!!

[Linux] SSH , SSHD & SSH Tunnel

前幾天剛入手一台i7-2600
想說灌個ubuntu linux server 版
這樣就可以用MBA遠端回linux
出門在外都不用擔心效能不足的問題

所以看了一下ssh、sshd、ssh tunnel等等文章

2011年10月11日 星期二

[Makefile] Implicit Rules

寫Makefile時最容易忘記的就是以下這些自動變數:

$@   代表Target
$?    代表該規則的所有dependencies
$<   代表該規則的第1個dependency
$^    代表整個Makefile中的所有dependencies(感覺不常用)

還有pattern variable,例如:
%.o %.c ...

用法大概如下

default: a.o b.o c.o
        g++ -o outputFile $?                # $? 就是 a.o b.o c.o

%.o: %.cpp %.h
        g++ -c $< [-o $@]                    # $< 就是 %.cpp,$@是%.o(可寫可不寫,因為default 生成的檔案就會根據%.cpp來命名)

意思就是說
當用g++編譯產生outputFile時
會先去檢查a.o b.o和c.o存不存在或是有沒有被動過
對於每個.o檔
makefile會自動去找到%.o: %.cpp %.h這條rule
所以剛剛檢查的動作
就會變成分別檢查 a.cpp a.h、b.cpp b.h和c.cpp c.h
如果相對應的檔案有被更動過的話
則.o檔則會被重新編譯
等到a.o b.o c.o都被檢查過(或被重新編譯過後)
就輪到 g++ -o outputFile $? 了

[Linux] Tar

記下來免得每次都要查...

解tar.gz和tar.bz2時

tar zxvf XXX.tar.gz
tar jxvf YYY.tar.bz2

.gz 用z / .bz2 用j
x 是 解壓縮 extract
v 是 文字顯示解壓縮過程(verbal)
f 後面接檔案名稱(file)

2011年10月10日 星期一

[Retrieval] Keywords

把最近survey到的某篇paper中
不懂的關鍵字都記下來...

ASR (Automatic Speech Recognition)
SDR (Spoken Document Retrieval)
Speech Recognition Lattice
OOV (Out-of-vocabulary)
Precision - Recall Rate
F-measure
MAP (Mean Average Precision)
R-precision
precision-at-N
OOV rate
query-OOV rate
WER (Word Error Rate)
lattice-WER
STD (Spoken Term Detection)
ATWV (Actual Term-Weighted Value)
Word-Spotting Measure

[Retrieval] Precision - Recall & F-measure

最近survey到一篇有關document retrieval的文章
講到Precision和Recall

Precision = GoldenFind / AllFind
Recall      = GoldenFind / Target

簡單來說:

2011年10月6日 星期四

[Steve Jobs]


雖然我不是賈迷
但Jobs確實改變了整個世界

會幫他開了一個標題
是希望也冀望所有念電機系的學弟學妹們
或許有那麼一天
你(妳)也能成為一位用智慧改變世界的人
一位能留給這世界什麼的人
謹記

[Linux] 查詢Linux主機的硬體規格(CPU + RAM)

查詢CPU規格
cat /proc/cpuinfo

RAM規格
cat /proc/meminfo

如果還想進一步查CPU夠不夠力