Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
💻 🍞

Damian Gryski dgryski

🏠
💻 🍞
View GitHub Profile
View moving-forward-with-generics.txt
From: Ian Lance Taylor
After many discussions and reading many comments, we plan to move
forward with some changes and clarifications to the generics design
draft.
1.
We’re going to settle on square brackets for the generics syntax.
We’re going to drop the “type” keyword before type parameters, as
View fuzz.go
// +build gofuzz
package viaproxy
import (
"bytes"
"io"
"net"
)
@dgryski
dgryski / gist:a8353cb0977641f1feb6db1b8ed0eaf7
Created Feb 27, 2018
using the C pre-processor with Go
View gist:a8353cb0977641f1feb6db1b8ed0eaf7
laptop:cppgo dgryski$ cat gen.go
package main
//go:generate cpp-7 -E -P foo.gopp foo.go
laptop:cppgo dgryski$ cat foo.gopp
package main
import "fmt"
#define STRINGIFY(x) #x
View gist:8a5450a2452b9c67acd352bff5ed75dd
<dgryski@kamek[go] \ʕ◔ϖ◔ʔ/ > ag '// [A-Z]+(\([^\)]*\))?: ' |sed 's/.*\/\/ //; s/:.*//; s/(.*)/(username)/' |sort |uniq -c |sort -n
1 ARM
1 ASCII
1 BP
1 BX
1 CAVEAT
1 D
1 DATABUNDLE
1 DATABUNDLEEND
1 EXCEPT
View main_test.go
package main
import (
"strings"
"testing"
)
var m = map[string]bool{"hello.goodbye": true}
func old(req string, filter map[string]bool) string {
View gist:cff922f5ed8ff6c2b4907c38a1b2f8c0
BenchmarkKetama8-4 5000000 373 ns/op
BenchmarkKetama32-4 5000000 394 ns/op
BenchmarkKetama128-4 3000000 433 ns/op
BenchmarkKetama512-4 3000000 538 ns/op
BenchmarkKetama2048-4 2000000 672 ns/op
BenchmarkKetama8192-4 2000000 978 ns/op
BenchmarkChash8-4 10000000 129 ns/op
BenchmarkChash32-4 10000000 136 ns/op
BenchmarkChash128-4 10000000 220 ns/op
BenchmarkChash512-4 5000000 318 ns/op
View gist:31ef7c8d40f804ab1d91f0c47728e928
<dgryski@kamek[w] \ʕ◔ϖ◔ʔ/ > cat main.go
package main
import "log"
type X struct {
body string
}
type Message interface {
View bench.txt
<dgryski@kamek[powbench] \ʕ◔ϖ◔ʔ/ > go test -test.bench=.
BenchmarkPolyPow-4 5000000 286 ns/op
BenchmarkPolyFast-4 100000000 16.7 ns/op
PASS
ok github.com/dgryski/powbench 3.430s
View go-runtime.pl
#!/usr/bin/perl
use warnings;
use strict;
my $bin=$ARGV[0];
my @line = split /\s+/, `nm $bin |grep runtime.buildVersion`;
my $addr = hex($line[0]);
my $end = $addr + 16;
View escape.txt
TEXT main.main(SB) /home/dgryski/Dropbox/GITS/gocode/src/github.com/dgryski/peachpy-examples/struct/main.go
main.go:11 0x401000 64488b0c25f8ffffff FS MOVQ FS:0xfffffff8, CX
main.go:11 0x401009 483b6110 CMPQ 0x10(CX), SP
main.go:11 0x40100d 0f86de000000 JBE 0x4010f1
main.go:11 0x401013 4883ec60 SUBQ $0x60, SP
main.go:11 0x401017 48896c2458 MOVQ BP, 0x58(SP)
main.go:11 0x40101c 488d6c2458 LEAQ 0x58(SP), BP
main.go:12 0x401021 488d05585d0900 LEAQ 0x95d58(IP), AX
main.go:12 0x401028 48890424 MOVQ AX, 0(SP)
main.go:12 0x40102c e83fcb0000 CALL runtime.newobject(SB)
You can’t perform that action at this time.