2014年7月7日 星期一

git add empty directory

$ mkdir aaa
$ cd aaa
$ vi .gitignore
# Ignore everything in this directory
*
# Except this file
!.gitignore




References :
How do I add an empty directory to a Git repository? - Stack Overflow

2014年7月6日 星期日

Python install ldap module

Modules/errors.h:8: fatal error: lber.h: No such file or directory
# apt-get install libldap2-dev


# pip install python-ldap





References :
module - Python: can't install python-ldap - Stack Overflow

2014年7月3日 星期四

Python string to operator

import operator

ops = {
    "+": operator.add,
    "-": operator.sub,
    ">=": operator.ge,
    "<=": operator.le
}

print ops[">="](2, 1)
print ops["<="](2, 1)




References :
Python:: Turn string into operator - Stack Overflow

2014年7月1日 星期二

DDWRT update ip to freedns.afraid.org

1. 取得 token
登入後進入此頁 https://freedns.afraid.org/dynamic/,可看到管理的 records,在要更新的 record 的 Direct URL 連結按右鍵,復制連結位址,連結路徑 ? 後面的編碼即爲 token

https://freedns.afraid.org/dynamic/update.php?YOUR_TOKEN


2. 設定 DDWRT
進入  DDNS 設定頁 http://192.168.1.1:8080/DDNS.asp

DDNS Service : freedns.afraid.org
User Name : 登入 freedns.afraid.org 的帳號
Password : 登入 freedns.afraid.org 的密碼
Host Name : example.mooo.com,AbCdEfGhIJKlMnOpQrStUvWxYz=
                      ,




References :

ddclient for freedns.afraid.org

ddclient 版本需 3.8.1 以上 (支援協定:freedns)




$ wget -O ddclient-3.8.2.tar.bz2 http://downloads.sourceforge.net/project/ddclient/ddclient/ddclient-3.8.2/ddclient-3.8.2.tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fddclient%2F&ts=1404268199&use_mirror=ncu

$ tar jxf ddclient-3.8.2.tar.bz2

$ cd ddclient-3.8.2

# cp ddclient /usr/sbin/
# apt-get install libdigest-sha-perl

# mkdir /var/cache/ddclient/

# vi /etc/ddclient/ddclient.conf
use=if, if=ppp0
server=freedns.afraid.org
protocol=freedns
login=login_name
password=the_password
somedomain.mooo.com

# vi /etc/rc.local
/usr/sbin/ddclient -daemon=1 -syslog -quiet -force





FATAL: Error loading the Perl module Digest::SHA1 needed for freedns update.
FATAL: On Debian, the package libdigest-sha1-perl must be installed.


這是舊版 ddclient 的問題,debian 已移除套件 libdigest-sha1-perl,下載新版 ddclient 並安裝 libdigest-sha-perl

#734661 - ddclient: Please update to 3.8.2 - Debian Bug report logs



 
References :
Dynamic DNS clients
ddclient | Free System Administration software downloads at SourceForge.net

Lua library path

.so
/usr/local/lib/lua/5.1

.lua
/usr/local/share/lua/5.1

Gearman Python example

Basic Client and Worker | Gearman HQ | The hosted job queue management system for getting work done using Gearman.