Monthly Archives: January 2010

Posting douban saying using python / 用python發送豆瓣廣播

Finally I got sometime to work on implementing my own python script for posting douban saying, again. This time I used the library written by Leah Culver, and everything went smoothly. It’s just that I have no idea why douban chose to use a different signing algorithm(if a thing as stupid as it is can be called a algorithm) for requesting access token.

終於又有時間再一次捯鼓豆瓣. 這次在 Leah Culver 寫的 library 的基礎上, 終於把python腳本發送豆瓣廣播終於搞定了. 唯一理解不能的事就是豆瓣在獲取access token的時候用了一個莫名其妙的簽名算法(如果這種也能叫做算法的話 = =).

Click on read more to view the actual code of the script.
查看腳本內容請點擊 read more
Continue reading

iptables port forwarding for emule

Suppose you wanna have HighID and open KAD network connection for eMule on a computer in a LAN, and the gateway is running iptables. Just add the rules below to your existing iptables rules and you are done.

# this example is based on the assumption that 
# eth0 is WAN interface and eth1 is LAN interface,
# 192.168.0.2 is the ip address of a computer in LAN,
# 4262 is the tcp port for ed2k network,
# 4272 is the udp port for kad network.

-A PREROUTING -i eth0 -p tcp -m tcp --dport 4262 -j DNAT --to-destination 192.168.0.2:4262
-A PREROUTING -i eth0 -p udp -m udp --dport 4272 -j DNAT --to-destination 192.168.0.2:4272

-A FORWARD -d 192.168.0.2/32 -i eth0 -o eth1 -p tcp --dport 4262 -j ACCEPT
-A FORWARD -d 192.168.0.2/32 -i eth0 -o eth1 -p udp --dport 4272 -j ACCEPT