Skip to content

Instantly share code, notes, and snippets.

View GeorgeDewar's full-sized avatar

George Dewar GeorgeDewar

  • Wellington, New Zealand
View GitHub Profile
#!/usr/bin/ruby
require 'json'
require 'term/ansicolor'
require 'optparse'
require 'httparty'
require 'set'
include Term::ANSIColor
@GeorgeDewar
GeorgeDewar / sydi2md
Last active August 29, 2015 13:57
Ruby script for converting SYDI XML files to readable Markdown
#!/usr/bin/env ruby
require 'xmlsimple'
require 'pp'
# Table widths will be padded in multiples of 10, so that small increases in maximum length will not always
# modify every line of the table (by increasing the width of the column)
PAD_MULTIPLE=10
# Map one or more hashes to strings within a table row by composing a string from the values in the hash. Fields
@GeorgeDewar
GeorgeDewar / vpn
Last active October 2, 2016 20:13
#!/bin/bash
red='\e[0;31m'
green='\e[0;32m'
NC='\e[0m'
set -e
function usage {
echo Enable/Disable routing all traffic through VPN, and
@GeorgeDewar
GeorgeDewar / killnet
Last active August 29, 2015 13:56
Simulates network disconnection over SSH by dropping all traffic to/from any host other than the host calling the script
#!/bin/bash
#Determine IP of calling user
ssh_ip=`echo $SSH_CLIENT | awk '{ print $1}'`
if [ "$1" == "kill" ]; then
echo "Simulating network disconnection by dropping traffic from all hosts except $ssh_ip..."
#Default Policy to DROP all incoming traffic
@GeorgeDewar
GeorgeDewar / do-node
Last active August 29, 2015 13:56
Handy little script to shut down or boot up droplets on Digital Ocean - great for demonstrating redundant systems like Ceph, where similarly named nodes need to be killed and restarted during demonstrations.
#!/bin/bash
function usage {
echo "Shutdown and boot Digital Ocean droplets remotely, and simulate network disconnection"
echo
echo "Usage: $0 <kill/boot/killnet/resumenet> node1 [node2] [node3] [node...]"
exit 1
}
# Get settings and node IDs from files