Skip to content

Instantly share code, notes, and snippets.

View bashtoni's full-sized avatar

Sam Bashton bashtoni

View GitHub Profile
@bashtoni
bashtoni / remove-mfa.sh
Created June 26, 2017 07:38
Remove MFA for a user
#!/bin/bash
if [ -n $1 ]; then
echo "Usage: $0 <username>"
fi
for mfaserial in $(aws iam list-mfa-devices --user-name $user --query MFADevices[].SerialNumber --output text); do
aws iam deactivate-mfa-device --serial-number $mfaserial --user-name $user
aws iam delete-virtual-mfa-device --serial-number $mfaserial
done
@bashtoni
bashtoni / gist:633b33e9441d0a5a3249
Created June 18, 2014 11:40
Script to create CentOS 7 docker image
#!/bin/bash -e
# Script to build a base CentOS 7 Pre-release docker image
# Tested under CentOS 6
BUILDROOT="/centos7"
if [ $(id -u) -ne 0 ]; then
echo "Must be run as root"
exit 1
@bashtoni
bashtoni / gist:406bfdfe678f99b1384d
Last active August 29, 2015 14:02
Create CentOS 6 docker container for use with Vagrant
# Docker image to use with Vagrant
# Aims to be as similar to normal Vagrant usage as possible
# Adds Puppet, SSH daemon
FROM centos
MAINTAINER Sam Bashton <[email protected]>
RUN yum -y install openssh-server
RUN yum -y install MAKEDEV
# Workaround needed for bad libselinux-ruby deps
RUN yum -y downgrade libselinux-2.0.94-5.3.el6_4.1 libselinux-utils
@bashtoni
bashtoni / gist:8157406
Created December 28, 2013 08:41
Find all EC2 instances created by a CloudFormation stack and print their IPs
aws ec2 describe-instances --filters Name=tag:aws:cloudformation:stack-name,Values=${STACKNAME} --output text --query 'Reservations[*].Instances[*].PrivateIpAddress'
@bashtoni
bashtoni / gist:7988793
Created December 16, 2013 15:26
Find an Amazon pvgrub kernel using the CLI
aws ec2 describe-images --filters Name=image-type,Values=kernel --filters Name=manifest-location,Values='*pv-grub-hd0_*x86_64*' --owners amazon
@bashtoni
bashtoni / gist:5966573
Created July 10, 2013 14:07
Live test match score for dashing
require 'json'
require 'net/http'
SCHEDULER.every '30s', :first_in => 5 do |job|
resp = Net::HTTP.get_response(URI.parse('http://cdnedge.bbc.co.uk/feeds/hi/english/static/cricket/statistics/scorecards/2013/07/87719/live_scorecard.json'))
data = resp.body
result = JSON.parse(data)
text = "<p>" + result["scorecard"]["teamASummary"] + "</p><p>" + result["scorecard"]["teamBSummary"] + "</p>"