Skip to content

Instantly share code, notes, and snippets.


laike9m laike9m

View GitHub Profile
koenbollen /
Created Jul 5, 2010
Proof of Concept: UDP Hole Punching
#!/usr/bin/env python
# Proof of Concept: UDP Hole Punching
# Two client connect to a server and get redirected to each other.
# This is the client.
# Koen Bollen <meneer koenbollen nl>
# 2010 GPL
DmitrySoshnikov /
Created Nov 15, 2010
Understanding Python's closures
# "Understanding Python's closures".
# Tested in Python 3.1.2
# General points:
# 1. Closured lexical environments are stored
# in the property __closure__ of a function
# 2. If a function does not use free variables
bdotdub / redis.markdown
Created Nov 24, 2010
Running redis using upstart on Ubuntu
View redis.markdown

Running redis using upstart on Ubuntu

I've been trying to understand how to setup systems from the ground up on Ubuntu. I just installed redis onto the box and here's how I did it and some things to look out for.

To install:

mikeyk /
Created Apr 8, 2011
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
View git乱码解决方案汇总.txt
1. 下载:
2. 解压到:<MsysGit安装目录>/cmd/,例如:D:\Program Files\Git\cmd
paulirish / data-markdown.user.js
Last active Jul 12, 2020
*[data-markdown] - use markdown, sometimes, in your HTML
View data-markdown.user.js
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <>
// @link
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
jrom / nginx.conf
Created Feb 7, 2012
nginx hack for multiple conditions
View nginx.conf
if ($request_uri = /) {
set $test A;
if ($host ~* {
set $test "${test}B";
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
vsajip /
Created Feb 9, 2012
Example of logging formatter factory usage with fileConfig()
import logging
class CustomFormatter(logging.Formatter):
def __init__(self, default):
self.default = default
def format(self, record):
if record.levelno in (logging.WARNING,
mikeal / gist:1840641
Created Feb 16, 2012
get a new/clean port with node.js
View gist:1840641
var portrange = 45032
function getPort (cb) {
var port = portrange
portrange += 1
var server = net.createServer()
server.listen(port, function (err) {
server.once('close', function () {
dupuy / README.rst
Last active Aug 2, 2020
Common markup for Markdown and reStructuredText
View README.rst

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.

You can’t perform that action at this time.