Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"github.com/EverythingMe/inbloom/go/inbloom"
"net/http"
)
var vocabulary = []string{"foo", "bar", "baz", "hey", "yo", "go"}
@dvirsky
dvirsky / disque_example.go
Created May 3, 2015 13:32
Disque Usage example
package main
import(
"fmt"
"time"
"github.com/EverythingMe/go-disque/disque"
"github.com/garyburd/redigo/redis"
)
@dvirsky
dvirsky / README.md
Last active August 29, 2015 14:20 — forked from jonhoo/README.md

Distributed Read-Write Mutex in Go

The default Go implementation of sync.RWMutex does not scale well to multiple cores, as all readers contend on the same memory location when they all try to atomically increment it. This gist explores an n-way RWMutex, also known as a "big reader" lock, which gives each CPU core its own RWMutex. Readers take only a read lock local to their core, whereas writers must take all locks in order.

package redis
import (
"fmt"
"github.com/garyburd/redigo/redis"
)
// Batch represents a set of batched results, either a transaction or just send/receive.
//
@dvirsky
dvirsky / gist:dfdfd4066c70e8391dc5
Created December 24, 2014 13:45
Checking is a function was deferred or not
package main
import(
"fmt"
"runtime"
"io/ioutil"
"bytes"
"strings"
)
@dvirsky
dvirsky / gist:f9ebf6f66f763a356d4a
Created November 19, 2014 11:58
Long running Python Parent/Child communication via pipes
import subprocess
import time
import sys
def parent():
p = subprocess.Popen(['python', './testp.py', '--child'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)