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 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
different addr could be config as different fastcgi behavior. 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



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

Saturday, February 01, 2014





Thursday, January 30, 2014


ALSA could use alisa (aplay -L) to distinguish different sound card and device (aplay -l). Then each application need to decide which alisa is used to output sound. mplayer, aplay and other application could use alisa as options. But flash plugins generally only use default, see link

For HDMI audio output, first application need to know which card/device is for HDMI output and then use related alisa as output. But flashplugins in Linux could only use default as output, then it is needed to assign default to HDMI device, see Wiki in Archlinux

PCM slave is used to forward ALSA plugins to related sound card and device.

Background: there is no audio through HDMI when I connect my laptop with TV and use TV as screen for I have to follow workaround from to reset default in .asoundrc. It is caused by flash only use default for output.

Sunday, January 12, 2014


I read three manuals or tutorials for database recently: SQL, mongo and Berkeley DB. SQL is rational database which you could treat it as a bigger "excel". Berkeley DB is simply key to data database. And mongo is document database which handle special json like document.

Berkeley DB is popular database in Unix/Linux world. It is the successor for gdbm. Oracle bought Berkeley DB and developed it with more function like transaction (group command), concurrency (prevent write one record by two guys together) and SQL capacity.Since it is key-data database, it is very convinient to store contact with bdb.

Mongo is database for json like document. From my understanding, Mongo is optimized for distribution/cluster and index. It is all for big-data.

SQL is most popular database for nearly all things. In SQL, everything is organized as tables. Everything record is one row which has several values/attributions. Also you could link two tables together if they has common values/attributions. SQL is used everywhere: blog, news site, bank, schools.