Skip to content

Instantly share code, notes, and snippets.

View msmith's full-sized avatar

Michael Smith msmith

  • WP Engine
  • Austin, TX
View GitHub Profile
@msmith
msmith / benchmark.md
Created November 18, 2019 16:36
Append with preallocated capacity

Benchmarking result

$ go test -bench=.
goos: darwin
goarch: amd64
BenchmarkGrowZero-12            	 3067180	       383 ns/op
BenchmarkGrowPreallocated-12    	 7515637	       158 ns/op
PASS
ok _/Users/msmith/Desktop/test-alloc	4.059s
@msmith
msmith / bad.go
Last active July 3, 2019 21:07
Avoiding global state
package main
import "fmt"
var Enabled bool
func LogEvent(msg string) {
if Enabled {
fmt.Println(msg)
}
### Keybase proof
I hereby claim:
* I am msmith on github.
* I am mr_smith (https://keybase.io/mr_smith) on keybase.
* I have a public key ASBvBLhaf8T72X_hJezYG_7kSKmlEKCbAdKuF7l_QcvRsQo
To claim this, I am signing this object:
@msmith
msmith / couchdb-ec2-install.sh
Created August 25, 2011 17:26
Set up CouchDB on EC2
#!/bin/bash
#
# This script installs and configures couchdb on a fresh Amazon Linux AMI instance.
#
# Must be run with root privileges
# Tested with Amazon Linux AMI release 2011.02.1.1 (ami-8c1fece5)
#
export BUILD_DIR="$PWD"