Skip to content

Instantly share code, notes, and snippets.

View ajm188's full-sized avatar

Andrew Mason ajm188

View GitHub Profile
@ajm188
ajm188 / main.go.diff
Created July 19, 2022 10:24
golang exec vs exec sh
grep := exec.CommandContext(ctx,
- "grep",
- "-Er",
- `'\bflag\.[A-Z]'`,
- path,
+ "sh", "-c", strings.Join([]string{
+ "grep",
+ "-Er",
+ `'\bflag\.[A-Z]'`,
+ path,
@ajm188
ajm188 / user_key_authenticator.go
Created May 4, 2022 13:15
Example VTAdmin Authenticator implementation
package main
import (
"ctx"
"http"
"strings"
"google.golang.org/grpc/metadata"
"vitess.io/vitess/go/vt/log"
@ajm188
ajm188 / vtadmin-out.txt
Created April 6, 2022 20:04
vtadmin grpc dynamic cluster
I0406 16:00:17.342425 5884 resolver.go:269] [vtadmin.cluster.resolver]: resolving vtctlds (cluster dynamic)
I0406 16:00:17.342477 5884 resolver.go:332] [vtadmin.cluster.resolver]: found 1 vtctlds (cluster dynamic)
I0406 16:00:17.342557 5884 proxy.go:141] Established gRPC connection to vtctld
I0406 16:00:17.345089 5884 resolver.go:269] [vtadmin.cluster.resolver]: resolving vtgates (cluster dynamic)
I0406 16:00:17.345144 5884 resolver.go:332] [vtadmin.cluster.resolver]: found 1 vtgates (cluster dynamic)
I0406 16:00:17.345230 5884 vtsql.go:136] Have valid connection to vtgate, reusing it.
@ajm188
ajm188 / main.go
Created April 5, 2022 13:21
vtadmin channelz demo
package main
import (
"context"
"errors"
"flag"
"fmt"
"google.golang.org/grpc"
@ajm188
ajm188 / flagutil.go.diff
Created November 3, 2021 10:39
mysqlctl => pflag
diff --git a/go/flagutil/flagutil.go b/go/flagutil/flagutil.go
index a03cb972d1..0b316fbd5a 100644
--- a/go/flagutil/flagutil.go
+++ b/go/flagutil/flagutil.go
@@ -83,6 +83,11 @@ func (value StringListValue) String() string {
}
+// Type is part of the pflag.Value interface.
+func (value StringListValue) Type() string {
@ajm188
ajm188 / go.rb.diff
Created August 26, 2021 23:43
homebrew go1.17
diff --git a/Formula/go.rb b/Formula/go.rb
index 41f8245cdd2..5b4ae9346a5 100644
--- a/Formula/go.rb
+++ b/Formula/go.rb
@@ -1,9 +1,9 @@
class Go < Formula
desc "Open source programming language to build simple/reliable/efficient software"
homepage "https://golang.org"
- url "https://golang.org/dl/go1.16.6.src.tar.gz"
- mirror "https://fossies.org/linux/misc/go1.16.6.src.tar.gz"
@ajm188
ajm188 / results.txt
Created June 24, 2021 00:35
boolset vs emptystructset
goos: darwin
goarch: amd64
pkg: ajm188.scratch/setsbench
cpu: Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
BenchmarkSets/bool_set-8 366444 3804 ns/op 2620 B/op 6 allocs/op
BenchmarkSets/emptystruct_set-8 303908 3472 ns/op 2363 B/op 6 allocs/op
PASS
coverage: 0.0% of statements
ok ajm188.scratch/setsbench 2.867s
@ajm188
ajm188 / etcd-up.sh.diff
Created June 10, 2021 18:47
vtctl replacement
--- a/examples/local/scripts/etcd-up.sh
+++ b/examples/local/scripts/etcd-up.sh
@@@ -40,10 -40,10 +40,21 @@@ etcdctl --endpoints "http://${ETCD_SERV
echo "add $cell CellInfo"
set +e
# shellcheck disable=SC2086
--vtctl $TOPOLOGY_FLAGS AddCellInfo \
-- -root /vitess/$cell \
-- -server_address "${ETCD_SERVER}" \
-- $cell
@ajm188
ajm188 / server.go
Created December 8, 2020 01:00
ShowAllKeyspaces stream
func (s *VtctldServer) ShowAllKeyspaces(req *vtctldatapb.ShowAllKeyspacesRequest, stream vtctlservicepb.Vtctld_ShowAllKeyspacesServer) error {
ctx := stream.Context()
keyspaces, err := s.ts.GetKeyspaces(ctx)
if err != nil {
return err
}
wg := sync.WaitGroup{}
ch := make(chan string)
@ajm188
ajm188 / padding_bench_test.go
Last active November 22, 2020 18:54
Zero padding benchmarks
package strings
import (
"bytes"
"fmt"
"strings"
"testing"
)
var (