Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Reagan reagent

View GitHub Profile
View 01-links.md
@reagent
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)
end
def self.sanitize(url)
new(url).to_s
end
def initialize(url)
@reagent
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
end
@reagent
reagent / 01_basic.go
Last active Aug 27, 2020
Custom HTTP Routing in Go
View 01_basic.go
package main
import (
"io"
"log"
"net/http"
)
func main() {
View libcurl-curb-installation.md

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
end
uncompressed_bytes = `curl "#{url}" --silent --write-out "%{size_download}\n" --output /dev/null`
@reagent
reagent / downgrade.sh
Last active Oct 30, 2019
Downgrade Apache + PHP on Ubuntu 14.04
View downgrade.sh
cat <<EOF >> /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu precise main restricted universe
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe
deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
EOF
apt-get update
apt-get purge \
apache2 \
@reagent
reagent / whitespace.sh
Last active Aug 15, 2019
Convert whitespace from tabs to 2 spaces
View whitespace.sh
#!/bin/bash
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
reagent / .gitignore
Last active May 14, 2020
Curses Windowing Example
@reagent
reagent / .gitignore
Last active May 13, 2020
Curses + C Example
You can’t perform that action at this time.