Skip to content

Instantly share code, notes, and snippets.

# you can make a text file of request times (in ms, one number per line) and import it here, or you can use a probability distribution to simulate request times (see below where setting req_durations_in_ms)
# rq = read.table("~/Downloads/request_times.txt", header=FALSE)$V1
# argument notes:
# parallel_router_count is only relevant if router_mode is set to "intelligent"
# choice_of_two, power_of_two, and unicorn_workers_per_dyno are only relevant if router_mode is set to "naive"
# you can only select one of choice_of_two, power_of_two, and unicorn_workers_per_dyno
run_simulation = function(router_mode = "naive",
reqs_per_minute = 9000,
@iw
iw / amazon_sender.py
Last active August 29, 2015 14:06 — forked from amix/amazon_sender.py
# -*- coding: utf-8 -*-
"""
amazon_sender.py
~~~~~~~~
Python helper class that can send emails using Amazon SES and boto.
The biggest feature of this class is that encodings are handled properly.
It can send both text and html emails.
This implementation is using Python's standard library (which opens up for a lot more options).
require 'rubygems'
require 'chef/encrypted_data_bag_item'
secret = Chef::EncryptedDataBagItem.load_secret('data_bag_key')
data = {"id" => "mysql", "root" => "some secret password"}
encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
FileUtils.mkpath('data_bags/passwords')
File.open('data_bags/passwords/mysql.json', 'w') do |f|
f.print encrypted_data.to_json
@iw
iw / KeyBindings.json
Created November 1, 2012 12:56 — forked from yorkxin/KeyBindings.json
My Sublime Text 2 Config
/* Default (OS X).sublime-keymap */
/* Key Bindings - User */
[
{ "keys": ["ctrl+shift+."], "command": "erb" },
{ "keys": ["super+shift+t"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
{ "keys": ["ctrl+super+r"], "command": "reveal_in_side_bar" },
// swap normal paste and paste-with-indention
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" },
@iw
iw / assets.rake
Created October 4, 2012 19:05 — forked from scottwb/assets.rake
Rake task to rebuild all JS/CSS assets with Compass/Jammit, including workaround for the bugs within.
namespace :assets do
task :rebuild do
# Config the base names of all the jammit CSS packages you have defined
# in assets.yml. Could probably parse assets.yml to get this if
# we wanted to.
packages = ['common']
# This is because on OS X, you have to put an explicit empty string to the
# required extension argument with the -i parameter, but on Linux you
# do not.
@iw
iw / gist:1286853
Created October 14, 2011 11:23 — forked from fennb/gist:1283573
nginx microcaching config example
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# Virtualhost/server configuration
server {
listen 80;
server_name yourhost.domain.com;
# Define cached location (may not be whole site)
@iw
iw / gist:1277558
Created October 11, 2011 08:20 — forked from mitchellh/gist:1277049
Configure Vagrant VM to use Host DNS for VPN
Vagrant::Config.run do |config|
# ...
config.vm.customize do |vm|
# Use the host resolver for DNS so that VPN continues
# to work within the VM
vm.network_adapters.each do |na|
if na.enabled? && na.nat_driver
na.nat_driver.dns_use_host_resolver = true
end
@iw
iw / lxc.rb
Created June 16, 2011 19:54
Setup an lxc-container (chef recipe)
package 'debootstrap'
package 'apt-cacher-ng'
package 'inotify-tools'
include_recipe 'lxc::manage'
include_recipe 'lxc::network_bridge'
include_recipe 'lxc::dns'
host = node[:container]
@iw
iw / gen_pipe.erl
Created June 16, 2011 14:29 — forked from krestenkrab/gen_pipe.erl
Ramblings on a gen_pipe DSL for riak_pipe
%%
%% Generic riak_pipe_vnode_worker worker, so you can write multiple fittings in one file.
%%
%% Each fitting is a function which must accept
%%
%% ImplFun(init, InitArg) -> {ok, State}
%% ImplFun({process, Input}, State) -> {ok, State} | forward_preflist
%% ImplFun(done, State) -> ok
%%
%% gen_pipe also has some more friendly API