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 / 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
@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 / 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 / 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 / README.md
Last active November 13, 2015 09:05 — forked from chuangbo/README.md
Python dynamic DNSPod DNS Script

替换上你的Email,密码,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔60秒检查一遍IP,如果修改了就更新IP。

获得domain_id可以用curl curl -k https://dnsapi.cn/Domain.List -d "login_email=xxx&login_password=xxx"

获得record_id类似 curl -k https://dnsapi.cn/Record.List -d "login_email=xxx&login_password=xxx&domain_id=xxx"

@qizhihere
qizhihere / delay.js
Created September 11, 2015 04:43
delay callback most used in keyboard events
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
// Usage
$('input').keyup(function() {
@qizhihere
qizhihere / time_ago.php
Last active September 7, 2015 06:43 — forked from hubsgz/convert2timeago.php
convert timestamp to N days/hours/minutes/seconds ago
function time_ago($timestamp, $lang='cn')
{
$msg = [
'cn' => [
'day' => '天前',
'hour' => '小时前',
'minute' => '分钟前',
'second' => '秒前',
],
'en' => [
@qizhihere
qizhihere / i3lock.sh
Created July 11, 2015 16:56
lock screen use i3lock and randomly select wallpaper or blur
#!/usr/bin/env bash
exec 2>/dev/null
exec 1>/dev/null
IMGS_DIR="$HOME/Pictures/Wallpapers/normal"
command-exist-p () {
local _command_exist=0
for i in "$@"; do
type -a "$i" &>/dev/null || _command_exist=1
@qizhihere
qizhihere / delay-search-prompt.js
Last active August 29, 2015 14:24
show delay prompt for search bar
function delayPrompt(event, elem, cb) {
var value = elem.prop('value');
this.lastKeyUp = event.timeStamp;
setTimeout(function() {
/* check input interval */
if (this.lastKeyUp - event.timeStamp !== 0) {
return;
}
@qizhihere
qizhihere / random-wallpaper.sh
Created July 9, 2015 01:59
randomly pick a wallpaper from one or more directory(or directories)
#!/usr/bin/env bash
WALLPAPER_DIR="/home/xxx/Pictures/Wallpapers/normal/"
find "$WALLPAPER_DIR/" -type f -regex ".*\.\(png\|jpe?g\)" |
shuf -n1 | xargs -I__ feh --bg-scale "__"