Skip to content

Instantly share code, notes, and snippets.

@reusee
reusee / gist:3786837
Created September 26, 2012 08:42
golang实现的http get批量采集器
package main
import (
"net"
"bufio"
"fmt"
"strings"
"reus/utils"
"net/http"
"io/ioutil"
@reusee
reusee / gist:3786868
Created September 26, 2012 08:47
golang实现的http get批量采集器
package main
import (
"bufio"
"flag"
"fmt"
"io/ioutil"
"net"
"net/http"
"reus/utils"
@reusee
reusee / gist:3839137
Created October 5, 2012 10:28
passing struct
package oo
import (
"testing"
"strings"
)
const n = 1024 * 1
func BenchmarkPassByCopy(b *testing.B) {
@reusee
reusee / gist:3839158
Created October 5, 2012 10:34
rust message ring
use task::spawn;
use pipes::{Chan, Port, stream};
fn main() {
let mut n = 100;
let m = 1000000;
let mut (firstChan, leftPort): (Chan<int>, Port<int>) = stream();
firstChan.send(m);
let mut (rightChan, rightPort): (Chan<int>, Port<int>) = stream();
import random
def foo():
n = random.randint(0, 2)
if n == 0:
return 1
elif n == 1:
return "foo"
elif n == 2:
return {}
package main
import (
"github.com/reusee/golua/lua"
"fmt"
"time"
)
func main() {
for n := int64(0); n < int64(1024); n++ {
@reusee
reusee / gist:4357590
Last active December 10, 2015 01:19
glib main loop in py
from gi.repository import GLib
main_loop = GLib.MainLoop()
class Counter:
def __init__(self):
self.c = 0
def count(self):
print self.c
self.c += 1
@reusee
reusee / t.py
Created January 25, 2013 11:02
# coding: utf8
def p(o, level = 0):
if hasattr(o, '__iter__'):
if level > 0: print ' ' * level,
par = {
list: ('[', ']'),
tuple: ('(', ')'),
dict: ('{', '}'),
}[type(o)]
package main
import (
"encoding/xml"
"log"
"os"
"io"
"fmt"
"time"
"strings"
package main
import (
"math"
"math/rand"
"fmt"
"sync"
)
func main() {