Skip to content

Instantly share code, notes, and snippets.


Paul Annesley pda

Block or report user

Report or block pda

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
pda /
Last active Nov 12, 2018
Demonstrate that queue time is not included in Unicorn's request timeout

Unicorn timeout test

Demonstrate that queue time is not included in Unicorn's timeout


$ ruby unicorn_timeout_test.rb
starting unicorn {:worker_processes=>2, :timeout=>3}
[client] concurrently requesting /sleep/6, /sleep/4, /sleep/2, /sleep/0
pda / Gemfile
Created Jan 23, 2017
Sidekiq::Web v4.2 (no longer on Sinatra) with GitHub OAuth
View Gemfile
source ""
# ruby web server; run Sidekiq::Web with e.g. `puma --port=80`
gem "puma"
# provides Sidekiq::Web monitoring UI
gem "sidekiq", "~> 4.2"
pda / rack_header_renamer.rb
Created May 25, 2016
RackHeaderRenamer middleware for Rack; copy a request header to a different name before Rails etc sees it. e.g. config.middleware.insert(0, RackHeaderRenamer, "X-Varnish-Proto" => "X-Forwarded-Proto")
View rack_header_renamer.rb
class RackHeaderRenamer
# mapping example, sets/overwrites second header with first:
# {"X-Varnish-Proto" => "X-Forwarded-Proto"}
def initialize(app, mapping)
@app = app
@mapping = mapping
def call(env)
View code.rb
require "bcrypt"
module GoTipping
class UserAuthenticator
def initialize(organisation, username, finder)
@organisation = organisation
@username = username
@finder = finder
pda /
Last active Mar 15, 2017

Keybase proof

I hereby claim:

  • I am pda on github.
  • I am pda ( on keybase.
  • I have a public key whose fingerprint is C01A 62C6 7093 CE6A 2C34 299A C902 25CE B876 8E7B

To claim this, I am signing this object:

pda / race.rb
Created Nov 18, 2014
thumbor_aws async/blocking debugging.
View race.rb
#!/usr/bin/env ruby
require "open-uri"
require "benchmark"
def main
urls = ARGV
results =
pda /
Last active Aug 29, 2015
For EC2 instances with two instance volumes, use LVM to combine them into a single /mnt
set -euo pipefail
set -x
pda / base_script.rb
Created Jun 3, 2014
BaseScript; small base for CLI scripts; signal handling, indented logging, colors ticks/crosses, injectable args/IO.
View base_script.rb
# A base class for implementing CLI scripts.
# ARGV and in/out IO's are injected, so can be mocked & tested.
# Basic signal handling by calling exit_on_signals inside work loops etc.
# Requires Ruby 2.0.0+ for keyword args etc.
class BaseScript
INDENT = " "
def initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr)
pda / git-push-as
Created Apr 27, 2014
git-push-as: pull request without creating branches.
View git-push-as
#!/bin/bash -e
# Push local changes on the current branch as a new branch, then
# reset the local branch back to its remote tracking branch.
# This enables a fast workflow:
# 10 `git commit` one or more changes to master.
# 20 `git push-as -p new-feature`
# 30 goto 10
pda /
Created Mar 21, 2014
Docker script to initialize MySQL database; auth from remote hosts.
# Initialize MySQL database.
# ADD this file into the container via Dockerfile.
# Assuming you specify a VOLUME ["/var/lib/mysql"] or `-v /var/lib/mysql` on the `docker run` command…
# Once built, do e.g. `docker run your_image /path/to/`
# Again, make sure MySQL is persisting data outside the container for this to have any effect.
set -e
set -x
You can’t perform that action at this time.