Skip to content

Instantly share code, notes, and snippets.

View laike9m's full-sized avatar
🧠
🐍

laike9m laike9m

🧠
🐍
View GitHub Profile
@koenbollen
koenbollen / punch.py
Created July 5, 2010 19:10
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
DmitrySoshnikov / python-closures.py
Created November 15, 2010 12:03
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
bdotdub / redis.markdown
Created November 24, 2010 22:18
Running redis using upstart on Ubuntu

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
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
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(
@xkyii
xkyii / git乱码解决方案汇总.txt
Created July 13, 2011 05:41
git乱码解决方案汇总
原帖地址: http://topic.csdn.net/u/20110113/19/b0d5d506-4307-428b-a61d-7974aa66a2da.html
首先要说明的是:这里介绍的方法都是大部分是本人“悟”出来的,所以网上难有流传!
好方法不能自己私藏,否则就白忙乎这几天了,分享给有需要的朋友们。如果有转载,敬请注明来自*CSDN老邓*作品。
呵呵,给自己打广告,实在是无耻之极,权当无聊之时打字之用。
欢迎流传,为最优秀的分布式版本管理系统Git做宣传!!
步骤:
1. 下载:http://loaden.googlecode.com/files/gitconfig.7z
2. 解压到:<MsysGit安装目录>/cmd/,例如:D:\Program Files\Git\cmd
@paulirish
paulirish / data-markdown.user.js
Last active February 6, 2024 10:41
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@vsajip
vsajip / custfmt.py
Created February 9, 2012 20:21
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,
logging.ERROR,
logging.CRITICAL):
@mikeal
mikeal / gist:1840641
Created February 16, 2012 01:33
get a new/clean port with node.js
var portrange = 45032
function getPort (cb) {
var port = portrange
portrange += 1
var server = net.createServer()
server.listen(port, function (err) {
server.once('close', function () {
cb(port)
@dupuy
dupuy / README.rst
Last active February 15, 2024 18:07
Common markup for Markdown and reStructuredText

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.

@zyxar
zyxar / exercise.tour.go
Last active March 8, 2024 11:47
tour.golang exercise solutions
/* Exercise: Loops and Functions #43 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(2.)