Skip to content

Instantly share code, notes, and snippets.

💾
Formatting…

Paul Annesley pda

💾
Formatting…
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
pda / README.md
Last active Nov 12, 2018
Demonstrate that queue time is not included in Unicorn's request timeout
View README.md

Unicorn timeout test

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

Output

$ ruby unicorn_timeout_test.rb
starting unicorn {:worker_processes=>2, :timeout=>3}
[client] concurrently requesting /sleep/6, /sleep/4, /sleep/2, /sleep/0
@pda
pda / Gemfile
Created Jan 23, 2017
Sidekiq::Web v4.2 (no longer on Sinatra) with GitHub OAuth
View Gemfile
source "https://rubygems.org"
# ruby web server; run Sidekiq::Web with e.g. `puma --port=80`
# https://github.com/puma/puma
gem "puma"
# provides Sidekiq::Web monitoring UI
# https://github.com/mperham/sidekiq/wiki/Monitoring
gem "sidekiq", "~> 4.2"
@pda
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
end
def call(env)
View code.rb
require "bcrypt"
module GoTipping
class UserAuthenticator
def initialize(organisation, username, finder)
@organisation = organisation
@username = username
@finder = finder
end
@pda
pda / keybase.md
Last active Mar 15, 2017
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am pda on github.
  • I am pda (https://keybase.io/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
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 = Queue.new
@pda
pda / ec2-lvm.sh
Last active Aug 29, 2015
For EC2 instances with two instance volumes, use LVM to combine them into a single /mnt
View ec2-lvm.sh
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
set -x
DEVICE_B="/dev/xvdb"
DEVICE_C="/dev/xvdc"
VG_NAME="ephemeral"
LV_NAME="ephemeral"
DEVICE_LV="/dev/$VG_NAME/$LV_NAME"
@pda
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
EXIT_SUCCESS = 0
INDENT = " "
def initialize(argv, stdin: $stdin, stdout: $stdout, stderr: $stderr)
@pda
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
pda / docker-mysql-initialize.sh
Created Mar 21, 2014
Docker script to initialize MySQL database; auth from remote hosts.
View docker-mysql-initialize.sh
#!/bin/bash
# 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/docker-mysql-initialize.sh`
# 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.