This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# A simple script to open a new tab in Terminal in the current directory | |
# Author: Eric Allen | |
osascript -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' > /dev/null 2>&1 | |
osascript -e "tell application \"Terminal\" to do script \"cd $PWD && clear\" in window 1" > /dev/null 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Basic daemon config | |
ServerRoot "/etc/apache2" | |
PidFile ${APACHE_PID_FILE} | |
User ${APACHE_RUN_USER} | |
Group ${APACHE_RUN_GROUP} | |
ServerTokens ProductOnly | |
ServerAdmin webmaster@djangoproject.com | |
### Listen on localhost:8000 (behind the proxy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def start_replication(): | |
""" | |
Begin Postgresql standby | |
""" | |
# Stop pg on the slave machine. | |
with settings(host_string=env.db_slave): | |
run('service postgresql-9.0 stop') | |
# Create the backup on the master machine | |
with settings(host_string=env.db_master): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Nagios plugin to check PostgreSQL 9 streaming replication lag. | |
Requires psycopg2 and nagiosplugin (both installable with pip/easy_install). | |
MIT licensed: | |
Copyright (c) 2010 Jacob Kaplan-Moss. All rights reserved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import mechanize | |
from xml.etree import cElementTree | |
USERNAME = '...' | |
PASSWORD = '...' | |
NUMBER = '2025551212' | |
br = mechanize.Browser() | |
br.open('https://ebillpay.verizonwireless.com/vzw/accountholder/overview/AccountOverview.action') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Install some packages. Ignore the errors. | |
aptitude install binutils libgdal1-1.5.0 postgresql-8.3-postgis postgresql-server-dev-8.3 python-psycopg2 python-setuptools | |
### Make connecting to postgres easier | |
echo "local all all trust" > /etc/postgresql/8.3/main/pg_hba.conf | |
invoke-rc.d postgresql-8.3 reload | |
### Become the Postgres user to create a spatial template database: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExceptionUserInfoMiddleware(object): | |
""" | |
Adds user details to request context on receiving an exception, so that they show up in the error emails. | |
Add to settings.MIDDLEWARE_CLASSES and keep it outermost(i.e. on top if possible). This allows | |
it to catch exceptions in other middlewares as well. | |
""" | |
def process_exception(self, request, exception): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from types import MethodType | |
from django.http import CompatCookie, HttpRequest | |
def _set_cookie(self, key, value='', max_age=None, expires=None, path='/', | |
domain=None, secure=False): | |
self._resp_cookies[key] = value | |
self.COOKIES[key] = value | |
if max_age is not None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import inspect | |
import pygraphviz as pgv | |
from django.conf import settings; settings.configure() | |
from django.views import generic | |
class GenericViewGraph(pgv.AGraph): | |
_ignore_types = (None, object) | |
def __init__(self, *args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.db.models import signals | |
class DeletingFileField(models.FileField): | |
""" | |
FileField subclass that deletes the refernced file when the model object | |
itself is deleted. | |
WARNING: Be careful using this class - it can cause data loss! This class | |
makes at attempt to see if the file's referenced elsewhere, but it can get |
OlderNewer