Skip to content

Instantly share code, notes, and snippets.

@wellsie
wellsie / asg-ips.sh
Last active October 8, 2018 10:19
Autoscaling group ip addresses
#!/bin/bash
GROUP=worker
IDS=$(aws autoscaling describe-auto-scaling-groups \
--auto-scaling-group-name $GROUP \
--query AutoScalingGroups[].Instances[].InstanceId \
--output text)
aws ec2 describe-instances \
--instance-ids $IDS \
--query Reservations[].Instances[].PrivateIpAddress \
@wellsie
wellsie / reverse.py
Last active May 6, 2016 17:58 — forked from nsfyn55/reverse.py
Reverse Singly Linked List Python
class Node:
def __init__(self, value, next):
self.value = value
self.next = next
def dump(self):
print self.value
if self.next is not None:
self.next.dump()
@wellsie
wellsie / reflection.go
Created April 24, 2016 19:42 — forked from drewolson/reflection.go
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
@wellsie
wellsie / install-mosquitto.sh
Created April 12, 2016 21:27
install mosquitto on raspberry pi
#!/bin/bash -eux
curl http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key | sudo apt-key add -
sudo curl -o /etc/apt/sources.list.d/mosquitto-repo.list -L http://repo.mosquitto.org/debian/mosquitto-jessie.list
sudo apt-get update
sudo apt-get install mosquitto
@wellsie
wellsie / text-overlay.sh
Created April 1, 2016 00:07
GraphicsMagick text overlay
#!/bin/bash -eux
gm convert -font helvetica -fill blue -pointsize 36 -draw "text 15,50 'hello'" source.jpg destination.jpg
@wellsie
wellsie / install-ffmpeg-amazon-linux.sh
Last active March 28, 2016 04:20 — forked from gboudreau/install-ffmpeg-amazon-linux.sh
How to compile ffmpeg on Amazon Linux (EC2)
#!/bin/sh
# Based on instructions found here: http://wiki.razuna.com/display/ecp/FFMpeg+Installation+on+CentOS+and+RedHat#FFMpegInstallationonCentOSandRedHat-InstallX264
if [ "`/usr/bin/whoami`" != "root" ]; then
echo "You need to execute this script as root."
exit 1
fi
cat > /etc/yum.repos.d/centos.repo<<EOF
@wellsie
wellsie / get-kubectl.sh
Created March 18, 2016 19:14
Fetch kubectl binary (linux, amd64)
#!/bin/bash -eux
curl -Os https://storage.googleapis.com/kubernetes-release/release/v1.1.8/bin/linux/amd64/kubectl
chmod +x kubectl
./kubectl version --client
@wellsie
wellsie / has-space.sh
Created March 18, 2016 17:08
Function to determine if a string contains a space in bash
#!/bin/bash -eux
function has-space {
[[ "$1" != "${1%[[:space:]]*}" ]] && return 0 || return 1
}
if has-space "sadfsdf" ; then
echo "SPACE"
fi
@wellsie
wellsie / install-kubectl.sh
Last active April 20, 2018 10:14
Install kubectl (amd64)
#!/bin/bash -eux
ARCH=${ARCH:-linux}
K8S_VER=${K8S_URL:-v1.1.8}
K8S_URL=https://storage.googleapis.com/kubernetes-release/release
curl -Lo /usr/local/bin/kubectl ${K8S_URL}/${K8S_VER}/bin/$ARCH/amd64/kubectl
chmod +x /usr/local/bin/kubectl
@wellsie
wellsie / k8s-release-urls.sh
Last active October 20, 2016 01:56 — forked from jbeda/gist:2cae7dd22a453c3caa94
URLs for kubernetes release artifacts
$ gsutil ls -R gs://kubernetes-release/release/v1.2.0 | sed 's|gs://kubernetes-release|https://storage.googleapis.com/kubernetes-release|; /^.*:$/d; /^$/d'
https://storage.googleapis.com/kubernetes-release/release/v1.2.0/kubernetes-client-darwin-386.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v1.2.0/kubernetes-client-darwin-386.tar.gz.md5
https://storage.googleapis.com/kubernetes-release/release/v1.2.0/kubernetes-client-darwin-386.tar.gz.sha1
https://storage.googleapis.com/kubernetes-release/release/v1.2.0/kubernetes-client-darwin-amd64.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v1.2.0/kubernetes-client-darwin-amd64.tar.gz.md5
https://storage.googleapis.com/kubernetes-release/release/v1.2.0/kubernetes-client-darwin-amd64.tar.gz.sha1
https://storage.googleapis.com/kubernetes-release/release/v1.2.0/kubernetes-client-linux-386.tar.gz
https://storage.googleapis.com/kubernetes-release/release/v1.2.0/kubernetes-client-linux-386.tar.gz.md5
https://storage.googleapis.com/kub