Skip to content

Instantly share code, notes, and snippets.

View tankywoo's full-sized avatar

Tanky Woo tankywoo

View GitHub Profile
# Set up ssh-agent
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
echo "Initializing new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
@tankywoo
tankywoo / atom.xml
Last active December 23, 2015 14:12
for simiki
<?xml version="1.0" encoding="utf-8"?>
{% if site.url %}
{% set site_url = "%s%s"|format(site.url, site.root) %}
{% else %}
{% set site_url = site.url %}
{% endif %}
<feed xmlns="http://www.w3.org/2005/Atom">
<generator uri="http://simiki.org/" version="{{ site.version }}">Simiki</generator>
<title>{{ site.title }}</title>
<link href="{{ site_url }}/" />
@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:
@tankywoo
tankywoo / helloworld.c
Created April 23, 2013 13:24
测试Wordpress中嵌入Gist代码
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}
import threading
def worker():
"""thread worker function"""
print 'Worker'
return
threads = []
for i in range(5):
t = threading.Thread(target=worker)
@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
@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 / 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 / gist:4282767
Created December 14, 2012 04:53
判断一个文件是否保存某个字符/字符串
grep "str" file
if [[ $? -eq 0 ]];then
echo "error"
fi