2014年5月30日 星期五

Apache 允許特定網段

多個網段以空格分開
Order Allow,Deny
Allow from 192.168.16.0/24 192.168.20.0/24
 
 
 
Allow, Deny 順序 
Match      | Allow,Deny result   | Deny,Allow result
-------------------------------------------------------
Allow only | Allowed             | Allowed
Deny only  | Denied              | Denied
No match   | Default: Denied     | Default: Allowed
Match both | Final match: Denied | Final match: Allowed 
 
 
 
 
References : 
Apache httpd: How can I Deny from all, Allow from subnet, but Deny from IP within that subnet? - Server Fault

2014年5月29日 星期四

virt-manager-tui install

ImportError: No module named newt_syrup.dialogscreen

# apt-get install libslang2-dev
# apt-get install libpopt-dev 

$ git clone git://git.fedorahosted.org/git/newt

$ ./autogen.sh
$ ./configure
$ make
# make install


$ git clone git://git.fedorahosted.org/newt-syrup.git

# python setup install

No module named libuser
# sudo apt-get install python-libuser

virt-manager image directory

default path is  /var/lib/libvirt/images

you can change it in /usr/share/virt-manager/virtManager/config.py
DEFAULT_XEN_IMAGE_DIR = 'YOUR_PATH'

2014年5月24日 星期六

vim show error in quickfix windows

:cope[n] [height] Open a window to show the current list of errors. 
:cw[indow] [height] Open the quickfix window 
:ccl[ose]  Close the quickfix window 
  
 
 
 
References : 
Vim documentation: quickfix

Python hex char to decimal

>>> chr(31)
'\x0f'

>>> int('1f', 16)
31
>>> int('0x1f', 16)
31
>>> ord('\x1f')
31




References :
Convert hex string to int in Python - Stack Overflow

2014年5月19日 星期一

mplayer 載入 ass 字幕

$ mplayer -ass -subcp cp950
-ass 載入 ass 字幕
-subcp 字幕檔案編碼 

unison

# server 及 client 都要安裝 unison
# apt-get install unison

$ vi .unison/default.prf
root = /home/yan/sync
root = ssh://yan@192.168.1.1//home/yan/sync

# 如果不想要在同步過程中因unison詢問而暫停,請設定batch=true
batch = true

# 檔案衝突的處理方式,設定為auto可讓unison決定最適合的處理方式而不會暫停等候使用者決定
auto = true
$ crontab -e
*/1 * * * * /usr/bin/unison &> /dev/null




References :
Unison | chtseng

2014年5月18日 星期日

Install Jenkins Log-Term Support Release on Debian

# wget -q -O - http://pkg.jenkins-ci.org/debian-stable/jenkins-ci.org.key | apt-key add -
# vi /etc/apt/sources.list

deb http://pkg.jenkins-ci.org/debian-stable binary/
# apt-get update
# apt-get install jenkins

# netstat -antlp | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN      3973/java

http://127.0.0.1:8080/





References :
Debian Repository for Jenkins

2014年5月16日 星期五

Python 列出所有組合


>>> list(itertools.combinations(range(1, 5), 2))
[(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]

2014年5月14日 星期三

2014年5月12日 星期一

Flask get all routing rules

for rule in app.url_map.iter_rules():
    options = {}
    for arg in rule.arguments:
        options[arg] = "[{0}]".format(arg)

    methods = ','.join(rule.methods)
    url = url_for(rule.endpoint, **options) 
 
    print rule.endpoint
    print methods
    print url
 
 
 
 
References :
python - get a list of all routes defined in the app - Stack Overflow

flask url path param

request.path             /page.html
request.script_root      /myapplication
request.base_url         http://www.example.com/myapplication/page.html
request.url              http://www.example.com/myapplication/page.html?x=y
request.url_root         http://www.example.com/myapplication/
 
request.referrer
 
request.args             GET params
 
 
 
 
 
References :
python - Flask request fields to get url path - Stack Overflow