This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/sha1" | |
"crypto/x509" | |
"encoding/pem" | |
"flag" | |
"io/ioutil" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"html/template" | |
"net/url" | |
"os" | |
"regexp" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/hex" | |
"fmt" | |
) | |
var i2b = []byte("0123456789bcdfghjklmnpqrstuvwxyz") | |
var b2i = func() []byte { | |
var ascii [256]byte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
benchmark old ns/op new ns/op delta | |
BenchmarkWriteDefault 14287 3258 -77.20% | |
BenchmarkWriteShortList 13116 3516 -73.19% | |
BenchmarkWriteCompact 10669 2897 -72.85% | |
BenchmarkWriteDiffable 16807 3786 -77.47% | |
benchmark old MB/s new MB/s speedup | |
BenchmarkWriteDefault 7.98 34.99 4.38x | |
BenchmarkWriteShortList 5.95 22.18 3.73x | |
BenchmarkWriteCompact 4.12 15.19 3.69x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
const Max = 10 | |
const Index = 1000000 | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
You can preprocess this using the following: | |
gcc -E -x c -P -C main.go | |
*/ | |
/* abs.h */ | |
#define ABS(N, T) func Abs##N(v T) T { \ | |
; if v < 0 { \ | |
; return -v \ | |
; } \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"unicode" | |
) | |
func validPassword(s string) error { | |
next: | |
for name, classes := range map[string][]*unicode.RangeTable{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func manager() { | |
chans := map[chan data]bool | |
active := sync.WaitGroup{} | |
for { | |
select { | |
case c := <-register: | |
chans[c] = true | |
case c := <-unregister: | |
active.Wait() | |
delete(chans, c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |