Thursday, January 22, 2015

2014 Summary

无论是生活还是工作,2014年都发生了巨大的变化。

工作

2014年初正式告别做了三年之久的maintenance project,并将项目转给了一位新来的同事。之后的主要精力放在了mRBS和node 相关的事情。

生活

生活发生了巨大的变化,8月份诞生了狮子座的小宝宝。她给我们带来了很多的欢乐和幸福,但从此也失去了晚上和周末的业余时间。 11月去土耳其出差期间重新使用微信,因而和很多多年不联系的老朋友又重新取得联系。

读书

由于宝宝的缘故,2014年的读书进度很慢。看完了英文版的安娜卡列琳娜,Darwin's dangerous idea由于生僻单词的原因,只看了20%。中文方面还在看网络小说,比如魔天记,宰执天下,从前有做灵剑山,宋时归。

社交网络

2014年主要使用微博,微信和 Google+。微博仍然是主要的信息来源;微信主要用于和老朋友联系,但朋友圈的帖子质量是在不高。Google+的使用频率在下降,主要还是确实有用的信息源。 水木,twitter and Facebook的账户已经删除。reddit和豆瓣的账户还在,但活跃度基本为零。

编程

2014年python的编程能力有了很大的提高。业余时间利用webpy制作了记账网站和blogspot的镜像。在制作网站的过程中学习了html, CSS, JavaScript, rational databases和thread的知识。在工作中也开始利用python计算可靠性和处理数据。 2015年要开始抛弃webpy,并逐步转移到flask上。 2014年开始学习数据结构和haskell,但都只是很粗浅的了解,希望在新的一年中能有所突破,特别是haskell。

其它兴趣

科学方面上并无特别突出的研究和兴趣点,希望2015年能focus一两个方向。最主要的还是要多读几本英文原著。 经济方面也无所突出的兴趣点,希望2015对货币和汇率相关的课题能有所了解。 大数据和机器学习在网上很火爆,但暂时还是不要有所涉及吧,有限的精力需要放在重点项目上。

Wednesday, January 21, 2015

issue for git and werkzeug

there are two issues when I installed new server on vultr

i couldn't git clone or ssh to git on new server. It takes long time to trouble shooting and finally it is caused no home direct in /etc/passwd.

SharedDataMiddleware in werkzeug could be used to host static file, but te problem is I always get a empty png without any drawing. It also take a long time to trouble shooting and it is caused by cache parameter which is used to enable or disable caching headers. cache is enabled by default and browser always use first png it get even later one has changed.

Monday, November 17, 2014

pip proxy bug

I have a company laptop which is behind a company HTTP proxy. It takes me lots of time to study how to use proxy for pip. At beginning, I tried "pip search --proxy xxx.xxx.xx.xx:xxxx matplotlib", but it doesn't work. Then I searched internet and found there are some bugs in pip proxy, like link,NTLM proxy issue. I even tried to use privoxy to convert socket5 proxy from ssh to HTTP to fix them, but it still doesn't work.

Finally I found it actually a bug for pip, see link1 and link2. Only pip search doesn't support proxy, pip install actually support it. This bug is planned to fixed in pip 1.6.

Saturday, October 11, 2014

Nginx + fastcgi/wsgi

Python web application normally should use wsgi as interface, but nginx only support fascgi, scgi,uwsgi and no wsgi support.

flup is python library which could convert your wsgi application into fastcgi server. Since it is a library, you don't need to setup other extra standalone application. flup could hep to set up fastcgi through Unix socket domain or TCP port. It is also support scgi. webpy could use flup directly.
app = web.application(urls,locals())
if __name__ == '__main__':
#web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr) for unix socket domain
#web.wsgi.runwsgi = lambda func, addr="/tmp/test.sock": web.wsgi.runfcgi(func, addr) for Tcp port
#web.wsgi.runwsgi = lambda func, addr=("localhost",7070): web.wsgi.runfcgi(func, addr) used with spawn-fcgi
app.run()
different addr could be config as different fastcgi behavior. app.run() just simply refer to web.wsgi.runwsgi.

uwsgi needs to be isntalled if you want use wsgi + nginx. I don't see webpy could support uwsgi protocal directly.

Wednesday, October 08, 2014

https build with nginx + startssl

startssl provide free ssl certification. I have updated my website with https connection.

first step is to apply a ssl certifciation on startsll. Please notice there is no username/passwd to login startsll website instead of certification on your browser which is installed by startssl. second is to follow website to fill personal information, validation your email and produce private key. private key (ssl.key) is not stored in startsll server, but it will download to your computer. Then you need to wait for sometimes to fetch public key (ssl.crt) and retrieve it from "Retrieve Certificate" in Toolbox.

second step is to configure nginx to use ssl.key and ssl.crt, see this link for detail. You also could use this website to check if any problem

Last thing needs to notice is firewall configuration on your server. Please open 443 port and remove other un-necessory configuration rule for 443. Previously I forwarded 443 to 8080 for shadowsocks and it toke me long time to find that is root caused for my https connection failure

Tuesday, September 30, 2014

Linode VPS installation

first step is to init pacman and update system

  1. init pacman for package verification function according to link
  2. update system to latest one: pacman -Syu

next step is to add user and configure ssh

  1. add normal login user with useradd. Add user to group: wheel,log and systemctl-journal
  2. add user git with useradd
  3. update sudo with visudo
  4. add public key in .ssh/authorized_keys for git and normal login user
  5. install git and change user git shell to git-shell.
  6. test ssh public key access and git clone from local computer
  7. disable ssh root access and passwd login
  8. install sshguard

next step is to configure network,time and other system configuration

  1. configure netctl for dhcp (enable both IPv4 and IPv6) and enable this profile as startup service. (I couldn't sucess for static IP configuration) (update: change to system-networkd for statis ip)
  2. set timezone with timedatectl
  3. install ntp and enable it as startup service
  4. set up iptables rules in /etc/iptables/iptables.rules and ip6tables.rules
  5. install bash-completion

next step is to install different application

  1. install vnstat
  2. install shadowsocks
  3. install nginx, spawn-fcgi,python2-webpy,python2-flup,python2-matplotlib,python2-iso8601
  4. install python2-pip and pip2 install --upgrade google-api-python-client
  5. install my own webapplication *.service file and start app

Monday, May 12, 2014

进化的速度

昨天看了polyhedron做得汉族起源的人类分子学研究的演讲,感触很多。按照Y染色体和线粒体的分析,非洲以外的人类都是由10万年前一小支走出非洲的人类演化而来。而汉族大概是由六千年前的五至七个超级祖先繁衍而形成的。可以想像,也许几千年以后,地球上的大部分人类都是由现在地球上几个人的后代,而其余几十亿人类的基因将在慢慢的历史长河中丢失。

update1: this link has similar conclusion has社会达尔文主义如何造就了现代中国

Saturday, February 01, 2014

民众的认识和知识的专业化

过年期间总有很多机会参与家人对政治经济和社会问题的讨论,尤其是男人之间。这种问题的讨论往往天马行空:从习近平反腐,股市为何长期低迷不振到马甸的老太太白手起家挣了8套房子。每个人都对这些不同的问题有一个自己认同的答案和理解,有些问题大家有共识,而有些问题则很难达成一致。但真正的问题在于:这些共识或者不一致的认识是否正确?

百年前也许还有所谓百科全书式的学者,但现代社会则很难出现类似的人物了。随着人类知识的不断暴涨和人脑有限容量的限制,学者专家们越来越局限于自己不断缩小的一亩三分地了。新浪微博上的很多讨论可以完美的呈现这个矛盾:比如之前有人在微博上说有中科院教授在课堂上说面膜无用,而且面膜会让面部细菌大量繁殖。但很快就有医院的皮肤科大夫给予反驳,面膜对改善皮肤的确用处不大,但其中的添加剂可以有效抑制细菌繁殖。对于皮肤相关的问题,皮肤科大夫的解读往往要比生物学教授专家靠谱很多。

政治经济问题的研究很复杂,民众一方面很少有机会去浏览和阅读相关材料,更为糟糕的是有些结论的推理过程过于复杂,结论往往和直觉相反,民众也很难理解和接受。如果大家对问题的理解都是错误的,讨论还有什么意义,我们的社会还能“正确”地发展吗?