Add dropbox cli as a daemon on ArchLinux

Dropbox can be used as a free cloud backup solution but in order to do so, dropbox has to be added as a service/daemon, simply save the following script as dropboxd in /etc/rc.d/

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

USER=YOUR_USER_NAME
DROPBOXD=/home/$USER/.dropbox-dist/dropboxd
PID=$(pidof -o %PPID $DROPBOXD)
case "$1" in
  start)
    stat_busy "Starting dropboxd"
    [ -z "$PID" ] && sudo -u $USER $DROPBOXD &
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon dropboxd
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping dropboxd"
    [ ! -z "$PID" ]  && kill $PID &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon dropboxd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0

Now add dropboxd to the daemon list in /etc/rc.conf and voila!

Changed hosting

Finally, I have my own VPS on linode now! Yeehoo~
Since moved to linode, the website is responding noticeably slower and this is the only drawback I’ve noticed so far.
But who visit here anyways. icon biggrin Changed hosting

春・桜

Accidentally saw this cherry tree full of blossoms on the metro, I couldn’t help but got off the metro right away and took this picture with my iphone, so please pretend that you don’t notice the poor quality :p

IMG 0052 337x450 春・桜

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