Skip to content

Instantly share code, notes, and snippets.

$ time ./client_cpp
real 1m48.071s
user 0m1.955s
sys 1m45.919s
# ./trace.d
dtrace: script './trace.d' matched 22 probes
CPU ID FUNCTION:NAME
2 1 :BEGIN Tracing...
@kylelemons
kylelemons / makedict.go
Created May 11, 2012 00:25 — forked from lamvak/makedict.go
particularly disturbing fragment of my new poliqarp binding (in progress)
func MakeDict(prefix string, strings []string) (dict *Dict, err error) {
image_file_size := 0
dict, err = nil, nil
for _, s := range strings {
// accomodate the string itself, length counter and zero-byte marker
// for the reason of backwards debility
image_file_size += len(s) + 5
}
image_file, err := os.Create(prefix + `.image`)
defer image_file.Close()
@kylelemons
kylelemons / bdr_proto.proto
Created April 18, 2012 01:06 — forked from spikebike/bdr_proto.proto
example for protobuf, go, and the repeated protobuf entry
package bdr_proto;
message request {
message blob {
required string hash = 1; // the sha256 checksum of the blob
required int32 size = 2; // the size of the blob
}
repeated blob blobs = 1;
}
@kylelemons
kylelemons / piping.go
Last active July 4, 2022 01:25 — forked from dagoof/piping.go
piping exec.Cmd in golang (example sorts all regular files under a directory by their extension)
package main
import (
"bytes"
"exec"
"log"
"os"
)
// Pipeline strings together the given exec.Cmd commands in a similar fashion
@kylelemons
kylelemons / client.go
Created August 9, 2011 20:49 — forked from zhujo01/client.go
TLS echo server and client
package main
import (
"crypto/tls"
"io"
"log"
)
func main() {
conn, err := tls.Dial("tcp", "127.0.0.1:8000", nil)