Skip to content

Instantly share code, notes, and snippets.

@hit9
hit9 / sources.list
Created April 3, 2013 06:00
哈工大ubuntu 11.04源
deb http://run.hit.edu.cn/ubuntu/ natty main universe restricted multiverse
deb-src http://run.hit.edu.cn/ubuntu/ natty universe main multiverse restricted
deb http://run.hit.edu.cn/ubuntu/ natty-security universe main multiverse restricted
deb-src http://run.hit.edu.cn/ubuntu/ natty-security universe main multiverse restricted
deb http://run.hit.edu.cn/ubuntu/ natty-updates universe main multiverse restricted
deb-src http://run.hit.edu.cn/ubuntu/ natty-updates universe main multiverse restricted
@hit9
hit9 / misaka_hilite.py
Last active December 15, 2015 06:59
use misaka to highlight code with pygments
import houdini as h
from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import HtmlFormatter
import misaka as m
from misaka import HtmlRenderer, SmartyPants
# Create a custom renderer
class BleepRenderer(HtmlRenderer, SmartyPants):
@hit9
hit9 / str_to_int.py
Created March 13, 2013 02:12
字符串转数字. eg: "3456" => 3456
reduce(lambda x,y:10*x+y,map(lambda x:ord(x)-48,a))

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
@hit9
hit9 / gist:5037573
Created February 26, 2013 10:41
如何翻转链表中的相邻两个元素?
/*
* Q: 如何翻转链表中的相邻两个元素?
* Link: http://www.foreach.cn/question/16
* 比如原链表是:
* a->b->c->d->e->f
* 我们只翻转相邻两个,即1和2翻转,3和4翻转,翻转后如下:
* b->a->d->c->f->e
*/
#include <stdio.h>
@hit9
hit9 / tree.md
Created January 13, 2013 12:47 — forked from hrldcpr/tree.md

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!