2014年9月15日 星期一

Python json.dumps 時含有時間物件

TypeError: datetime.datetime(2014, 9, 16, 10, 24, 26, 755110) is not JSON serializable


class DateEncoder(json.JSONEncoder):
    def default(self, obj):
        if hasattr(obj, 'isoformat'):
            return obj.isoformat()
        else:
            return str(obj)
        return json.JSONEncoder.default(self, obj)


json.dumps(my_variable, cls=DateEncoder)




References :
python - Cannot serialize datetime as JSON from Cherrypy - Stack Overflow

2014年9月13日 星期六

git list remote branches

可以列出本地與遠端的 branch 對應
$ git branch -avv 

2014年9月9日 星期二

2014年9月6日 星期六

reinstall debian package with config files

$ cd /var/cache/apt/archives
# dpkg --install --force-confmiss mysql-server-5.5_5.5.38-0ubuntu0.14.04.1_amd64.deb




References :
Linux Wisdom: Reinstall deleted or damaged files in Debian/Ubuntu

2014年9月5日 星期五

git pull remote branch

$ git checkout -b < new_branch > origin/< new_branch >
fatal: git checkout: updating paths is incompatible with switching branches/forcing
Did you intend to checkout ‘origin/‘ which can not be resolved as commit?’

$ git pull




References :
Wetware » Pull A Git Branch from Remote