Skip to content

Instantly share code, notes, and snippets.

View kchristensen's full-sized avatar

Kyle Christensen kchristensen

View GitHub Profile
@kchristensen
kchristensen / gist:9725241
Created March 23, 2014 16:07
Hot honey garlic wing sauce
1/3 c Sriracha
1/4 c coconut aminos (or Bragg's liquid aminos)
1 tsp grated ginger
3 cloves garlic (minced)
1 tbs melted ghee (or butter)
4-5 tbs honey (to taste)
Combine ingredients in a small sauce pan and reduce over low heat until it reaches your desired consistency
@kchristensen
kchristensen / backup-freenas.sh
Last active August 29, 2015 14:13
FreeNAS Config Backup
#!/bin/bash
POOL="zpool1"
DATASET="backup/nas"
DB=freenas-v1.db
DB_HOME="/data"
BACKUP_HOME="/mnt/$POOL/$DATASET"
VERSIONS=10
exec 2> $BACKUP_HOME/backup.log
@kchristensen
kchristensen / kernel_cleanup.py
Last active August 29, 2015 14:16
Ubuntu kernel cleanup
#!/usr/bin/env python
#
# This script will uninstall kernels that are not
# current running, or one of the two latest available.
#
import apt
import optparse
import os
import re
@kchristensen
kchristensen / gist:25923763ccf82beb134b
Last active August 29, 2015 14:16
Rainbow Knight Rider for WS2812 LEDs
void knightRider(uint8_t wait) {
uint8_t i, j, x = 1, prev = 11;
for (j = 0; j < 256; j++) {
for (i = 0; i >= -1; i = i + x) {
if (i == 255)
return;
if (i > PIXEL_COUNT)
x = -1;

Keybase proof

I hereby claim:

  • I am kchristensen on github.
  • I am kylec (https://keybase.io/kylec) on keybase.
  • I have a public key whose fingerprint is D69C 60B1 60CD 91DB 81B3 5ACB 309D 52C6 A327 4B9A

To claim this, I am signing this object:

@kchristensen
kchristensen / check_rabbit_partitioning.py
Last active August 29, 2015 14:26
Nagios check for Rabbit cluster partitioning
#!/usr/bin/env python
"""
Nagios check to check RabbitMQ cluster for partitioning (split-brain)
"""
import json
import optparse
import logging
import requests
import sys
@kchristensen
kchristensen / ec2-instance-slack-watch.py
Last active December 10, 2015 15:28
Notify Slack if people leave EC2 test instances running
#!/usr/bin/env python
import boto3
import json
import requests
from datetime import datetime
filter = [{'Name': 'tag:Name', 'Values': ['test-kitchen', 'Packer']}]
boto3.setup_default_session(profile_name='prod')
ec2 = boto3.resource('ec2')
@kchristensen
kchristensen / gist:eb4bd6aa3200dafbe52d
Last active December 12, 2015 07:49
PHP Globals micro optimization
/*
foreach ($GLOBALS as $field => $value)
{
if (!in_array($field, array('_ENV', '_POST', '_GET', '_SERVER', '_FILES', '_REQUEST', 'GLOBALS', '_COOKIE')))
{
$data[$field] = $value;
}
}
*/
@kchristensen
kchristensen / docker-watch.sh
Created December 17, 2015 14:00
Watches docker to see if any of your containers have exited abnormally and notifies slack
#!/bin/bash
INSTANCE=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
SLACK_CHANNEL='#ops-notifications'
SLACK_URL='<%= node['base']['slack']['hook'] %>'
SLACK_USERNAME='DockerBot'
for CONTAINER in $(docker ps -a|grep -v CONTAINER|awk '{print $1}')
do
STATE=$(docker inspect -f '{{.State.Running}}' ${CONTAINER})
#!/bin/sh
# Edit in the commands you want to run
COMMAND="uptime"
unset CHAR PASS CONFIRM
echo -n "Enter webserver root password: "
while IFS= read -r -s -n1 CHAR
do