Skip to content

Instantly share code, notes, and snippets.

import logging
import optparse
LOGGING_LEVELS = {'critical': logging.CRITICAL,
'error': logging.ERROR,
'warning': logging.WARNING,
'info': logging.INFO,
'debug': logging.DEBUG}
def main():
@ysheng26
ysheng26 / decorator.py
Created August 28, 2013 03:21
A python decorator template
def decorator_with_args(decorator_to_enhance):
"""
This function is supposed to be used as a decorator.
It must decorate an other function, that is intended to be used as a decorator.
Take a cup of coffee.
It will allow any decorator to accept an arbitrary number of arguments,
saving you the headache to remember how to do that every time.
"""
# We use the same trick we did to pass arguments
@ysheng26
ysheng26 / Chess-Openings.txt
Created August 28, 2013 03:29
Chess openings I prefer
Sicilian, Najdorf (B90)
1 e4 c5 2 Nf3 d6 3 d4 cxd4 4 Nxd4 Nf6 5 Nc3 a6
Sicilian, Najdorf, Opocensky Variation (B92)
1 e4 c5 2 Nf3 d6 3 d4 cxd4 4 Nxd4 Nf6 5 Nc3 a6 6 Be2
Sicilian, Najdorf (B96)
1 e4 c5 2 Nf3 d6 3 d4 cxd4 4 Nxd4 Nf6 5 Nc3 a6 6 Bg5 e6 7 f4
@ysheng26
ysheng26 / c-declaration-interpreter.c
Created August 30, 2013 02:35
C declaration intepreter from Expert C Programming
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#define MAXTOKENS 100
#define MAXTOKENLEN 64
enum type_tag { IDENTIFIER, QUALIFIER, TYPE };
struct token
@ysheng26
ysheng26 / install_linux_on_chromebook_pixel.txt
Created August 30, 2013 02:38
Instructions of how to install linux on chromebook pixel
Installing Linux on the Chromebook Pixel.
These directions are provided AS-IS, if you lose all of your data or
brick your machine, it's not my problem.
Quick pre-requisites:
A) You should (optionally) have a USB mouse you can plug into the
Pixel for when you first boot into Linux as the touchpad and
touchscreen won't work at the beginning.
@ysheng26
ysheng26 / caps2ctrl.ahk
Created September 3, 2013 01:27
AutoHotKey script to assign capslock to ctrl. It is optional to remap capslock to either left ctrl or right ctrl.
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: William Isaac Miller <wimiller@cs.umb.edu>
;
; Script Function:
; Remaps the CapsLock key to Control, and moves CapsLock to Right Control.
;
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@ysheng26
ysheng26 / .gitconfig
Last active December 24, 2015 21:19
my .gitconfig file
[user]
name = Sheng Yun
email = uewing@gmail.com
[core]
excludesfile = /Users/shengy/.gitignore_global
autocrlf = false
; editor = mvim -f
editor = vi
; editor = emacs
[diff]
@ysheng26
ysheng26 / bash_profile
Last active December 25, 2015 00:29
bash_profile
source ~/Dropbox/shengy/scripts/git-completion.bash
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/shengy/bin
export PATH=$PATH:~/bin
export PATH=/usr/texbin:$PATH
export PATH=~/libs/android-sdk-macosx/platform-tools:~/libs/android-sdk-macosx/tools:$PATH
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/shims:$PATH"
@ysheng26
ysheng26 / template.sublime-project
Created February 13, 2014 08:37
sublime project template from official documentation
{
"folders":
[
{
"path": "src",
"folder_exclude_patterns": ["backup"]
},
{
"path": "docs",
"name": "Documentation",