Skip to content

Instantly share code, notes, and snippets.

Peter Teichman pteichman

Block or report user

Report or block pteichman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View backoff6.go
type Backoff interface {
Duration(n int) time.Duration
type RandomBackoff struct {}
func (b RandomBackoff) Duration(n int) time.Duration {
// This is a terrible idea: backoff between 0 ns and 290 years.
return time.Duration(rand.Int63())
View backoff5.go
func retryConn(reset, done <-chan struct{}) {
var attempt int
for {
// Replace the time.Sleep above with this block.
select {
case <-done:
case <-reset:
View backoff4.go
func retryConn(done <-chan struct{}) {
var attempt int
for {
// Replace the time.Sleep above with this block.
select {
case <-done:
case <-time.After(backoff.Default.Duration(attempt)):
View backoff3.go
func retryConn() {
var attempt int
for {
conn, err := makeConnection()
if err != nil {
// Maybe log the error.
View backoff2.go
package backoff
import "time"
// BackoffPolicy implements a backoff policy, randomizing its delays
// and saturating at the final value in Millis.
type BackoffPolicy struct {
Millis []int
View backoff1.go
package backoff
type Backoff struct {
attempt int
func New() *Backoff {
pteichman / gist:55577c41bf5355f548c0
Created Mar 31, 2015
Google Books trigram download
View gist:55577c41bf5355f548c0
for n in 0 1 2 3 4 5 6 7 8 9 _ADJ_ _ADP_ _ADV_ _CONJ_ _DET_ _NOUN_ _NUM_ _PRON_ _PRT_ _VERB_ a_ aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az b_ ba bb bc bd be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv bw bx by bz c_ ca cb cc cd ce cf cg ch ci cj ck cl cm cn co cp cq cr cs ct cu cv cw cx cy cz d_ da db dc dd de df dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy dz e_ ea eb ec ed ee ef eg eh ei ej ek el em en eo ep eq er es et eu ev ew ex ey ez f_ fa fb fc fd fe ff fg fh fi fj fk fl fm fn fo fp fq fr fs ft fu fv fw fx fy fz g_ ga gb gc gd ge gf gg gh gi gj gk gl gm gn go gp gq gr gs gt gu gv gw gx gy gz h_ ha hb hc hd he hf hg hh hi hj hk hl hm hn ho hp hq hr hs ht hu hv hw hx hy hz i_ ia ib ic id ie if ig ih ii ij ik il im in io ip iq ir is it iu iv iw ix iy iz j_ ja jb jc jd je jf jg jh ji jj jk jl jm jn jo jp jq jr js jt ju jv jw jx jy jz k_ ka kb kc kd ke kf kg kh ki kj kk kl km kn ko kp kq kr ks kt ku kv kw kx ky kz l_ la lb lc ld le lf lg lh li lj lk ll l
pteichman / beats.c
Last active Aug 29, 2015
Euclidean drums (C)
View beats.c
#include <stdio.h>
#include <string.h>
// beat must be an already allocated, num_steps length array.
void fill_beats(char *beat, int num_beats, int num_steps) {
int cur = num_steps;
for (int i=0; i<num_steps; i++) {
if (cur >= num_steps) {
cur -= num_steps;
beat[i] = 'x';
pteichman /
Created Jan 30, 2015
Euclidean drums (Python)
def fill_beats(num_beats, num_steps):
beats = ""
cur = num_steps
for _ in xrange(num_steps):
if cur >= num_steps:
cur -= num_steps
beats += "x"
beats += "."
View gist:9ffe82fc9d7d6e7a628f
CHAPTER I. Down the 🐰-Hole
Alice was beginning to get very tired of sitting by her 👶 on the
🏦, and of having 0⃣ to do: once or twice she had peeped into the
📖 her 👶 was reading, but it had no pictures or conversations in
it, 'and what is the use of a 📖,' thought Alice 'without pictures or
You can’t perform that action at this time.