Skip to content

Instantly share code, notes, and snippets.

@benwtr
benwtr / carbon-amqp-proxy.js
Created October 4, 2011 06:56
ghetto carbon/graphite amqp proxy in node.js
// Listens on localhost port 2003 for graphite metrics and publish them to carbon via amqp
var sys = require('sys')
, net = require('net')
, amqp = require('amqp')
var payload = "";
var server = net.createServer(function (s) {
s.on('data', function(data) {
d = data.toString().replace(/(\n|\r)+$/, '');
@benwtr
benwtr / duo.py
Created November 9, 2011 07:44
duosecurity post-auth script for openvpn access server
# This is a post-auth script to integrate Duo Security with OpenVPN Access Server
#
# glued together from openvpn-as sample code and duo's community openvpn python
# integration script
#
# Disclaimer: I am not a python programmer
#
import os, sys, urllib, hashlib, httplib, hmac, base64, json, syslog, time, re
from pyovpn.plugin import *
@benwtr
benwtr / hack.sh
Created April 2, 2012 22:49 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@benwtr
benwtr / gist:5465284
Last active December 16, 2015 16:48
rbenv config for ruby 1.9.3-p392 with railsexpress patchset
# This is an rbenv config that installs ruby 1.9.3 with railsexpress patchset from https://github.com/skaes/rvm-patchsets
#
# https://gist.github.com/burke/1688857 was helpful to look at to see how this is done
#
# required debian packages:
# apt-get install autoconf build-essential openssl libreadline6 libreadline6-dev zlib1g zlib1g-dev libssl-dev ncurses-dev libyaml-dev libffi-dev tk-dev libgdbm-dev
#ruby patch revision
rev=392
@benwtr
benwtr / nagios.coffee
Last active January 13, 2016 08:29 — forked from oremj/nagios.coffee
# Description:
# This script receives pages in the formats
# /usr/bin/curl -d host="$HOSTALIAS$" -d output="$SERVICEOUTPUT$" -d description="$SERVICEDESC$" -d type=service -d notificationtype="$NOTIFICATIONTYPE$ -d state="$SERVICESTATE$" $CONTACTADDRESS1$
# /usr/bin/curl -d host="$HOSTNAME$" -d output="$HOSTOUTPUT$" -d type=host -d notificationtype="$NOTIFICATIONTYPE$" -d state="$HOSTSTATE$" $CONTACTADDRESS1$
#
# Based on a gist by oremj (https://gist.github.com/oremj/3702073)
#
# Configuration:
# HUBOT_NAGIOS_URL - https://<user>:<password>@nagios.example.com/cgi-bin/nagios3
#
@benwtr
benwtr / Vagrantfile
Last active December 25, 2015 20:49
Vagrantfile that fpm's up some ruby and svn debs that I needed. Optionally puts them in a apt repo on s3
#
# Abuse of vagrant to build some debs. optionally also uploads to an apt repo on s3.
#
# Tested with:
# squeeze64 https://dl.dropboxusercontent.com/u/13054557/vagrant_boxes/debian-squeeze.box
# squeeze32 http://mathie-vagrant-boxes.s3.amazonaws.com/debian_squeeze_32.box
# Debian-7.1.0-64 (built with veewee, not shared on a public url. this is also the default)
#
# Usage:
# # vagrant box add squeeze32 http://mathie-vagrant-boxes.s3.amazonaws.com/debian_squeeze_32.box
@benwtr
benwtr / hubot-twitter-user.coffee
Created October 27, 2015 23:36
Example Hubot script that uses an OAuth PIN flow to authenticate individual users with Twitter
# Description
# Do things on twitter through hubot, as your logged in user after authenticating with an oauth pin.
#
# Configuration:
# HUBOT_TWITTER_CONSUMER_KEY - API key for hubot app registered on dev.twitter.com
# HUBOT_TWITTER_CONSUMER_SECRET - API secret for hubot app registered on dev.twitter.com
#
# Commands:
# hubot t auth <pin_code> - authenticate with pin code
# hubot t clear my credentials - forget any authentication tokens
@benwtr
benwtr / warmup.rb
Last active November 4, 2015 20:21
Ever wish your thermostat had a "turn heat on for x minutes" feature? Me too, but not enough to spend more than 5 minutes writing a script to do it
#!/usr/bin/env ruby
# Tell a nest thermostat to kick the heat on for n minutes
require 'nest_thermostat'
unless ARGV[0]
puts 'Usage: warmup.rb <minutes>'
exit 1
end
# Policyfile.rb
name "some_policy"
run_list 'derp'
require 'json'
JSON.parse(File.read('../environments/some_env.json'))['default_attributes'].each_pair{|k,v| default[k]=v}
# Description:
# Hubot interface for timezone.io
#
# Configuration:
# HUBOT_TIMEZONEIO_URL - full team url eg: https://timezone.io/team/buffer
#
# Commands:
# hubot tz - Show team's local time across time zones via timezone.io
#
# Dependencies: