Skip to content

Instantly share code, notes, and snippets.

View mark-rushakoff's full-sized avatar
🙈
I'm not watching GitHub notifications. Contact me directly to get my attention.

Mark Rushakoff mark-rushakoff

🙈
I'm not watching GitHub notifications. Contact me directly to get my attention.
View GitHub Profile
@mark-rushakoff
mark-rushakoff / Dockerfile
Created September 18, 2013 07:11
cf-deployer Dockerfile
FROM ubuntu:precise
MAINTAINER Mark Rushakoff <mark.rushakoff@gmail.com>
RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y build-essential libffi-dev libgdbm-dev libncurses5-dev libreadline-dev libssl-dev libyaml-dev zlib1g-dev
RUN apt-get install -y wget
@mark-rushakoff
mark-rushakoff / log.md
Created November 26, 2013 07:03
Benchmarking NATS connectivity in a CloudFoundry deployment

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):

@mark-rushakoff
mark-rushakoff / results.txt
Last active April 1, 2016 15:55
Which is faster: `a := make([]int, size); a[i] = val`, or `a := make([]int, 0, size); a = append(a, val)`?
→ 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 / results.txt
Created December 19, 2015 18:48
Which is faster: `s += str` or `buf.WriteString(str) ... buf.String()`?
PASS
BenchmarkStringConcat-4 2000000 3901 ns/op
BenchmarkByteBuffer-4 10000000 966 ns/op
@mark-rushakoff
mark-rushakoff / Dockerfile_client
Created August 18, 2016 04:31
Simple micro-load generator for InfluxDB using docker-compose
FROM alpine:latest
RUN apk add --no-cache \
bash \
curl
COPY ./client.sh /client.sh
CMD ["/client.sh"]
@mark-rushakoff
mark-rushakoff / fields.go
Created September 1, 2016 16:28
Result parsing for InfluxDB
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 / backup_restore.bash
Last active November 16, 2020 14:53
Backup and restore influxdb inside Docker
#!/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 / trimpkg.go
Created September 19, 2019 17:25
Print out all the files required to build a single Go package.
package main
import (
"fmt"
"os"
"golang.org/x/tools/go/packages"
)
func main() {
@mark-rushakoff
mark-rushakoff / gist:65d587799de9f3f353055333ed907807
Created September 15, 2020 15:36
Find packages that are declared in your project but not referenced anywhere
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 / gist:d84957d47ebbdfabaafbfdf9e476bef7
Last active September 16, 2020 20:06
List all imports of your project, by count
go list -json ./... | jq -r '.Imports | map(select(contains("."))) | join("\n")' | sort | uniq -c | sort -n