Skip to content

Instantly share code, notes, and snippets.

View qizhihere's full-sized avatar

littleqz qizhihere

  • WuHan, Hubei Province, China
View GitHub Profile
@qizhihere
qizhihere / docker-entrypoint-example.sh
Created June 28, 2016 14:38
Run a process in a docker container with specific uid and gid. Take dropbox for example.
#!/usr/bin/env sh
has_gid () {
cut -d: -f1,4 /etc/passwd | grep -q "^${1}:${2}" || return 1
}
# example: ensure_user btsync 1000 1000
ensure_user () {
local user=$1
local uid=$2
@qizhihere
qizhihere / gist:351ffdba62f6f2737dc742240af6b243
Created July 7, 2016 12:51 — forked from vladimirtsyupko/gist:10964772
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@qizhihere
qizhihere / script-helpers.py
Last active October 3, 2016 06:20
Python helper functions.
def has_pkg(package):
import importlib
try:
importlib.import_module(package)
except ImportError:
return False
return True
def pip_install(package):
import pip
@qizhihere
qizhihere / tmux_install.sh
Last active October 14, 2016 13:06 — forked from P7h/tmux__CentOS__build_from_source.sh
tmux 2.0 and tmux 2.3 installation steps for Ubuntu
# tmux v2.3 installation steps for Ubuntu [various OS versions]
sudo apt-get update -yqqu
sudo add-apt-repository -y ppa:pi-rho/dev
sudo apt-get update -yqqu
sudo apt-get install -yqqu python-software-properties software-properties-common
sudo apt-get install -yqq tmux-next=2.3~20160913~bzr3547+20-1ubuntu1~ppa0~ubuntu16.04.1
# sudo apt-get install -yqq tmux-next=2.3~20160913~bzr3547+20-1ubuntu1~ppa0~ubuntu15.10.1
# sudo apt-get install -yqq tmux-next=2.3~20160913~bzr3547+20-1ubuntu1~ppa0~ubuntu15.04.1
# sudo apt-get install -yqq tmux-next=2.3~20160913~bzr3547+20-1ubuntu1~ppa0~ubuntu14.04.1