Skip to content

Instantly share code, notes, and snippets.

Gene Wood gene1wood

Block or report user

Report or block gene1wood

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
gene1wood /
Created Jan 31, 2014
A parallel ssh command which checks the last chef run and runs it again if there was a problem.
# `get_hosts $stack` returns the ips of the instances in the named stack
# the "-t -t" extra-args works around the issue of running sudo without a tty
# the "--force-formatter" tells chef-solo to still output what it's doing even though it has no tty
pssh --host="`get_hosts $stack`" --timeout=0 --inline --par=10 --extra-args='-t -t -o StrictHostKeyChecking=no' --user=ec2-user 'if tail -1 /var/log/chef.log | grep FATAL; then sudo chef-solo -c /etc/chef/solo.rb -j /etc/chef/node.json --force-formatter; fi'
View bam_next_meeting_widget.html
<div class="textwidget"><span id="nextmeeting">The next meeting will be held at Linden Street Brewery </span><span id="nojavascript">on the second Thursday of the month</span>. Social starts at 7:00pm, meeting starts at 7:30pm.
// First, checks if it isn't implemented yet.
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
for i in $(eval echo {1..$1})
echo $(date +"%T")
if ! curl -v "" -o /dev/null &>/tmp/c.out; then
cat /tmp/c.out
echo "success"
gene1wood / maint.conf
Last active Aug 29, 2015
Apache config to serve a maintenance page
View maint.conf
ServerAdmin root@localhost
DocumentRoot "/var/www"
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} !=503
RewriteRule ^(.*)$ /$1 [R=503,L]
ErrorDocument 503 /maint.html
Alias /maint.html /var/www/html/maint.html
gene1wood / maint.html
Created Feb 15, 2014
A maintenance page
View maint.html
<html><head><title>This site is undergoing planned maintenance</title></head><body><h1>This site is undergoing planned maintenance</h1><p>This maintenance which begain Saturday February 22nd should conclude around 2pm</p></body></html>
gene1wood /
Last active Aug 29, 2015
An example of how to use a config file which is overridden by command line arguments in Python.
#!/usr/bin/env python
import ConfigParser
import argparse
import logging
import os
def type_loglevel(level):
result = getattr(logging, level.upper())
gene1wood /
Last active Aug 29, 2015
Determine the modulus of a certificate, key or certificate request and output it for the purposes of comparing them to confirm they match
if grep -- ' PRIVATE KEY-' "$1" >/dev/null; then
modulus="`openssl rsa -noout -modulus -in "$1" | md5sum | awk '{print $1}'`"
elif grep -- '-BEGIN CERTIFICATE REQUEST-' "$1" >/dev/null; then
modulus="`openssl req -noout -modulus -in "$1" | md5sum | awk '{print $1}'`"
elif grep -- '-BEGIN CERTIFICATE-' "$1" >/dev/null; then
modulus="`openssl x509 -noout -modulus -in "$1" | md5sum | awk '{print $1}'`"
gene1wood / tail-chef-log-across-hosts.bash
Created May 27, 2014
Tail the chef log across multiple hosts in parallel, exiting when the chef run completes
View tail-chef-log-across-hosts.bash
hostlist="`get_hosts $stack`"
pssh -O StrictHostKeyChecking=no \
--print \
--user ec2-user \
--host "$hostlist" \
--timeout=0 \
--par=20 \
'while true; do if ! tail -1 /var/log/chef.log | sed -e "s/^/`hostname`/" | grep -v "`date +%Y-%m-%d`.*Report handlers complete"; then tail -1 /var/log/chef.log | grep "`date +%Y-%m-%d`.*Report handlers complete"; break; fi; sleep 2; done'
View pssh-with-sudo.bash
# The key to using pssh and sudo is the `--extra-args='-t -t' trick
pssh -H "`cat hostlist.txt`" \
--user ec2-user \
--timeout=0 \
--inline \
--par=10 \
--extra-args='-t -t -o StrictHostKeyChecking=no' \
'sudo cat /etc/shadow'
gene1wood /
Created Jun 13, 2014
Some old bash functions for doing parallel ssh and scp, pushing and fetching files through jump hosts and deep escaping
function multiscp {
tempfiletemplate="/tmp/`basename $0`-XXXXXX"
pidlistfile="`mktemp $tempfiletemplate`"
for host in $hostlist; do
scp $filename $host: &
echo "$!" >>$pidlistfile
You can’t perform that action at this time.