Skip to content

Instantly share code, notes, and snippets.

View tankywoo's full-sized avatar

Tanky Woo tankywoo

View GitHub Profile
; Sample supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;
; Notes:
; - Shell expansion ("~" or "$HOME") is not supported. Environment
; variables can be expanded using this syntax: "%(ENV_HOME)s".
; - Comments must have a leading space: "a=b ;comment" not "a=b;comment".
@tankywoo
tankywoo / gist:4274450
Created December 13, 2012 06:07
一行写出shell判断语句
#!/bin/bash
# Tanky Woo@2012-12-13
[ "$?" -ne "0" ] && { echo "FAIL"; exit 1; } || echo "SUCC"
@tankywoo
tankywoo / gist:4282767
Created December 14, 2012 04:53
判断一个文件是否保存某个字符/字符串
grep "str" file
if [[ $? -eq 0 ]];then
echo "error"
fi
@tankywoo
tankywoo / calculate_dir.py
Last active October 14, 2015 05:34
calculate directory size
# http://stackoverflow.com/questions/1392413/calculating-a-directory-size-using-python
import os
def get_size(start_path = '.'):
total_size = 0
for dirpath, dirnames, filenames in os.walk(start_path):
for f in filenames:
fp = os.path.join(dirpath, f)
total_size += os.path.getsize(fp)
return total_size
@tankywoo
tankywoo / gh-pages-deploy.md
Created November 11, 2015 07:09 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@tankywoo
tankywoo / searchdir.sh
Created December 30, 2012 08:54
search the dir, output the blocks it have
#!/bin/bash
dir=$1
cd $dir
for ff in *
do
if [ -d "$ff" ]; then
du -hs "$ff";
fi;
done
import threading
def worker():
"""thread worker function"""
print 'Worker'
return
threads = []
for i in range(5):
t = threading.Thread(target=worker)
@tankywoo
tankywoo / helloworld.c
Created April 23, 2013 13:24
测试Wordpress中嵌入Gist代码
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}
@tankywoo
tankywoo / uplight.py
Created April 25, 2013 17:47
树莓派 一直点亮GPIO11 控制的发光二极管
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
# need to set up every channel which are using as an input or an output
GPIO.setup(11, GPIO.OUT)
while True: