2014年10月9日 星期四
2014年8月5日 星期二
2014年7月19日 星期六
沒有root權限下安裝python mysql connector
mkdir ~/mysql-connector
1.
到http://dev.mysql.com/downloads/connector/python/下載platform independent的tarball
2.
python setup.py build
3.
python setup.py install --home=~/mysql-connector
4.
export PYTHONPATH=/home/user
1.
到http://dev.mysql.com/downloads/connector/python/下載platform independent的tarball
2.
python setup.py build
3.
python setup.py install --home=~/mysql-connector
4.
export PYTHONPATH=/home/user
沒有root權限下安裝igraph
Step 1. 下載igraph c core
在想安裝igraph C core的地方mkdir,例如~/igraphcore
下載http://igraph.org/nightly/get/c/igraph-0.7.1.tar.gz
./configure --prefix=~/igraphcore --disable-graphml
如果沒有disable-graphml,我們就必須安裝libxml2這個函式庫
make
make install (把編譯出的函式庫move到~/igraphcore)
(configure, setup.py要下哪些參數,可以從
./configure --help
setup.py --help得知,setup.py --help-commands有更完整的指令列表)
Step 2. 安裝python-igraph
在想安裝python-igraph的地方mkdir,例如~/igraph
http://igraph.org/nightly/get/python/python-igraph-0.7.0.tar.gz
修改setup.py裡面的LIBIGRAPH_FALLBACK_INCLUDE_DIRS和LIBIGRAPH_FALLBACK_LIBRARY_DIRS
在LIBIGRAPH_FALLBACK_INCLUDE_DIRS加上'/home/user/igraph/include/igraph'來告訴setup.py我們的C core include資料夾在哪裡 (也可以只留下'/home/user/igraphcore/include/igraph',把'/usr/include/igraph'等其他都刪掉)
在LIBIGRAPH_FALLBACK_LIBRARY_DIRS加上'/home/user/igraphcore/lib'來告訴setup.py我們的C core lib資料夾在哪裡(一樣也可以只留下'/home/user/igraphcore/lib')
python setup.py build_py (產生的東西會在build資料夾裡)
python setup.py install_lib --no-download -d ~/igraph (把東西move到~/igraph裡)
(install_lib參數是從setup.py --help-commands知道的
--no-download參數是看setup.py原始碼知道的,加上這項才不會因為偵測不到igraph c core而又重新下載編譯一次)
Step 3.
export PYTHONPATH=/home/user (把/home/user加入python的search path裡面,才能import igraph。另一個方法是在python script裡面sys.path.append('/home/user'))
export LD_LIBRARY_PATH=/home/user/igraphcore/lib (因為python-igraph會需要動態連結igraph C core library,但Linux的dynamic loader並不知道igraph C core library在哪裡,所以我們需要用LD_LIBRARY_PATH來告訴dynamic loader該library的位置)
※實際上任何套件都可以用類似上述的步驟安裝在任何一個資料夾下面,不需要root權限
在想安裝igraph C core的地方mkdir,例如~/igraphcore
下載http://igraph.org/nightly/get/c/igraph-0.7.1.tar.gz
./configure --prefix=~/igraphcore --disable-graphml
如果沒有disable-graphml,我們就必須安裝libxml2這個函式庫
make
make install (把編譯出的函式庫move到~/igraphcore)
(configure, setup.py要下哪些參數,可以從
./configure --help
setup.py --help得知,setup.py --help-commands有更完整的指令列表)
Step 2. 安裝python-igraph
在想安裝python-igraph的地方mkdir,例如~/igraph
http://igraph.org/nightly/get/python/python-igraph-0.7.0.tar.gz
修改setup.py裡面的LIBIGRAPH_FALLBACK_INCLUDE_DIRS和LIBIGRAPH_FALLBACK_LIBRARY_DIRS
在LIBIGRAPH_FALLBACK_INCLUDE_DIRS加上'/home/user/igraph/include/igraph'來告訴setup.py我們的C core include資料夾在哪裡 (也可以只留下'/home/user/igraphcore/include/igraph',把'/usr/include/igraph'等其他都刪掉)
在LIBIGRAPH_FALLBACK_LIBRARY_DIRS加上'/home/user/igraphcore/lib'來告訴setup.py我們的C core lib資料夾在哪裡(一樣也可以只留下'/home/user/igraphcore/lib')
python setup.py build_py (產生的東西會在build資料夾裡)
python setup.py install_lib --no-download -d ~/igraph (把東西move到~/igraph裡)
(install_lib參數是從setup.py --help-commands知道的
--no-download參數是看setup.py原始碼知道的,加上這項才不會因為偵測不到igraph c core而又重新下載編譯一次)
Step 3.
export PYTHONPATH=/home/user (把/home/user加入python的search path裡面,才能import igraph。另一個方法是在python script裡面sys.path.append('/home/user'))
export LD_LIBRARY_PATH=/home/user/igraphcore/lib (因為python-igraph會需要動態連結igraph C core library,但Linux的dynamic loader並不知道igraph C core library在哪裡,所以我們需要用LD_LIBRARY_PATH來告訴dynamic loader該library的位置)
※實際上任何套件都可以用類似上述的步驟安裝在任何一個資料夾下面,不需要root權限
2014年7月18日 星期五
編譯套件的一般流程
編譯套件的一般流程:
1. 先看INSTALL, README
2. 執行configure --help,看看有哪些參數和路徑可以設定。然後configure (套件要安裝在哪個路徑下都是在configure這個階段要設定,通常是以--prefix=路徑來設定)
3. 執行make
4. 執行make install
1. 先看INSTALL, README
2. 執行configure --help,看看有哪些參數和路徑可以設定。然後configure (套件要安裝在哪個路徑下都是在configure這個階段要設定,通常是以--prefix=路徑來設定)
3. 執行make
4. 執行make install
2014年5月15日 星期四
C pointers
1.
可以用組合語言的角度去看C的pointers。
2.
variable事實上就是一個記憶體位址
3.
a = b;
a是lvalue(address of a)
b是rvalue(value at address b)
翻成組語就是"把在記憶體位址b儲存的東西,寫入記憶體位址a上"
可以用組合語言的角度去看C的pointers。
2.
variable事實上就是一個記憶體位址
3.
a = b;
a是lvalue(address of a)
b是rvalue(value at address b)
翻成組語就是"把在記憶體位址b儲存的東西,寫入記憶體位址a上"
2014年4月29日 星期二
2014年4月11日 星期五
遞迴轉迴圈
http://stackoverflow.com/questions/159590/way-to-go-from-recursion-to-iteration
http://www.codeproject.com/Articles/418776/How-to-replace-recursive-functions-using-stack-and
在google找關鍵字「recursive to iterative」也可以找到不少資料
http://www.codeproject.com/Articles/418776/How-to-replace-recursive-functions-using-stack-and
在google找關鍵字「recursive to iterative」也可以找到不少資料
2014年1月30日 星期四
1.
http://marc-abramowitz.com/archives/2011/12/14/vim-screen-corruption-with-screentmux-and-matchparen-vim/
Vim在UTF8 screen下,刪除字母的時候視窗會產生如亂碼般的錯誤,是由matchparen plugin導致的
關閉matchparen plugin的方法就是在.vimrc加入底下這行:
let loaded_matchparen = 1
2.
http://www.adp-gmbh.ch/vim/let_vs_set.html
vim的set和let的差別:
:set guifont=Lucida_Console:h9:cANSI
:let &guifont="Lucida_Console:h9:cANSI"
以上兩行等價
http://marc-abramowitz.com/archives/2011/12/14/vim-screen-corruption-with-screentmux-and-matchparen-vim/
Vim在UTF8 screen下,刪除字母的時候視窗會產生如亂碼般的錯誤,是由matchparen plugin導致的
關閉matchparen plugin的方法就是在.vimrc加入底下這行:
let loaded_matchparen = 1
2.
http://www.adp-gmbh.ch/vim/let_vs_set.html
vim的set和let的差別:
:set guifont=Lucida_Console:h9:cANSI
:let &guifont="Lucida_Console:h9:cANSI"
以上兩行等價
2014年1月23日 星期四
GNU screen
screen使用入門:
http://gnailuy.com/2011/07/23/gnu-screen%E4%BD%BF%E7%94%A8%E5%85%A5%E9%97%A8/
http://blog.longwin.com.tw/2005/11/screen_teach_for_use/
給screen下指令的方式:
bound to a key, invoked from a screenrc file, or called from the colon prompt
http://www.math.utah.edu/docs/info/screen_4.html#SEC4
screen畫面會閃爍的原因:visual bell
screen支援utf8的方法:
screen -U
(在existing session下執行這個指令沒用。This does not work when attaching to an existing session, you need to start a new session.)
http://gnailuy.com/2011/07/23/gnu-screen%E4%BD%BF%E7%94%A8%E5%85%A5%E9%97%A8/
http://blog.longwin.com.tw/2005/11/screen_teach_for_use/
給screen下指令的方式:
bound to a key, invoked from a screenrc file, or called from the colon prompt
http://www.math.utah.edu/docs/info/screen_4.html#SEC4
screen畫面會閃爍的原因:visual bell
screen支援utf8的方法:
screen -U
(在existing session下執行這個指令沒用。This does not work when attaching to an existing session, you need to start a new session.)
訂閱:
意見 (Atom)