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 | |
# -*- coding: utf-8 -*- | |
"""MySQL Binary Log Purger | |
This script handles purging unneeded binary logs from a MySQL master. It | |
will run on python 2.5+ and requires the oursql library. | |
In order to configure this script, you need to have a user with the same | |
username and password on the master and all slaves. The port is assumed | |
to be the same amongst the master and all slaves, and it is assumed |
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
# Run this like fab -R www deploy | |
from fabric.api import * | |
REPO_URL = '[email protected]:username/repo.git' | |
PROJECT_DIR = '$HOME/projects/projectname' | |
PROJECT_NAME = 'projectname' | |
SERVER_NAME = 'projectname.servername' # I use gunicorn, so i have projectname.gunicorn | |
env.roledefs['www'] = ['www1.example.com'] |
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 | |
import urllib | |
import json | |
import sys | |
LINODE_API_URL = 'https://api.linode.com/' | |
LINODE_API_KEY = '' # Add in your Linode API Key | |
TARGET_DOMAIN = 'example.com' # Replace with domain name | |
TARGET_RECORD = 'home' # Replace with sub domain |
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 | |
# -*- coding: utf-8 -*- | |
"""Finds the Address with the most Hit's yesterday""" | |
from datetime import date, datetime | |
from optparse import OptionParser | |
import mmap | |
import csv | |
import sys | |
DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S" |
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
# Written by Donald Stufft | |
# | |
# My Windows PowerShell Profile. It gives a prompt that looks like | |
# UserName at MachineName in ~/path on master^1?! | |
# (virtualenvname) ± | |
# | |
# Explanation: | |
# If you are in a git repo the prompt character will be ±, ¥ for mercurial and » otherwise. | |
# If you are in a git repo it will include the "on ...." bit. | |
# It will replace master with the name of the current branch |
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 tastypie.authentication import BasicAuthentication as TastypieBasicAuthentcation | |
from django.contrib.auth.models import AnonymousUser | |
class BasicAuthentication(TastypieBasicAuthentcation): | |
""" | |
Subclass Basic Authentcation to allow Anonymous users. | |
""" | |
def is_authenticated(self, request, **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.conf import settings | |
from django.http import HttpResponseRedirect | |
class LoginRequired(object): | |
def dispatch(self, request, *args, **kwargs): | |
if self.check_logged_in(request.user): | |
return super(LoginRequired, self).dispatch(request, *args, **kwargs) | |
else: | |
return self.not_logged_in(self): |
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 functools import wraps | |
class ViewDecorator(object): | |
def __init__(self, decorator_class): | |
self.decorator_class = decorator_class | |
def __call__(self, *args, **kwargs): | |
# Pretend that there is a generic decorator wrapper here | |
pass |
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 gevent | |
from gevent import socket, queue | |
from gevent.ssl import wrap_socket | |
import logging | |
logger = logging.getLogger('irc') | |
logger.setLevel(logging.DEBUG) | |
ch = logging.StreamHandler() |
OlderNewer