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
debugdjango() { | |
action=${1:-traceback} | |
port=${2:-8000} | |
interface=${3:-lo} | |
TCPDUMP="tcpdump -i${interface} -A port ${port}" | |
case $action in | |
all) | |
echo "INFO: Running tcpdump on interface $interface and port $port" >&2 | |
sudo $TCPDUMP | |
;; |
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
# Originally based on: http://djangosnippets.org/snippets/1872/ | |
# Requires sqlparse: http://pypi.python.org/pypi/sqlparse | |
import time | |
from django.test.signals import template_rendered | |
from django.conf import settings | |
from django.db import connection | |
from django.utils.encoding import force_unicode | |
from django.utils.safestring import mark_safe | |
TEMPLATE = """ |
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
# Put this in /etc/profile.d/cdpy.sh or copy the function into ~/.bashrc | |
# Change to the source directory of just about any python module to RTFS | |
# | |
# (c) 2011 Jeff Schroeder <jeffschroeder@computer.org> released as GPLv2 | |
cdpy() { | |
module="$1" | |
[ -z "$module" ] && return 1 | |
dir=$(python -c " | |
import os | |
try: |
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
# Copied from the django source but added feed_url so the write actually works. | |
import sys | |
from django.utils import feedgenerator | |
feed = feedgenerator.Atom1Feed( | |
title=u"Poynter E-Media Tidbits", | |
link=u"http://www.poynter.org/column.asp?id=31", | |
feed_url=u"http://rss.feed_url/", | |
description=u"A group weblog by the sharpest minds in online media/journalism/publishing.", | |
language=u"en", |
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
jeff@desktopmonster:~/src/git/salt/salt/modules (misc-fixes)$ gdi apt.py | |
diff --git a/salt/modules/apt.py b/salt/modules/apt.py | |
index f3b0cd8..75751a4 100644 | |
--- a/salt/modules/apt.py | |
+++ b/salt/modules/apt.py | |
@@ -196,7 +196,7 @@ def upgrade(refresh=True): | |
return ret_pkgs | |
-def list_pkgs(regex_string=""): |
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
############################## django-auth-ldap ############################## | |
if DEBUG: | |
import logging, logging.handlers | |
logfile = "/tmp/django-ldap-debug.log" | |
my_logger = logging.getLogger('django_auth_ldap') | |
my_logger.setLevel(logging.DEBUG) | |
handler = logging.handlers.RotatingFileHandler( | |
logfile, maxBytes=1024 * 500, backupCount=5) |
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
############################## django-auth-ldap ############################## | |
import ldap | |
from django_auth_ldap.config import LDAPSearch, PosixGroupType | |
# django-auth-ldap configuration starts here | |
AUTH_LDAP_SERVER_URI = "ldap://ldap.els03.loc ldap://ldap.zbw03.loc ldap://ldap.cvg03.loc" | |
#AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=People,o=loc" | |
# JW is in ou=Admin,o=loc so we search over o=loc to find him | |
AUTH_LDAP_USER_SEARCH = LDAPSearch("o=loc", |
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 hr_bytes(size): | |
''' | |
This just returns the bytes in a human readable format. | |
''' | |
hr = lambda s:[(s%1024**i and "%.1f"%(s/1024.0**i) or str(s/1024**i))+x.strip() for i,x in enumerate(' KMGTPEZY') if s<1024**(i+1) or i==8][0] | |
return hr(size) |
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
""" | |
This allows you to import Django modules into a Salt module | |
""" | |
import logging | |
import sys | |
import os | |
log = logging.getLogger(__name__) |
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
include: | |
- apt | |
# our custom sources | |
/etc/apt/sources.list.d/fatbox.list: | |
file: | |
- managed | |
- source: salt://fatbox/debian/apt/fatbox.list | |
- owner: root | |
- group: root |
OlderNewer