Skip to content

Instantly share code, notes, and snippets.

@reusee
reusee / gist:1554159
Created January 3, 2012 08:58
a coroutine-based parallel library for Python
# coding: utf8
from types import *
import thread
import time
import multiprocessing
import ctypes
import traceback
class ProcessRegistry:
@reusee
reusee / gist:2437960
Created April 21, 2012 15:52
xml dom accessor
from xml.dom.minidom import parseString
from xml.dom import Node
def parse(source):
dom = parseString(source)
return AccessProxy(dom)
class AccessProxy(object):
def __init__(self, dom):
self.dom = dom
@reusee
reusee / gist:2486397
Created April 25, 2012 04:35
print a matrix using QGraphicsView
from PySide.QtCore import *
from PySide.QtGui import *
from numpy import *
import sys
app = QApplication(sys.argv)
matrix = arange(16).reshape(4, 4)
scene = QGraphicsScene()
|
-
- id = main_nav
a 豆瓣社区
a 豆瓣读书
a 豆瓣电影
a 豆瓣音乐
a 豆瓣同城
a 豆瓣FM
a 更多
(require 'package) (package-initialize)
(add-to-list 'package-archives '("elpa" . "http://tromey.com/elpa/"))
(add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/"))
(require 'ace-jump-mode)
; Appearance
(setq linum-format "%d ") (global-linum-mode 1)
(setq ring-bell-function 'ignore)
(setq scroll-step 1 scroll-conservatively 10000)
@reusee
reusee / gist:3711912
Created September 13, 2012 04:45
ring
package main
import "fmt"
const links int = 100
const messages int = 1000000
type Msg struct {
tag string
msg int
@reusee
reusee / gist:3711915
Created September 13, 2012 04:46
ring
package main
import "fmt"
const links int = 100
const messages int = 1000000
type Msg struct {
tag string
msg int
@reusee
reusee / gist:3723451
Created September 14, 2012 17:41
image viewer written by golang
package main
import (
"fmt"
sf "gosfml2"
"time"
"path/filepath"
"os"
"flag"
"math/rand"
use task::spawn;
use uint::range;
use io::println;
use pipes::{stream, Port, Chan};
const N: uint = 100;
fn main() {
let mut chans: ~[mut (Chan<uint>, Port<uint>)] = ~[mut];
for range(0, N) |_i| {
@reusee
reusee / gist:3783289
Created September 25, 2012 17:25
pool
package main
import (
"sync"
"fmt"
)
func WorkerPool(size int) chan func() {
listen := make(chan func())
pool := make(chan bool, size)