Skip to content

Instantly share code, notes, and snippets.

reagent / vcr_strip_credentials_from_params.rb
Created Aug 8, 2019
Example of stripping credentials / sensitive data from GET params when using VCR (5.0.x)
View vcr_strip_credentials_from_params.rb
class URLSanitizer
def self.equal?(first, second)
new(first) == new(second)
def self.sanitize(url)
def initialize(url)
reagent / migrator.rb
Created Nov 21, 2017
DIY migrations in Ruby
View migrator.rb
require 'pg'
require 'uri'
class Migrator
class Migration
def initialize(connection, path)
@connection, @path = connection, path
reagent /
Last active Jun 14, 2022
Custom HTTP Routing in Go

Custom HTTP Routing in Go

Basic Routing

Responding to requests via simple route matching is built in to Go's net/http standard library package. Just register the path prefixes and callbacks you want invoked and then call the ListenAndServe to have the default request handler invoked on each request. For example:

package main

import (

Installing libcurl with Updated OpenSSL Support

If your Linux distribution is so out of date that you can no longer install updated patches, you'll typically need to either reach for an unsupported package or install the software via source. Additionally, I didn't want to interfere with installed software in fear of rendering the system unusable.

Become Root and Grab Tarballs

You're going to be installing stuff that requires root access, so it's easier to just be able to do it when you want without having to worry about using sudo and permissions. Be careful you don't delete anything you can't recover

$ sudo su - 
View check-gzip
#!/usr/bin/env ruby
url = ARGV.pop
if url.to_s.strip.length == 0
puts "Error: Please supply a URL"
exit 1
uncompressed_bytes = `curl "#{url}" --silent --write-out "%{size_download}\n" --output /dev/null`
reagent /
Last active Oct 30, 2019
Downgrade Apache + PHP on Ubuntu 14.04
cat <<EOF >> /etc/apt/sources.list
deb precise main restricted universe
deb precise-updates main restricted universe
deb precise-security main restricted universe multiverse
apt-get update
apt-get purge \
apache2 \
reagent /
Last active Aug 15, 2019
Convert whitespace from tabs to 2 spaces
set -e # fail on nonzero status
cd $1
files=`find . \
-not \( -path ./vendor -prune \) \
-not \( -path ./tmp -prune \) \
-name '*.html' -o -name '*.js' -o -name '*.coffee' -o \
reagent / .gitignore
Last active Jul 30, 2022
Curses Windowing Example
reagent / .gitignore
Last active Sep 13, 2021
Curses + C Example