What I'm Doing

Isolation is the I in ACID, one of the 4 famous properties in database transaction.

Isolation level play a critial role in concurrent scenarios. Higher isolation level offers better gurantee of data consistency, however worse performance in concurrency.

... Read More

In golang, you can’t directly compare bool value and int value, and you can’t print bool value as digit 1 or 0 using fmt.Printf(). the best way is to convert bool variable to int.

How to do that? A most common way is to write a conversion function like this one.

... Read More

Nginx can gracefully upgrade without shutdown the existing server. Detail upgrade process can be found at the nginx document

In short,

  • Build a new nginx binary, move it to /usr/local/nginx/sbin/nginx
  • Send a USR2 signal to existing nginx process, the this process will execute new binary, the new binary will accept requests with the old one simultaneously.
  • If nothing wrong, send WINCH(optional) and QUIT signal to stop old process.

... Read More

Brief Note of Docker
27 August 2015

Installation

On linux, follow the installation guide

On OSX, install boot2docker(deprecated) or Docker Toolbox which is recommended on docker official document.

... Read More

By default, openvpn traffic only local network traffic through vpn. We can config openvpn client to route all ipv4 traffic through vpn, such as the advanced option in tunnelblick. However, some other vpn clients like zerotier, whose client is not sound enough, thus we have to route these traffic manually.

... Read More

When rename a directory which contains submodule using command git mv old new, and then check status with git status, an error will occur like

fatal: Could not chdir to ‘../../../../../lib/hiredis’: No such file or directory fatal: ‘git status –porcelain’ failed in submodule lib/hiredis

because git won’t rename the path of submodule in the configuration files automatically. Thus we must edit these configs manually.

... Read More

preparation

*.crt Client certificate

*.key Client private key

*.takey OpenVPN TLS auth key

ca.crt CA root certificate

Server ip & port

Encryption Cipher Method, AES-256-CBC etc.

Hash Algorithm, default SHA1

... Read More

One of the leecode problem quotes Roman Numberal. Out of curiosity, I query some document about Roman Numberal, wikipedia and Roman Numerals Chart

... Read More

Preparation

The installation is based on a debian jessie (server) with two network interface. eth0(192.168.100.2) connects to internet, eth1(10.10.10.2) for intranet configured for with fai server.

dhcp server

Firstly, configure fai server with a static ip, edit /etc/network/interfaces

... Read More

To improve the performance of python website under nginx, it’s better to use tcp connection rather than proxy_pass with http protocol.

nginx conf

edit /etc/nginx/site-enabled/default or add a new file in site-enabled folder

server{
    listen 80;
    server_name abc.com
    location /api {
        uwsgi_pass 127.0.0.1:3015;
        include uwsgi_params;
        access_log /var/log/api.log;
    }
}

... Read More