Skip to content

Instantly share code, notes, and snippets.

@mattupstate
mattupstate / windowResize.coffee
Created December 4, 2013 22:07
A generic window resize directive to which you can add to any element to call a function on your controller
angular.module('something')
.directive 'windowResize', ($window, $parse) ->
restrict: 'A'
link: (scope, element, attrs) ->
w = angular.element($window)
fn = $parse(attrs['windowResize'])
handler = (event) ->
@mattupstate
mattupstate / virtualbox.json
Created September 3, 2013 20:45
Ubuntu 12.04 VirtualBox Packer example
{
"provisioners": [
{
"type": "shell",
"scripts": [
"scripts/base.sh",
"scripts/vagrant.sh",
"scripts/virtualbox.sh",
"scripts/ruby.sh",
"scripts/chef.sh",
@mattupstate
mattupstate / Vagrantfile
Last active December 13, 2015 21:48
RabbitMQ cluster with Vagrant and Chef
Vagrant::Config.run do |vagrant|
vagrant.vm.define :vm1 do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :hostonly, "192.168.0.80"
config.vm.host_name = 'rabbit1'
config.vm.provision :chef_solo do |chef|
chef.add_recipe "apt"
chef.add_recipe "hostsfile"

Keybase proof

I hereby claim:

  • I am mattupstate on github.
  • I am mattupstate (https://keybase.io/mattupstate) on keybase.
  • I have a public key whose fingerprint is 141F 4546 6A68 8F3D D2C7 0603 28D4 7F5D D3BC 77D5

To claim this, I am signing this object:

@mattupstate
mattupstate / diskusage.lua
Last active October 8, 2015 10:25
heka disk usage decoder and filter
--[[
Graphs disk usage data containing fields entield `DiskSize`, `DiskUsed`,
`DiskAvailable`, and `DiskPercentUsed`
Config:
- sec_per_row (uint, optional, default 60)
Sets the size of each bucket (resolution in seconds) in the sliding window.
- rows (uint, optional, default 1440)
Sets the size of the sliding window i.e., 1440 rows representing 60 seconds
@mattupstate
mattupstate / configure_nginx.yml
Created July 31, 2012 21:51
pseudo nginx playbook
---
- hosts: testing
user: ubuntu
sudo: True
vars_files:
- software/nginx/vars/default.yml
tasks:
@mattupstate
mattupstate / supervisord.conf
Created February 10, 2012 18:59 — forked from danmackinlay/supervisord.sh
an init.d script and generic config for supervisord
; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
@mattupstate
mattupstate / ses_handler.py
Created November 26, 2011 19:20
Amazon SES email logging handler for Python
import logging
import types
from boto.ses import SESConnection
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE
class SESHandler(logging.Handler):
"""
A handler class which sends an email using Amazon SES.
@mattupstate
mattupstate / middleware.py
Created October 18, 2011 19:22
HTTP method override middleware for Werkzeug
from werkzeug import url_decode
class HTTPMethodOverrideMiddleware(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
if 'METHOD_OVERRIDE' in environ.get('QUERY_STRING', ''):
args = url_decode(environ['QUERY_STRING'])
@mattupstate
mattupstate / tests.py
Created October 1, 2011 22:11
I'm getting a BrowserStateError for some reason
import unittest
from flask import Flask, render_template
from flaskext.testing import TestCase, Twill
TWILL_ENABLED = True
DEBUG = True
SECRET_KEY = 'secret'
def create_app():
app = Flask(__name__)