Skip to content

Instantly share code, notes, and snippets.

View dstokes's full-sized avatar

Drew Stokes dstokes

View GitHub Profile
@dstokes
dstokes / args.sh
Last active August 29, 2015 14:16
#!/bin/bash
#
# Parse command flags and positional arguments regardless
# of argument order
#
# placeholder for postional arguments
PARAMS=""
@dstokes
dstokes / changelog.sh
Last active August 29, 2015 14:10
Create a CHANGELOG.md with Bash + Git
#!/bin/bash
# vim: set syntax=sh :
#
# Generate a changelog
#
git tag | sort -r | awk '
/^v/ {
# print commit log diff
if(NR>1)
system("git log " $1 "..." prev " --pretty=format:\"- [%s](http://github.com/<owner>/<repo>/commit/%H) \" | tail -n+2")
@dstokes
dstokes / redis-monitor.sh
Last active December 19, 2019 03:25
StatsD Redis Monitor in 10LOC
#!/bin/bash
#
# Report redis usage data to statsd
# Metric Format: <env>.<hostname>.<redis>.<metric>
#
# Add to crontab for periodic monitoring
#
STATSD_HOST=<host>
STATSD_PORT=8125
{# set the value as a jinja variable #}
{%- mayvar = 'taco ' %}
{# add jinja variable to pillar data #}
mypillarkey: {{ myvar }}
{# add jinja variable to another pillar key #}
myotherpillarkey: {{ myvar }}
@dstokes
dstokes / Vagrantfile
Created July 25, 2014 18:18
salt auth error setup
Vagrant.configure("2") do |config|
config.vm.box = "hashicorp/precise64"
config.vm.define "master" do |master|
master.vm.hostname = "master"
master.vm.network :private_network, ip: "10.10.10.2"
master.vm.synced_folder ".", "/srv/salt/", nfs: true
master.vm.provider "virtualbox" do |v|
v.cpus = 2
include:
- mysls
# this runs even when mysls errors
some_state:
cmd.run:
- name: do things
- require:
- sls: mysls
@dstokes
dstokes / Vagrantfile
Created July 7, 2014 22:09
SmartOS Vagrantfile (Virtualbox)
Vagrant.configure("2") do |config|
# existing box name
config.vm.box = "SmartOS"
# download url for box (if it doesn't already exist)
config.vm.box_url = "http://dlc-int.openindiana.org/aszeszo/vagrant/smartos-base1310-64-virtualbox-20130806.box"
# sync a local directory to the vm
#config.vm.synced_folder "/path/to/local/dir", "/path/to/vm/dir"
@dstokes
dstokes / Vagrantfile
Created July 1, 2014 19:19
Salt Development Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
$bootstrap = <<SCRIPT
#!/usr/bin/env bash
apt-get update
apt-get install -y git build-essential python-pip python-dev python-m2crypto
{
"Environment": "prod",
"VPC": "vpc-69f00f0c",
"Subnets": "subnet1,subnet2",
"Zones": "us-east-1a",
"ServerSecurityGroups": "...",
"ElbSecurityGroups": "...",
"Endpoint": "www2.o2lontour.com"
}
{% set workers = { 'worker': 'rake resque:work QUEUE=immediate,high,medium,low',
'data_seed_worker': 'rake resque:work QUEUE=data_seed',
'youtube_quota_worker': 'rake resque:youtube_quota_worker',
'scheduler': 'rake resque:scheduler'
'sidekiq': 'sidekiq' } %}