Skip to content

Instantly share code, notes, and snippets.

View philchristensen's full-sized avatar

Phil Christensen philchristensen

View GitHub Profile
@philchristensen
philchristensen / check_anything.py
Last active December 15, 2015 15:59
A boilerplate nagios check script.
#!/usr/bin/env python
"""
Boilerplate Nagios check script.
"""
import os, os.path, sys, getopt, datetime
import yaml
nagios_codes = {'OK': 0,
@philchristensen
philchristensen / gist:5147023
Created March 12, 2013 21:06
Show how to read from the nagios datafile
#!/usr/bin/python
import os.path, datetime, sys
import termcolor
datfile = "/opt/local/var/nagios/status.dat"
def main(infile):
if os.path.exists(datfile) == False:
@philchristensen
philchristensen / mega-dev-prompt.sh
Created June 6, 2012 16:10
Mega developers prompt
export VIRTUAL_ENV_DISABLE_PROMPT=1
function parse_svn_branch {
if [ -d '.svn' ]; then
ref=$(svn info | grep URL | awk -F/ '{print $NF}' 2> /dev/null) || return
cur=$(pwd | awk -F/ '{print $NF}' 2> /dev/null) || return
if [ $ref != $cur ]; then
echo -ne "\xE2\x9C\xB6${ref}"
fi
fi
(function($) {
var settings;
var methods = {
init: function(options){
// Create some defaults, extending them with any options that were provided
settings = $.extend({
}, options);
@philchristensen
philchristensen / awk-spaces.sh
Created March 1, 2012 16:16
Grab a space-separated field using awk
df | awk 'BEGIN { FS = " +" } { print $5}'
@philchristensen
philchristensen / prepare-commit-msg.sh
Created December 19, 2011 16:29
Append branch name to ticket
#!/bin/sh
#
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
# This hook will append the current branch name to
# the commit message if it's not already there.
@philchristensen
philchristensen / fubot-init.sh
Created November 9, 2011 18:30
hubot init script
#! /bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/fubot/bin/hubot
NAME=fubot
DESC="Jabber Bot"
CONF="-a xmpp --name $NAME"
BOT_USER=fubot
BOT_GROUP=fubot
@philchristensen
philchristensen / gist:1152898
Created August 17, 2011 23:21
resistence stuff
V = IR
R = V/I
I = V/R
3V / 1.4A = 2.142857142857143 ohms
5V / 1.4A = 3.571428571428571ohms
1.428571428571429 ohm resistor
@philchristensen
philchristensen / anti-spam-autoresponse.txt
Created August 7, 2011 14:59
Anti-Spam Auto-Response
Your post advocates a
( ) technical ( ) legislative (X) market-based (X) vigilante ( ) form-based
approach to fighting spam. Your idea will not work. Here is why it won't work. (One or more of the following may apply to your particular idea, and it may have other flaws which used to vary from state to state before a bad federal law was passed.)
( ) Spammers can easily use it to harvest email addresses
( ) Mailing lists and other legitimate email uses would be affected
( ) No one will be able to find the guy or collect the money
( ) It is defenseless against brute force attacks