Skip to content

Instantly share code, notes, and snippets.

@menghan
menghan / mix.go
Last active August 29, 2015 13:57
package mix
func Mix(high <-chan interface{}, low <-chan interface{}) <-chan interface{} {
c := make(chan interface{})
go func() {
defer close(c)
var vh, vl interface{}
highOpen := true
lowOpen := true
var ok bool
@menghan
menghan / makefile
Created March 28, 2014 14:22
manipulate path in makefile
PATH := $(PATH):/tmp/t
export PATH
t:
env
testcmd
@menghan
menghan / main.py
Last active August 29, 2015 13:57
# coding=utf-8
from sqlalchemy import create_engine, Column, Integer, DECIMAL, DATE, String, ForeignKey, Float, TEXT
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship, backref
db_schema = 'sqlite:///sqlite.db'
debug = True
engine = create_engine(db_schema, echo=debug)
create_session = sessionmaker(bind=engine)
@menghan
menghan / gist:8178588
Created December 30, 2013 06:37
setuptools bug paste
(st)menghan@MenghanMac:/tmp/t$ python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to ExampleProject.egg-info/requires.txt
writing ExampleProject.egg-info/PKG-INFO
writing namespace_packages to ExampleProject.egg-info/namespace_packages.txt
writing top-level names to ExampleProject.egg-info/top_level.txt
writing dependency_links to ExampleProject.egg-info/dependency_links.txt
WARNING: example is a namespace package, but its __init__.py does
@menghan
menghan / Makefile
Last active December 23, 2015 20:09
bench:
go test benchmark_test.go --bench=. | tee result
import time
import gevent
request_times = []
def calc_response_time(func):
def _(env, start_response):
package main
import "fmt"
type Handle interface {
ServeHTTP(c *int, req *int)
}
func NotFound(c *int, req *int) {
}
@menghan
menghan / git.md
Created February 26, 2013 03:46
学习 git:Documentation/user-manual.txt 的笔记

git log -S'foo()' # search changesets which changes 'foo()'

git diff master..test # diff between tips of the two branches

git diff master...test # diff from common ancestor to test

git format-patch master..test # 加不加 '..' 是一样的

git show v2.5:fs/locks.c

@menghan
menghan / vim.rst
Created February 25, 2013 09:25
学习 vim help 的笔记

undo and redo

  • u/^R/U
  • :undo + <num> / g- / g+ : 前者用于知道跳转去向,后者用于不知道的
  • :undolist
  • :earlier 10s / 10h / 1m / :later
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from twisted.internet import reactor, defer, protocol
from twisted.protocols import basic
from twisted.python import log
class LongTimeProtocol(basic.LineReceiver):