Skip to content

Instantly share code, notes, and snippets.

View hownowstephen's full-sized avatar
🥔

Stephen Young hownowstephen

🥔
View GitHub Profile
@maxpert
maxpert / hash_test.go
Created March 16, 2015 02:18
JumpConsistentHash
package main
import "fmt"
type hash_function func (uint64, int32) int32
func main() {
for j := 1; j < 32; j++ {
simulate_rebalance("JumpConsistentHash", 32, int32(32 + j), JumpConsistentHash)
simulate_rebalance("ModConsistentHash", 32, int32(32 + j), ModConsistentHash)

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
L2 cache reference ........................... 7 ns                     14x L1 cache
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns                     20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs 4X memory

@rmulley
rmulley / golang_emails.go
Last active December 11, 2016 03:17
Sends an email in Go with text/HTML and an attachment.
package main
import (
"bytes"
"encoding/base64"
"fmt"
"io/ioutil"
"log"
"net/smtp"
) //import
@omarish
omarish / gist:3080200
Created July 10, 2012 00:42
Priceonomics Puzzles

Priceonomics Programming Puzzle, Summer 2012

We love solving puzzles at Priceonomics. We also like meeting people who like to solve puzzles. Here are two interesting puzzles we've faced at some point in the past months that we'd like to share with you.

If you have any questions, contact omar@priceonomics.com.


Puzzle 1: Heatwave

@bellbind
bellbind / microdata.py
Created September 13, 2010 10:42
[python] HTML5 microdata parser
"""HTML5 microdata parser for python 2.x/3.x
- it requires lxml
- microdata specification: http://dev.w3.org/html5/md/
"""
try: from urllib.parse import urljoin
except: from urlparse import urljoin
import lxml.html as lhtml
def items(html, types=None, uri=""):