Skip to content

Instantly share code, notes, and snippets.

View woods's full-sized avatar

Scott Woods woods

View GitHub Profile
# Allow access to the vault service from the public and private subnets
# Note that this doesn't allow access from the internet; it just allows
# traffic over the private network from hosts that reside in either of our
# two subnets.
resource "aws_security_group_rule" "vault" {
security_group_id = "${aws_security_group.security_group.id}"
type = "ingress"
from_port = 8200
to_port = 8200
protocol = "tcp"
@woods
woods / purge.sh
Last active May 31, 2019 22:17
Purge unused kernel packages on Ubuntu 14.04
# Get all patch versions of all kernels on the system
all_kernel_patch_versions=$( dpkg -l | egrep 'linux-headers-3.13.0-[0-9]+-generic' | awk -F '-' '{print $4}' | sort -n )
# Exclude any kernels that are in use (hard coded; you must CUSTOMIZE THIS PER MACHINE)
unused_kernel_patch_versions=$( echo "$all_kernel_patch_versions" | egrep -v '1[67]' )
for n in $unused_kernel_patch_versions ; do
echo
echo "========== $n ========="
echo
@woods
woods / order.html
Created October 25, 2018 20:44
Code snippet for purple lizard order checkout page (just the total amount)
<tr>
<td colspan="4" class="align_right"><strong>{{ 'customer.order.total' | t }}</strong></td>
<td class="text-right"><strong>{{ order.total_price | money }} {{ order.currency }}</strong></td>
</tr>
@woods
woods / command.bash
Created October 6, 2018 13:40
Selectively remove old kernels and source
for n in 57 61 68 77 79 83 85 86 87 88 91 92 93 95 96 98 100 101 103 105 106 107 108 109 110 111 112 113 115 116
do
apt-get purge -y \
linux-headers-3.13.0-$n \
linux-headers-3.13.0-${n}-generic \
linux-image-3.13.0-${n}-generic \
linux-image-extra-3.13.0-${n}-generic
done
@woods
woods / specs.md
Last active November 7, 2017 16:29
West Arete's spec layout

Over time, West Arete has developed a convention for how we organize our spec directories. This arrangement has been very successful for us over many years and many projects. We'd love to extract it into some kind of framework/gem, but have never managed/invested to do so. So at the very least we can share this writeup of what we've found to be useful, in the hope that it's useful to others.

The top level of our spec directory looks like this:

spec/
  spec_helper.rb
@woods
woods / command.bash
Created June 12, 2017 14:01
Get IP ranges of AWS Route53 health checkers
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json \
| jq '.prefixes | map(select(.service=="ROUTE53_HEALTHCHECKS")) | map(.ip_prefix)'
### Keybase proof
I hereby claim:
* I am woods on github.
* I am woods (https://keybase.io/woods) on keybase.
* I have a public key ASBRwmuep3o_XIJa0bbb-0xxkdgyxWqCt-SEvK1MHlkjoQo
To claim this, I am signing this object:
@woods
woods / friendly_urls.markdown
Last active August 17, 2016 00:28 — forked from cdmwebs/friendly_urls.markdown
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

<!DOCTYPE html>
<HTML>
<head>
<title id="PageTitle">Allegheny County Assessment</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR" />
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE" />
<meta content="JavaScript" name="vs_defaultClientScript" />
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
@woods
woods / check_vault_seal_status.sh
Last active April 6, 2022 10:10
Nagios plugin to make sure Hashicorp Vault is unsealed
#!/bin/bash
# Assumes the following:
# - The `curl` package is installed
# - Vault is listening on the standard port 8200
# - Vault is using https with a valid certificate
# The hostname of the vault server that we're supposed to check.
hostname=$1