Skip to content

Instantly share code, notes, and snippets.

View hartfordfive's full-sized avatar

Alain L hartfordfive

View GitHub Profile
@hartfordfive
hartfordfive / .gitconfig
Created April 10, 2015 18:03
Sample Git config
[filter "media"]
required = true
clean = git media clean %f
smudge = git media smudge %f
[user]
name = Your Name
email = [email protected]
[alias]
rmbranch = !sh -c 'echo "Removing local branch $0" && git branch -d $0'
rmrbranch = !sh -c 'echo "Removing remote branch $0..." && git push origin :$0'
@hartfordfive
hartfordfive / testkitchen-ec2-cleanup
Last active December 22, 2015 09:42
Script to automatically cleanup EC2 instances created by Test Kitchen
#!/bin/bash
<<COMMENT
Dependencies:
1. This script assumes that Test Kitchen provisioned instances have name prefixes begining with "kitchen".
2. You must have jq installed
3. You must have the python aws-cli tool installed
4. You must have the appropriate IAM role assigned to the machine that will be running this script if you dont want to provide the access key and secret key
@hartfordfive
hartfordfive / estop.sh
Last active February 16, 2017 20:58
Top-like ElasticSearch status script
#!/bin/bash
clear
function header {
dt=$(date)
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
echo " EStop :: $1 :: Last Update - $dt"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -
@hartfordfive
hartfordfive / locust_basic_auth_test.py
Created June 18, 2015 15:55
Sample LocustIO testing script with basic auth
'''
Simple LocustIO testing script with basic auth
'''
import random, gzip, StringIO, threading, urllib2, re, getpass
from locust import HttpLocust, TaskSet, task, web
from random import randint
from urlparse import urlparse
#resource.setrlimit(resource.RLIMIT_NOFILE, (999999, 999999))
USER_AGENTS = [
@hartfordfive
hartfordfive / util_functions.go
Created September 15, 2015 13:50
Sample Go utility functions
func is_whitespace(ch rune) bool { return ch == ' ' || ch == '\t' || ch == '\n' }
func is_alpha(ch rune) bool { return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') }
func is_numeric(ch rune) bool { return (ch >= '0' && ch <= '9') }
@hartfordfive
hartfordfive / gist:f597fa73f3aba929b26f
Created November 4, 2015 12:24
Get key file fingerprint for APT repo
gpg --with-fingerprint [KEY_FILE]
@hartfordfive
hartfordfive / Vagrantfile
Last active November 10, 2015 19:32
Vagrant file to privision nightly build of Grafana
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
$startup_script = <<SCRIPT
if [ ! -d "/opt" ]; then
mkdir /opt
fi
@hartfordfive
hartfordfive / asg-ssh-mac
Created December 11, 2015 12:23
PHP script to connect to all EC2 instances in an auto-scaling group on a Mac
#!/usr/bin/php
<?php
/****************************************
Requirements:
- Python 2.7+
- aws-cli
- osascript
*****************************************/
@hartfordfive
hartfordfive / gist:6f9aef937fe0ba8fe144
Created December 16, 2015 13:56
Force apt-get update at compile time in chef
execute "fix apt-cache" do
command 'apt-get update'
only_if do
acp = Mixlib::ShellOut.new('apt-cache policy autoconf')
acp.run_command
acp.error?
end
end.run_action( :run )
@hartfordfive
hartfordfive / center_string.go
Last active July 3, 2024 21:11
Go function to center a string with whitespace padding
package main
import (
"bytes"
"fmt"
)
// Example: http://play.golang.org/p/Q34HEmWMXh
func main() {