Skip to content

Instantly share code, notes, and snippets.

View aaronbbrown's full-sized avatar

Aaron Brown aaronbbrown

View GitHub Profile
@aaronbbrown
aaronbbrown / gist:4001420
Created November 2, 2012 13:38
Debugging ERB Templates

Some tips on debugging ERB Templates

Convert the template to a ruby file

$ erb -x -T - file.erb > file.rb

Open the file. At the bottom, you'll see:

; _erbout
@aaronbbrown
aaronbbrown / Dockerfile
Last active April 14, 2017 23:45
Dockerfile ARGs vs ENVs
FROM alpine
ENV MYENV="THIS IS AN ENV VARIABLE"
ARG MYARG="THIS IS A BUILD ARGUMENT"
RUN echo "BUILD MYENV: '$MYENV' MYARG: '$MYARG'"
CMD echo "RUN MYENV: '$MYENV' MYARG: '$MYARG'"
@aaronbbrown
aaronbbrown / service-checklist.md
Created September 12, 2016 20:45 — forked from acolyer/service-checklist.md
Internet Scale Services Checklist

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@aaronbbrown
aaronbbrown / gist:5216957
Created March 21, 2013 21:29
Vagrantfile for chef solo
Vagrant::Config.run do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "opscode-centos63"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
@aaronbbrown
aaronbbrown / iam.md
Last active December 11, 2015 11:48
Using IAM

Installation and Setup

Install the AWS IAM tools:

Homebrew:

brew install aws-iam-tools

@aaronbbrown
aaronbbrown / fix_shitty_csv.rb
Created November 19, 2012 21:13
Fixing broken CSV data
#!/usr/bin/env ruby
require 'pp'
require 'csv'
require 'logger'
def join_and_quote ( a )
a.to_csv(:row_sep => "\r\n", :quote_char => '"')
end
@aaronbbrown
aaronbbrown / gist:3707263
Created September 12, 2012 15:10
nginx gzip HTTP/1.0 vs HTTP/1.1

HTTP/1.0 request

$ curl  -sv0IH 'Accept-Encoding: gzip' -H 'Host: www.ideeli.com' http://www.ideeli.com/welcome?MuttAndJeff=1
* About to connect() to www.ideeli.com port 80 (#0)
*   Trying 208.39.105.3...
* connected
* Connected to www.ideeli.com (208.39.105.3) port 80 (#0)
> HEAD /welcome?MuttAndJeff=1 HTTP/1.0
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Accept: */*
@aaronbbrown
aaronbbrown / hashsub.rb
Created August 29, 2012 15:58
Subtract Hashes
#!/usr/bin/env ruby
require 'pp'
class Hash
def subtract (h)
result = {}
self.each do |k,v|
result[k] = (self[k] - h[k]) if h[k]
end
result
@aaronbbrown
aaronbbrown / count_queries.rb
Created August 17, 2012 16:58
count queries
#!/usr/bin/env ruby
require 'pp'
h = { :select => 0, :insert => 0, :delete => 0, :update => 0}
ARGF.each do |line|
case line
when /SELECT.*FROM/i then
h[:select] += 1
when /INSERT.*INTO/i then
@aaronbbrown
aaronbbrown / gist:2966320
Created June 21, 2012 15:12
get ec2 volumes from md device
def get_volumes (mount = nil)
return [] unless @ec2_instance_id
mount ||= @datadir
vols = []
devs = get_devs(mount)
instance = @ec2.instances[@ec2_instance_id]
vols = instance.block_device_mappings.map { |dev,attach| attach.volume.id if devs.include?(dev) }.compact
return vols
end