This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ec2ssh() { | |
# ec2-54-187-110-140.us-west-2.compute.amazonaws.com -> 54-187-110-140 | |
hostname=`echo $1 | perl -pe 's/\..*//; s/ec2-//; s/-/./g'` | |
ssh $hostname | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install sysbench with | |
# sudo yum --enablerepo=epel install -y sysbench | |
targetDir=/data/benchmark # pick a directory inside your target file system | |
fileSize=300G # pick large enough size that you aren't using FS cache effectively | |
threads=128 | |
test=rndrw # can also use rndrd | |
blockSize=4096 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
With confd sometimes you will want to join a bunch of keys together into a line with comma separated values. Here is a template snippet to do that: | |
servers={{range $index,$server := .myapp_servers}}{{if $index}},"{{$server.Value}}"{{else}}"{{$server.Value}}"{{end}}{{end}} | |
Credit for the technique goes to Jan Newmarch's tutorial page at http://jan.newmarch.name/go/template/chapter-template.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# more detailed instructions are at http://dev.iron.io/mq-onpremise/getting_started | |
# Get a coreos VM up | |
git clone https://github.com/coreos/coreos-vagrant.git | |
cd coreos-vagrant/ | |
vagrant up | |
# get into the coreos box | |
vagrant ssh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Loading function'); | |
const https = require('https'); | |
const url = require('url'); | |
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration | |
const slack_url = 'https://hooks.slack.com/services/...'; | |
const slack_req_opts = url.parse(slack_url); | |
slack_req_opts.method = 'POST'; | |
slack_req_opts.headers = {'Content-Type': 'application/json'}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// This command will allow you to provision, delete, describe, or estimate the cost of the specified CloudFormation template. | |
// | |
// Once compiled use the -help flag for details. | |
import ( | |
"bufio" | |
"flag" | |
"fmt" | |
"io/ioutil" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GOEDITOR="/Applications/Atom.app" | |
# practice does the following | |
# creates a new directory named after the project | |
# creates a file under that directory named $project.go with a small template | |
# NOTE: specifically not using main.go so I can distinguish the files in my editor tabs | |
# opens the file in my editor | |
# changes to the new project directory | |
practice() { | |
if [ $# -ne 1 ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// These benchmarks are used to compare how fast it is to read a set of space separated numbers from a string | |
// using different techniques. | |
// The primary motiviation for this came when writing some code for hackerrank and realizing that the parsing of numbers | |
// for large input sets was actually the bottleneck | |
// | |
// For stable results, it is recommended to increase the runtime allocated for benchmarking, such as | |
// go test -v -run none -bench . -benchtime 5s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package lambda helps create workers that run in AWS’ Lambda service. | |
// The Lambda service is designed to run Node.js programs, so we have a very thin | |
// Node.js wrapper which is essentially an adapter between our Go worker programs | |
// and Lambda. Lambda runs our Node.js wrapper/adapter which then in turn runs | |
// our Go worker programs as child processes, communicating with them via stdio pipes | |
// and Unix exit codes. | |
// | |
// The interaction between the Lambda wrapper and our Go programs works like this: | |
// | |
// * The Node.js function is invoked by Lambda. Lambda passes an `event` parameter to |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
go test -run none -bench . -benchtime 3s -benchmem | |
testing: warning: no tests to run | |
PASS | |
BenchmarkAlgorithmOne-4 1000000 4719 ns/op 53 B/op 2 allocs/op | |
BenchmarkAlgorithmTwo-4 3000000 1645 ns/op 0 B/op 0 allocs/op | |
BenchmarkAlgorithmThree-4 2000000 2572 ns/op 16 B/op 1 allocs/op | |
BenchmarkAlgorithmFour-4 1000000 3368 ns/op 1 B/op 1 allocs/op | |
BenchmarkAlgorithmFive-4 1000000 3423 ns/op 1 B/op 1 allocs/op |
OlderNewer