Skip to content

Instantly share code, notes, and snippets.

View jeanbza's full-sized avatar
🐘

Jean Barkhuysen jeanbza

🐘
View GitHub Profile
Take
unlock 0
lock 0
Take
Take
Take
Take
Take
Take
Take
@jeanbza
jeanbza / foo
Created April 26, 2019 16:52
foo
take
maintainer calculates sessionsToKeep: 0
(for loop) shrinking down to: 0
take
take
take
take
take
take
take
@jeanbza
jeanbza / clean_test.go
Created April 25, 2019 21:33
cleaner_test
func TestTakeWriteSessionFromIdleList_Better(t *testing.T) {
ctx := context.Background()
sessionsToCreate := 10
idleSessions := 20
// Make sure maintainer keeps the idle sessions.
_, sp, mock, cleanup := serverClientMock(t, SessionPoolConfig{MaxIdle: uint64(idleSessions)})
defer cleanup()
@jeanbza
jeanbza / caitlin.go
Last active March 20, 2019 20:17
zips all folders in the directory it's run
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/pierrre/archivefile/zip"
)
| | With .protos | Without .protos |
|--------------------------------------------------|-----------------------------------------------------------------------------------|-----------------|
| Classes/structs/objects (in google-cloud-common) | Generated by .proto, or interpreted. | Hand written. |
| Test file creation (in google-cloud-common) | .json files generated by a (very) thin generator program in google-cloud-common. | Hand written. |
| Test file reading (in libraries) | JSON parser. | JSON parser. |
@jeanbza
jeanbza / gist:0387be14cd292bebf8cc90e87116938f
Created February 22, 2019 17:06
go get -u -v cloud.google.com/go/vision/apiv1
deklerk at deklerk in ~
$ docker run -it golang:1.11 /bin/bash
root@a831b595a7c0:/go# go get -u -v cloud.google.com/go/vision/apiv1
Fetching https://cloud.google.com/go/vision/apiv1?go-get=1
Parsing meta tags from https://cloud.google.com/go/vision/apiv1?go-get=1 (status code 200)
get "cloud.google.com/go/vision/apiv1": found meta tag get.metaImport{Prefix:"cloud.google.com/go", VCS:"git", RepoRoot:"https://code.googlesource.com/gocloud"} at https://cloud.google.com/go/vision/apiv1?go-get=1
get "cloud.google.com/go/vision/apiv1": verifying non-authoritative meta tag
Fetching https://cloud.google.com/go?go-get=1
Parsing meta tags from https://cloud.google.com/go?go-get=1 (status code 200)
cloud.google.com/go (download)
@jeanbza
jeanbza / Dockerfile
Created January 3, 2019 16:08
Dockerfile which does not hang (because it has ca-certificates)
FROM ruby:2.5.0-alpine3.7
RUN apk update
RUN apk add gcc musl-dev cmake alpine-sdk linux-headers
RUN apk add ca-certificates # adds ca-certificates, which suddenly makes google libraries work!
ADD cacert.pem /tmp/cacert/pem
ENV SSL_CERT_FILE=/tmp/cacert.pem
ADD creds.json /tmp/creds.json
ENV GOOGLE_APPLICATION_CREDENTIALS /tmp/creds.json
@jeanbza
jeanbza / spanner_cancel_lock.go
Created December 2, 2018 18:57
spanner_cancel_lock.go
package main
import (
"context"
"dummy/spanner-utility"
"fmt"
"cloud.google.com/go/spanner"
"cloud.google.com/go/spanner/admin/database/apiv1"
"google.golang.org/api/iterator"
@jeanbza
jeanbza / callers.go
Last active September 20, 2018 20:15
callers
func MyCallers() []string {
// we get the callers as uintptrs
fpcs := make([]uintptr, 1024)
n := runtime.Callers(-1, fpcs)
if n == 0 {
return []string{"I don't know your caller! What the heck.."}
}
var callers []string