Skip to content

Instantly share code, notes, and snippets.

View philchristensen's full-sized avatar

Phil Christensen philchristensen

View GitHub Profile
@philchristensen
philchristensen / YQL.py
Created April 29, 2013 19:41
Example of querying the YQL console.
import restkit
import simplejson
YQL_URL = ('http://query.yahooapis.com', '/v1/public/yql')
value = '11215'
pmr = restkit.Resource(YQL_URL[0])
query = 'SELECT * FROM geo.places WHERE text = "%s"'
qs = value.replace(r'"', r'\"')
@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