Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Weiliang Li kigawas

🎯
Focusing
View GitHub Profile
@kigawas
kigawas / redo-undo-container.js
Last active Dec 28, 2020
redux in 40 lines of code with redo/undo
View redo-undo-container.js
const createStore = (reducer) => {
const states = [reducer()];
let sp = 0; // stack pointer
const listeners = new Set();
function notify() {
for (const listener of listeners) {
listener();
}
}
@kigawas
kigawas / uf.py
Created Jan 20, 2020
Simple python union find
View uf.py
class UF:
def __init__(self, n):
self.par = list(range(n))
self.rank = [0] * n
def find(self, x):
if x != self.par[x]:
self.par[x] = self.find(self.par[x])
return self.par[x]
@kigawas
kigawas / update_kubelet_config.yml
Created Jun 5, 2019
Ansible playbook for updating kubelet daemon config on all nodes
View update_kubelet_config.yml
---
- hosts: all
become: true
tasks:
- name: kubelet gce config
copy:
dest: /etc/default/kubelet
content: KUBELET_EXTRA_ARGS=--cloud-provider=gce # Add your custom flag here
- name: Systemd reload configs
@kigawas
kigawas / watch_and_sync.sh
Last active Apr 23, 2019
Automatically rsync local folder to server's folder behind http proxy on Linux
View watch_and_sync.sh
LOCAL=$1 # /home/user/test/
REMOTE=$2 # /home/remoteuser/test/
if [[ -z "$LOCAL" || -z "$REMOTE" ]]; then
echo 'No src/dst folder'
exit
fi
while inotifywait -r -e modify,create,delete $LOCAL; do
rsync -avuz --delete -e "ssh -o \"ProxyCommand=connect-proxy -H YOUR_PROXY_HOST:YOUR_PROXY_PORT %h %p\"" $LOCAL YOUR_USERNAME@YOUR_SERVER_IP:$REMOTE
View unblock_youku_urls.txt
^dmd\-fifajs\-h5\-ikuweb\.youku\.com:443
^dmd\-fifa\-h5\-ikuweb\.youku\.com:443
^http:\/\/acs\.youku\.com\/.*$
^acs\.youku\.com:443
^http:\/\/pl\-ali\.youku\.com\/.*$
^http:\/\/list\.youku\.com\/.*$
^http:\/\/api\.youku\.com\/.*$
^http:\/\/play\.youku\.com\/.*$
^http:\/\/play\-dxk\.youku\.com\/.*$
^http:\/\/play\-ali\.youku\.com\/.*$
@kigawas
kigawas / a.pyx
Created Jun 26, 2018
Cython example of multiple pyx files
View a.pyx
cdef int _fib(int n):
cdef int i
cdef int a=0, b=1
for i in range(n):
a, b = a + b,a
return a
def fib(n):
return _fib(n)
@kigawas
kigawas / setup_ss.md
Created Jun 22, 2018
搭建Shadowsocks服务
View setup_ss.md

系统版本

Ubuntu 18.04 LTS

防火墙规则

打开80 443和4000端口

@kigawas
kigawas / initialize.sh
Last active Jun 19, 2018
Initialize docker on Ubuntu
View initialize.sh
apt-get update
apt-get install apt-transport-https ca-certificates curl software-properties-common -y -q
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-key fingerprint 0EBFCD88
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install docker-ce -y -q
@kigawas
kigawas / fix_docker_redis.sh
Last active Jun 19, 2018
Run redis in docker without warnings
View fix_docker_redis.sh
sysctl vm.overcommit_memory=1
echo never > /sys/kernel/mm/transparent_hugepage/enabled
View proxychina.pac
var nowall_proxy = "SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080;";
var wall_proxy = "DIRECT;";
var direct = "DIRECT;";
var ip_proxy = "DIRECT;";
/*
* Copyright (C) 2014 breakwa11
* https://github.com/breakwa11/gfw_whitelist
*/