Skip to content

Instantly share code, notes, and snippets.

View dt's full-sized avatar

David Taylor dt

View GitHub Profile
@dt
dt / uuid_incr.go
Last active May 19, 2017 18:08
Computing Incremented UUID
package main
import (
"encoding/binary"
"math/big"
"math/rand"
"reflect"
"testing"
"testing/quick"
)
rekik86 @rekik86 Jun 22 2016 16:51
Hi David
David Taylor @dt Jun 22 2016 16:51
Hey
rekik86 @rekik86 Jun 22 2016 16:52
Thanks for offering your help
I'm new to RDBM
This is just a homework actually
@dt
dt / gist:aab4d2f3043c48fc432a61593f4f7ec1
Created January 5, 2017 17:36
pgbench_cockroach.txt
[17:34:59] ~/code/go/src/github.com/cockroachdb/cockroach $ rm -rf cockroach-data
[17:35:02] ~/code/go/src/github.com/cockroachdb/cockroach $ ./cockroach start --background
CockroachDB node starting at 2017-01-05 17:35:11.062768945 +0000 UTC
build: 85fe10a @ 2017/01/05 17:34:36 (go1.7.1)
admin: http://localhost:8080
sql: postgresql://root@localhost:26257?sslmode=disable
logs: cockroach-data/logs
store[0]: path=cockroach-data
status: initialized new cluster
@dt
dt / gist:042eba2f391a89c9732e90d2ad5baa7c
Created December 6, 2016 20:36
protobuf version jumping with debug output
[20:33:44] ~/code/go/src/github.com/cockroachdb/cockroach $ glide cc && ./scripts/glide.sh --debug up && g diff && ./scripts/glide.sh --debug up && g diff
[INFO] Glide cache has been cleared.
[DEBUG] No mirrors.yaml file exists
[INFO] Downloading dependencies. Please wait...
[DEBUG] Locking https-github.com-cockroachdb-c-protobuf
[DEBUG] Locking https-github.com-grpc-ecosystem-grpc-gateway
[DEBUG] Locking https-github.com-jteeuwen-go-bindata
[DEBUG] Locking https-github.com-cockroachdb-c-jemalloc
[DEBUG] Locking https-github.com-cockroachdb-crlfmt
[DEBUG] Locking https-github.com-golang-lint
@dt
dt / gist:f9ca4acb5bb27b9899d20c6f42bbf718
Created December 6, 2016 20:33
protobuf version jumping (snipped)
[20:23:31] ~/code/go/src/github.com/cockroachdb/cockroach $ glide cc && ./scripts/glide.sh up && g diff && ./scripts/glide.sh up && g diff
[INFO] Glide cache has been cleared.
[INFO] Downloading dependencies. Please wait...
...
[INFO] Keeping google.golang.org/grpc 79b7c349179cdd6efd8bac4a1ce7f01b98c16e9b
[INFO] --> Fetching github.com/matttproud/golang_protobuf_extensions.
[INFO] --> Setting version for github.com/golang/protobuf to 8d92cf5fc15a4382f8964b08e1f42a75c0591aa3.
...
[INFO] Project relies on 99 dependencies.
diff --git a/glide.lock b/glide.lock
.tab:before {
content: "\00bb\00a0";
}
/* Languages where tabs are used for indentation -- don't highlight */
.go.line.content .tab:before {
content: "\00a0\00a0";
}
package main
import "fmt"
import "testing"
// go test -bench . -benchmem -count 10 | benchstat
// name time/op alloc/op allocs/op
// Fmt-8 168ns ± 7% 32.0B ± 0% 2.00 ± 0%
func BenchmarkFmt(b *testing.B) {
for k := 0; k < b.N; k++ {
package main
import (
"database/sql"
"log"
"time"
_ "github.com/lib/pq"
)
david=# CREATE TABLE test1 (t timestamp);
david=# SET TIME ZONE -4; INSERT INTO test1 VALUES('2015-05-01 12:00:00');
david=# SET TIME ZONE 0; INSERT INTO test1 VALUES('2015-05-01 12:00:00');
david=# SET TIME ZONE 2; SELECT * FROM test1;
2015-05-01 12:00:00
2015-05-01 12:00:00
david=# SET TIME ZONE 0; SELECT * FROM test1;
2015-05-01 12:00:00
2015-05-01 12:00:00
package main
import (
"encoding/hex"
"fmt"
)
func main() {
data := []byte("ab")
encoded := make([]byte, len(data)*2+1)