Skip to content

Instantly share code, notes, and snippets.

@fotinakis
fotinakis / Dockerfile
Created November 23, 2014 20:48
Docker + fig with mounted volume for dev environment (and correctly handles bundle install).
# Base image.
FROM fotinakis/baseimage-ruby:2.1.3
# System dependencies for gems.
RUN apt-get update
RUN apt-get install -y --no-install-recommends libmysqlclient-dev
# Add 'web' user which will run the application.
RUN adduser web --home /home/web --shell /bin/bash --disabled-password --gecos ""
@fotinakis
fotinakis / cancan_matchers.rb
Last active December 8, 2023 14:18
Custom rspec matcher for testing CanCan abilities
# Custom rspec matcher for testing CanCan abilities.
# Originally inspired by https://github.com/ryanb/cancan/wiki/Testing-Abilities
#
# Usage:
# should have_abilities(:create, Post.new)
# should have_abilities([:read, :update], post)
# should have_abilities({manage: false, destroy: true}, post)
# should have_abilities({create: false}, Post.new)
# should not_have_abilities(:update, post)
# should not_have_abilities([:update, :destroy], post)
# 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,