Skip to content

Instantly share code, notes, and snippets.

View tankywoo's full-sized avatar

Tanky Woo tankywoo

View GitHub Profile

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

# Copyright (c) 2011 Phil Plante <unhappyrobot AT gmail DOT com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@tankywoo
tankywoo / color_print.py
Created December 18, 2013 02:07
color print
RESET_COLOR = "\033[0m"
COLOR_CODES = {
"debug" : "\033[1;34m", # blue
"info" : "\033[1;32m", # green
"warning" : "\033[1;33m", # yellow
"error" : "\033[1;31m", # red
"critical" : "\033[1;41m", # background red
}
# 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 / iptables.sh
Created May 22, 2013 02:33
iptables startup script, put it in /etc/init.d/
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: iptables
# Required-Start: mountkernfs $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Set up iptables rules
### END INIT INFO
@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