Skip to content

Instantly share code, notes, and snippets.

@xkou
xkou / .vimrc
Last active October 28, 2016 02:49 — forked from josephwecker/new_bashrc.sh
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful.
set nocompatible " 关闭 vi 兼容模式
syntax on " 自动语法高亮
set number " 显示行号
set ruler " 打开状态栏标尺
set shiftwidth=4 " 设定 << 和 >> 命令移动时的宽度为 4
set softtabstop=4 " 使得按退格键时可以一次删掉 4 个空格
set tabstop=4 " 设定 tab 长度为 4
set nobackup " 覆盖文件时不备份
set noexpandtab
set autoindent
@xkou
xkou / gist:8572872
Created January 23, 2014 04:33
install tengine with luagit
# git clone https://github.com/simpl/ngx_devel_kit.git
cd tengine-2.0.0/
# tell nginx's build system where to find LuaJIT 2.0:
export LUAJIT_LIB=/usr/local/lib
export LUAJIT_INC=/usr/local/include/luajit-2.0/
# Here we assume Nginx is to be installed under /opt/nginx/.
@xkou
xkou / gist:8599318
Last active January 4, 2016 08:59 — forked from creotiv/gist:1217855
gevent web server
import sys
from gevent import server
from gevent.baseserver import _tcp_listener
from gevent import pywsgi
from gevent.monkey import patch_all; patch_all()
from multiprocessing import Process, current_process, cpu_count
def hello_world(env, start_response):
if env['PATH_INFO'] == '/':
start_response('200 OK', [('Content-Type', 'text/html')])
@xkou
xkou / rt_tables
Last active September 30, 2016 05:33
_setip(){
eth=eth0
id=$1
ip link add link $eth name vlan$id address 00:aa:bb:cc:dd:0$id type macvlan
ifconfig vlan$id 10.1.1.8$id up
ip route add default dev vlan$id table tab$id
ip rule add from 10.1.1.8$id lookup tab$id
# route del -net 0.0.0.0 netmask 0.0.0.0 dev vlan$id
route del -net 1.0.0.0 netmask 255.0.0.0 dev vlan$id
@xkou
xkou / gist:8644127
Last active January 4, 2016 15:59
show ip before login for ubuntu
#!/bin/sh
if [ "$METHOD" = loopback ]; then
exit 0
fi
# Only run from ifup.
if [ "$MODE" != start ]; then
exit 0
fi
@xkou
xkou / gist:9151354
Last active August 29, 2015 13:56
sysctrl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and
# sysctl.conf(5) for more details.
# Controls IP packet forwarding
net.ipv4.ip_forward = 0
# Controls source route verification
net.ipv4.conf.default.rp_filter = 1
@xkou
xkou / squid.conf
Created March 4, 2014 15:30
squid.conf
acl all src -n all
http_port 8111 transparent
cache_dir ufs /var/cache/squid 512 16 256
access_log /tmp/1.log squid
pid_filename /tmp/8111.pid
acl breakwall dstdomain .fancyguo.com
acl breakwall dstdomain .external.out
never_direct allow all
# =============== #
# Unity generated #
# =============== #
Temp/
Library/
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
@xkou
xkou / install.sh
Last active October 28, 2016 02:41
install ubuntu kernel
#Install a 4.3+ kernel from http://kernel.ubuntu.com/~kernel-ppa/mainline, for example:
VER=4.5.1-040501
PREFIX=http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.5.1-wily/
REL=201604121331
wget ${PREFIX}/linux-headers-${VER}-generic_${VER}.${REL}_amd64.deb
wget ${PREFIX}/linux-headers-${VER}_${VER}.${REL}_all.deb
wget ${PREFIX}/linux-image-${VER}-generic_${VER}.${REL}_amd64.deb
sudo dpkg -i linux-*${VER}.${REL}*.deb
# reboot
@xkou
xkou / asyncio-tornado.py
Created June 13, 2018 09:59 — forked from arvidfm/asyncio-tornado.py
Running Tornado on asyncio's event loop, including 'yield from' support in request handlers
import asyncio
import tornado.concurrent
import tornado.ioloop
import tornado.web
import tornado.platform.asyncio
import tornado.httpclient
class ReqHandler(tornado.web.RequestHandler):
async def get(self):