Skip to content

Instantly share code, notes, and snippets.

View jarpy's full-sized avatar
💚

Nina Dowland jarpy

💚
  • Elastic
  • Adelaide
  • 17:34 (UTC +10:30)
View GitHub Profile
@jarpy
jarpy / gist:2785420
Created May 25, 2012 02:28
AWS Auto Scaling with boto
import boto
from boto.ec2.autoscale import ScalingPolicy
from boto.ec2.cloudwatch import MetricAlarm
autoscale = boto.connect_autoscale()
cloudwatch = boto.connect_cloudwatch()
# Let's assume you already have an Auto Scaling group.
# Setting one up is well documented elsewhere.
@jarpy
jarpy / gist:8b209615563c4cb2bec9
Last active August 29, 2015 14:16
Count outstanding upgrades on a Debian/dpkg/Aptitude system.
aptitude safe-upgrade --simulate --assume-yes | awk -F ' ' '/[0-9]+ packages upgraded/ {print $1}'
@jarpy
jarpy / gist:d8bc2f353f365490f485
Created March 11, 2015 23:32
Send statsd metrics from the shell using only echo and Netcat.
# Counter
echo -n 'some.metric.namespace:1|c' | nc -u -q0 localhost 8125
# Gauge
echo -n 'some.metric.namespace:100|g' | nc -u -q0 localhost 8125
# Timer
echo -n 'some.metric.namespace:342|ms' | nc -u -q0 localhost 8125
@jarpy
jarpy / gist:75f1ada8eee09873a423
Last active August 29, 2015 14:18
Enviroment variables in Puppet Exec.
$secret = 'SESAME'
exec {'read_secret_variable':
command => '/bin/echo $ENVSECRET > /tmp/secret',
environment => "ENVSECRET=$secret"
}
# $ cat /tmp/secret
# SESAME
@jarpy
jarpy / logstash-forwarder-init.debian.sh
Last active August 29, 2015 14:21
Minimal init scripts for logstash-forwarder on RedHat and Debian.
#! /bin/sh
### BEGIN INIT INFO
# Provides: logstash-forwarder
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
root@salt:~# salt --async '*' cmd.run 'date ; sleep 10; date'
Executed command with job ID: 20150716111845948627
root@salt:~# salt --async '*' cmd.run 'date ; sleep 10; date'
Executed command with job ID: 20150716111847963330
root@salt:~# salt-run jobs.lookup_jid 20150716111845948627
debian7:
Thu Jul 16 11:18:45 AEST 2015
Thu Jul 16 11:18:55 AEST 2015
@jarpy
jarpy / remove-crapware.ps1
Created March 23, 2016 13:17
[WIP] Remove crapware from Windows 10
Get-AppxPackage | Select-String Zune | Remove-AppxPackage
Get-AppxPackage | Select-String Camera | Remove-AppxPackage
Get-AppxPackage | Select-String onenote | Remove-AppxPackage
Get-AppxPackage | Select-String phone | Remove-AppxPackage
Get-AppxPackage | Select-String photos | Remove-AppxPackage
Get-AppxPackage | Select-String BingSport | Remove-AppxPackage
Get-AppxPackage | Select-String Microsoft.People | Remove-AppxPackage
Get-AppxPackage | Select-String BingWeather | Remove-AppxPackage
Get-AppxPackage | Select-String WindowsSoundRecorder | Remove-AppxPackage
Get-AppxPackage | Select-String WindowsStore | Remove-AppxPackage
@jarpy
jarpy / purge-docker.sh
Last active September 12, 2016 06:55
Violently clean up Docker
# Remove all containers, inluding those that are not running.
docker ps --quiet | xargs docker kill
docker ps --all --quiet | xargs docker rm
# Remove all images.
docker images --format '{{.ID}}' | xargs docker rmi --force
apt-get -y update
apt-get -y install apt-transport-https ca-certificates
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://apt.dockerproject.org/repo ubuntu-trusty main' > /etc/apt/sources.list.d/docker.list
apt-get -y update
apt-get -y install docker-engine
service docker start
docker run hello-world
#!/usr/bin/env python
import RPi.GPIO as GPIO
import picamera
import subprocess
# Set up a pin on the GPIO connector for the "record" button.
# We'll use pin 18, which is here:
#
# ....X........