Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Rushakoff mark-rushakoff

View GitHub Profile
View mark-rushakoff_work.json
{
"version": 1,
"notes": "Planck Work Map v1",
"documentation": "\"This file is a QMK Configurator export. You can import this at <https://config.qmk.fm>. It can also be used directly with QMK's source code.\n\nTo setup your QMK environment check out the tutorial: <https://docs.qmk.fm/#/newbs>\n\nYou can convert this file to a keymap.c using this command: `qmk json2c {keymap}`\n\nYou can compile this keymap using this command: `qmk compile {keymap}`\"\n",
"keyboard": "planck/rev6",
"keymap": "mark-rushakoff_work",
"layout": "LAYOUT_ortho_4x12",
"layers": [
[
"KC_ESC",
@mark-rushakoff
mark-rushakoff / gist:d84957d47ebbdfabaafbfdf9e476bef7
Last active Sep 16, 2020
List all imports of your project, by count
View gist:d84957d47ebbdfabaafbfdf9e476bef7
go list -json ./... | jq -r '.Imports | map(select(contains("."))) | join("\n")' | sort | uniq -c | sort -n
@mark-rushakoff
mark-rushakoff / gist:65d587799de9f3f353055333ed907807
Created Sep 15, 2020
Find packages that are declared in your project but not referenced anywhere
View gist:65d587799de9f3f353055333ed907807
go list -test ./... | sort -u > /tmp/full_list_with_tests
go list -test -json ./... | jq -r '.Deps | map(select(startswith("github.com/YOUR/PROJECT/"))) | join("\n")' | sort -u > /tmp/is_depended_with_tests
comm -23 /tmp/full_list_with_tests /tmp/is_depended_with_tests | grep -v '.test$'
@mark-rushakoff
mark-rushakoff / trimpkg.go
Created Sep 19, 2019
Print out all the files required to build a single Go package.
View trimpkg.go
package main
import (
"fmt"
"os"
"golang.org/x/tools/go/packages"
)
func main() {
@mark-rushakoff
mark-rushakoff / backup_restore.bash
Last active Nov 16, 2020
Backup and restore influxdb inside Docker
View backup_restore.bash
#!/bin/bash
set -e
# Default working directory to current directory, but allow override via WORKDIR environment variable.
WORKDIR=${WORKDIR:-$PWD}
NOW="$(date +%s)"
INFLUXDIR="$WORKDIR/influxdb-$NOW"
BACKUPDIR="$WORKDIR/backup-$NOW"
@mark-rushakoff
mark-rushakoff / fields.go
Created Sep 1, 2016
Result parsing for InfluxDB
View fields.go
package resultparser
import (
"encoding/json"
"fmt"
)
// Field is implemented by TimeField, IntField, FloatField, and StringField
type Field interface {
columnIndex([]string) (int, error)
@mark-rushakoff
mark-rushakoff / Dockerfile_client
Created Aug 18, 2016
Simple micro-load generator for InfluxDB using docker-compose
View Dockerfile_client
FROM alpine:latest
RUN apk add --no-cache \
bash \
curl
COPY ./client.sh /client.sh
CMD ["/client.sh"]
@mark-rushakoff
mark-rushakoff / results.txt
Created Dec 19, 2015
Which is faster: `s += str` or `buf.WriteString(str) ... buf.String()`?
View results.txt
PASS
BenchmarkStringConcat-4 2000000 3901 ns/op
BenchmarkByteBuffer-4 10000000 966 ns/op
@mark-rushakoff
mark-rushakoff / results.txt
Last active Apr 1, 2016
Which is faster: `a := make([]int, size); a[i] = val`, or `a := make([]int, 0, size); a = append(a, val)`?
View results.txt
→ go test -bench=. -benchmem -benchtime=5s
PASS
BenchmarkMakeLen_Index8-4 100000000 70.7 ns/op 64 B/op 1 allocs/op
BenchmarkMakeLen_Index16-4 100000000 90.7 ns/op 128 B/op 1 allocs/op
BenchmarkMakeLen_Index32-4 50000000 132 ns/op 256 B/op 1 allocs/op
BenchmarkMakeLen_Index64-4 30000000 212 ns/op 512 B/op 1 allocs/op
BenchmarkMakeLen_Index128-4 20000000 362 ns/op 1024 B/op 1 allocs/op
BenchmarkMakeLen_Index256-4 10000000 675 ns/op 2048 B/op 1 allocs/op
BenchmarkMakeLen_Index512-4 5000000 1371 ns/op 4096 B/op 1 allocs/op
BenchmarkMakeLen_Index1024-4 3000000 2573 ns/op 8192 B/op 1 allocs/op
@mark-rushakoff
mark-rushakoff / log.md
Created Nov 26, 2013
Benchmarking NATS connectivity in a CloudFoundry deployment
View log.md

On nats_z2/0 (only NATS server):

$ sudo su
$ cd /var/vcap/bosh/bin
$ ./nats-server --port 12121 --user foo --pass bar

On api_z1/1 (Working CC, different AZ from NATS):