Skip to content

Instantly share code, notes, and snippets.

@ericlagergren
ericlagergren / procmaps.go
Last active February 12, 2016 09:57
Read /proc/$$/maps into something workable.
// +build ignore
package main
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"log"
#include <string.h>
// Assuming name is null-terminated.
static bool contains(const char* const* kws, const char* name) {
while (*++kws) {
if (strcmp(*kws, name) == 0) {
return true;
}
}
return false;
package main
import (
"archive/zip"
"bufio"
"fmt"
"io"
"log"
"os"
"sort"
@ericlagergren
ericlagergren / latency.txt
Created October 25, 2015 08:21 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
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
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
return json.Marshal(struct {
Payload json.RawMessage `json:"payload"`
Signatures []sigHead `json:"signatures"`
}{
Payload: j.plcache,
Signatures: j.sb,
})
}
@ericlagergren
ericlagergren / idk.s
Last active September 27, 2015 01:01
// type a struct { b string }
// func (x a) Name() { return x.b }
// type b a
// aa := a{ b: "1234" }
// _ = aa.Name()
// bb := b{ b: "1234" }
// _ = a(bb).Name()
test.go:7 0x401004 31db XORL BX, BX
test.go:7 0x401006 488d0d93e90600 LEAQ 0x6e993(IP), CX
// package jwt
type Claims map[string]interface{}
type JWT interface{
GetClaims() Claims
}
func Parse(b []byte) JWT {
// heuristics
if isJWE {
{
"form_id": "form_id_here",
"items": [
"cool_shirt_1",
"cool_pants_2",
"ziglar_dvd_3",
],
...
}
package main
import (
"fmt"
"math/rand"
"strings"
"time"
)
func getInput() string {
### Keybase proof
I hereby claim:
* I am ericlagergren on github.
* I am ericlagergren (https://keybase.io/ericlagergren) on keybase.
* I have a public key whose fingerprint is D290 3B6E 2274 1158 7595 6F3C 1615 1BDB C433 449C
To claim this, I am signing this object: