Skip to content

Instantly share code, notes, and snippets.

@sheldonh
sheldonh / config.ru
Created Nov 14, 2019
Rack::RequestTimer
View config.ru
require "time"
module Rack
class RequestTimer
class Timer
FORMAT = "%0.3fms elapsed since %s" unless defined?(FORMAT)
View chruby-copy-gems.sh
#!/bin/sh
old_version=$1
new_version=$2
inventory=$(chruby-exec $old_version -- gem list -q | sed -e 's/^\([^ ]*\) (\(.*\))/\1:\2/' -e 's/[:,] */:/g')
for item in $inventory; do
gem=${item%%:*}
versions=${item#*:}
versions=$(echo $versions | sed -e 's/:/ /g')
View gist:337725ad15c5215108a3
### Keybase proof
I hereby claim:
* I am sheldonh on github.
* I am sheldonh (https://keybase.io/sheldonh) on keybase.
* I have a public key whose fingerprint is 07B7 6119 5FAD 8AAD EDAA 6F64 F42E 096D 615C 2D28
To claim this, I am signing this object:
View legacy_bootstrapping.feature
Feature: Legacy bootstrapping
As a legacy service component
In order to use the configuration service without changing hosting strategy
I want to bootstrap the configuration service from a file.
Scenario: Legacy bootstrapping
Given no environmental service configuration
And a legacy service configuration file
View legacy_bootstrapping.feature
Feature: Legacy bootstrapping
As a legacy service component
In order to use the configuration service without changing hosting strategy
I want to bootstrap the configuration service from a file.
Scenario: Legacy bootstrapping
Given no environmental service configuration
And a service configuration file
View hetzner.ovpn
client
proto tcp
dev tun
nobind
mssfix
remote vpn-router1.cpt4.host-h.net 443
resolv-retry infinite
script-security 1
@sheldonh
sheldonh / virtualbox-guest.sh
Last active Aug 29, 2015
Virtualbox guest setup
View virtualbox-guest.sh
#!/bin/sh -e
#
# wget -O virtualbox-guest.sh https://goo.gl/BYGYEx
# chmod +x virtualbox-guest.sh
# sudo ./virtualbox-guest.sh
#
if [ $(id -u) != 0 ]; then
echo "sudo, remember?" 1>&2
exit 1
fi
@sheldonh
sheldonh / setup.sh
Last active May 4, 2016
Desktop bootstrap
View setup.sh
#!/bin/sh
# 1. Install Google Chrome and LastPass
# 2. Fetch secrets from S3
# 3. Profit!
#
# To run:
#
# wget -O setup.sh https://goo.gl/htFGUu
# chmod +x setup.sh
@sheldonh
sheldonh / .bashrc
Created Apr 15, 2015
bash git prompt on Fedora
View .bashrc
if ! type __git_ps1 &> /dev/null && [ -e /usr/share/git-core/contrib/completion/git-prompt.sh ]; then
. /usr/share/git-core/contrib/completion/git-prompt.sh
fi
if type __git_ps1 &> /dev/null; then
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export GIT_PS1_SHOWCOLORHINTS=1
export PROMPT_DIRTRIM=2
export PROMPT_COMMAND='__git_ps1 "\w" "\\\$ "'
fi
View log_duration.coffee
# Logs timing of an operation:
#
# * Start a clock.
# * Calls the `operation`, passing in a `done` function that will:
# * Stop the clock.
# * Log the title of the operation with its elapsed duration and optional outcome.
# If the operation calls the `done` function with no outcome, "completed" is used.
#
# Example:
#