Skip to content

Instantly share code, notes, and snippets.

Avatar
🙈
Taking care of my kid

Matt Wright mattupstate

🙈
Taking care of my kid
View GitHub Profile
@mattupstate
mattupstate / supervisord.conf
Created Feb 10, 2012 — forked from danmackinlay/supervisord.sh
an init.d script and generic config for supervisord
View supervisord.conf
; 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 Nov 26, 2011
Amazon SES email logging handler for Python
View ses_handler.py
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 Oct 18, 2011
HTTP method override middleware for Werkzeug
View middleware.py
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 Oct 1, 2011
I'm getting a BrowserStateError for some reason
View tests.py
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__)
@mattupstate
mattupstate / golden_ticket.md
Created Aug 22, 2011 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
View golden_ticket.md
@mattupstate
mattupstate / controller.py
Created Aug 18, 2011
Simple way of implementing before and after filters in a web.py app
View controller.py
def before_filter(*args, **kwargs):
print "before"
def after_filter(*args, **kwargs):
print "after"
class Controller(object)
@RequestFilter(before=[before_filter], after=[after_filter])
def GET(self):
return "Hello!"
@mattupstate
mattupstate / main.py
Created Aug 15, 2011
uwsgi yaml file
View main.py
#!/usr/bin/env python
import os, web, sys
sys.path.append(os.path.dirname(__file__))
urls = (
r'/', 'Home',
)
@mattupstate
mattupstate / convert_all_to_south.py
Created Jul 24, 2011
Django management command to convert all your apps to use South migrations
View convert_all_to_south.py
import settings
from django.core.management.base import BaseCommand
from subprocess import call
class Command(BaseCommand):
def _is_project_app(self, app_name):
return not 'django' in app_name and not 'south' in app_name
def handle(self, *args, **options):
View gist:928270
package net.nobien.cloudfoundry.example.config.database
import java.net.UnknownHostException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@mattupstate
mattupstate / cloud-context-config
Created Apr 19, 2011
Easily get your cloud environment properties in your Spring context initializer
View cloud-context-config
package net.nobien.cloudfoundry.example.config;
import java.util.Properties;
import org.cloudfoundry.runtime.env.CloudEnvironment;
import org.cloudfoundry.runtime.env.CloudEnvironmentPropertiesFactoryBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.core.env.ConfigurableEnvironment;
You can’t perform that action at this time.