Make a Linux service auto start

linux

Steps

  1. Create a service script in /etc/init.d/ and chmod a+x for it.
  2. Test, sudo service xxxxx start
  3. At last, sudo systemctl enable xxxxx

Read more →

Migrate from wordpress to hugo

network

Why abandon wordpress

It’s too heavy to my VPS, even with cache plugin. Static page is much more faster!

Why Hugo

See official doc: http://gohugo.io/

  • Hugo is written in golang. It’s just an tiny executable binary file available for most popular operating system.
  • All pages are written in Markdown.
  • Hugo contains a super fast web server, it could monitor file changes and sync the contents in all most realtime (~200 ms for 100 pages).

Read more →

Different implemention of nested dict in Python

python

Different implemention of nested dict in Python.

Code is also available on gist

Read more →

如何编写晦涩难读的Perl代码

perl

如何编写晦涩难读的Perl代码

Read more →

DO NOT use infinality to render fonts!

linux

DO NOT use infinality to render fonts!

DO NOT use infinality to render fonts!

DO NOT use infinality to render fonts!

Read more →

在家下文件:4M ADSL+路由器+移动硬盘+迅雷远程下载+迅雷快鸟

network

需要下几百G的文件,无奈家中只有小水管电信4M ADSL,最大速度仅为540 kb/s。

购买NetGear WNDR 4300路由器,刷“明月永在”的OpenWRT固件,通过USB挂载一块1T的移动硬盘。

Read more →

Barplot with significant differences by ggplot2

r ggplot

R is so different from other languages. I spent TWO DAYS plotting this plot!

Read more →

GNU Parallel Note

efficiency linux

Introduction

GNU parallel is a shell tool for executing jobs in parallel using one or more computers.

If you use xargs and tee today you will find GNU parallel very easy to use as GNU parallel is written to have the same options as xargs. If you write loops in shell, you will find GNU parallel may be able to replace most of the loops and make them run faster by running several jobs in parallel.

GNU parallel makes sure output from the commands is the same output as you would get had you run the commands sequentially. This makes it possible to use output from GNU parallel as input for other programs.

Simple one

parallel echo {}\; cat {} ::: *.txt

Reading arguments from stdin and run

ls *.csv | parallel -j 4 wc -l

Read more →

Python multiprocessing.Pool: Difference between map, apply, map_async, apply_async

python

multiprocessing.Pool  is cool to do parallel jobs in Python. But some tutorials only take Pool.map  for example, in which they used special cases of function accepting single argument.

There are four choices to mapping jobs to process. Here are the differences:

             Multi-args   Concurrence    Blocking     Ordered-results
map          no           yes            yes          yes
apply        yes          no             yes          no
map_async    no           yes            no           yes
apply_async  yes          yes            no           no

Read more →

R note

note r

My R learning note.

last upate: 2016-04-07

Read more →