Skip to content

Instantly share code, notes, and snippets.

View erain's full-sized avatar

Yu YI erain

View GitHub Profile
@erain
erain / NFPonUbuntu.sh
Created March 23, 2012 03:05
This is a Automatic Script for setting up nginx, fast-cgi (php-fpm) and php on Ubuntu system.
# install Nginx
sudo apt-get install nginx
# install php5.3 and some php modules
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get install -y php5-cgi php5-fpm php5-mysql php5-curl php5-gd php-pear php5-imap php5-mcrypt php5-mhash php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json php5-common php-apc php5-dev
# set up Nginx
@erain
erain / tree.md
Created April 24, 2012 02:15 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@erain
erain / script.md
Last active October 6, 2015 01:07 — forked from torgeir/install_redis_on_ubuntu.md
Redis 2.4.8 Install on Ubuntu 10.04

Installation commands:

$ wget http://redis.googlecode.com/files/redis-2.6.7.tar.gz
$ tar xvfz redis-2.6.7.tar.gz 
$ cd redis-2.6.7/
$ sudo mkdir -p /opt/redis
$ sudo make PREFIX=/opt/redis install
$ sudo cp redis.conf /opt/redis/redis.conf
$ cd /opt/redis
@erain
erain / gist:3857375
Created October 9, 2012 08:34 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@erain
erain / openresty.md
Last active December 23, 2015 10:19
Install OpenResty in Ubuntu 12.04

Install OpenResty in Ubuntu 12.04

Compile Options

When we compile OpenResty, we would like to have a "good enough" version so that every plugin in our project is installed.

./configure --prefix=/opt/openresty \
--conf-path=/etc/nginx/nginx.conf \
--with-luajit \
@erain
erain / test_coroutine.py
Created December 4, 2013 09:22
An example of Coroutine in Python.
def read_producer(text, coroutines):
for word in text.split():
for coroutine in coroutines:
coroutine.send(word)
for coroutine in coroutines:
coroutine.close()
def match_filter(pattern, next_coroutine):
print("Looking for {0}".format(pattern))
@erain
erain / setup.md
Last active January 3, 2017 18:44
Software Installation

Ubuntu Basic Setup

sudo apt-get install -y vim tmux build-essential zsh python-setuptools python-dev git curl python-software-properties software-properties-common

To setup oh-my-zsh

curl -L http://install.ohmyz.sh | sh
chsh -s $(which zsh)

环境 (Environment)

版本:Ubuntu 14.04 LTS 默认语言:English(United States)

安装 (Setup)

Debian 和 Ubuntu 下对中文支持比较好的字体有: fonts-droid、ttf-wqy-zenhei 和 ttf-wqy-microhei 等,除了文泉驿系列字体外,比较流行的免费中文字体还有文鼎提供的楷体和上海宋,包名分别是: fonts-arphic-ukai 和 fonts-arphic-uming。

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

package main
import (
"net/http"
"database/sql"
"fmt"
"log"
"os"
)