Skip to content

Instantly share code, notes, and snippets.

View skydark's full-sized avatar

Skydark Chen skydark

View GitHub Profile
import time
class Timer(object):
def __init__(self, verbose=False):
self.verbose = verbose
def __enter__(self):
self.start = time.time()
return self
@skydark
skydark / prime_sieve.go
Created August 15, 2012 15:37 — forked from lyricat/prime_sieve.go
A concurrent prime sieve #go
// A concurrent prime sieve
// via: http://golang.org/doc/play/sieve.go
package main
// Send the sequence 2, 3, 4, ... to channel 'ch'.
func Generate(ch chan<- int) {
for i := 2; ; i++ {
ch <- i // Send 'i' to channel 'ch'.
}
@skydark
skydark / lua_OO.lua
Created May 7, 2012 15:37
http://blog.codingnow.com/cloud/LuaOO 云风:Lua 中实现面向对象 #lua
-- 这里提供 Lua 中实现 OO 的一种方案:
local _class={}
function class(super)
local class_type={}
class_type.ctor=false
class_type.super=super
class_type.new=function(...)
local obj={}