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 httplib | |
import urllib | |
class WebServer(object): | |
def __init__(self, host): | |
self.host = host | |
def _make_request(self, method, url, data, headers): | |
conn = httplib.HTTPConnection(self.host) |
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.contrib import admin | |
from django.contrib.auth.admin import UserAdmin | |
from django.contrib.auth.forms import UserCreationForm, UserChangeForm | |
from django.contrib.auth.models import Group, User | |
# Override username field require email address | |
class UserCreationForm2(UserCreationForm): | |
email = forms.CharField(max_length=75, required=True) |
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 print_warning(msg): | |
print fabric.colors.red("WARNING: ") + msg | |
def print_error(msg): | |
print fabric.colors.red("ERROR: ") + msg | |
def print_label(msg): | |
print fabric.colors.blue("==> ", bold=True) + msg |
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 local2(command, print_command=False): | |
"Run a command, returning the exit code, output, and stderr." | |
from subprocess import Popen, PIPE | |
p = Popen(command, stdout=PIPE, stderr=PIPE) | |
if print_command: print " ".join(command) | |
output, errput = p.communicate() | |
return p.returncode, output, errput | |
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 subprocess import Popen, PIPE | |
def local2(command, print_command=False): | |
"Run a command, returning the exit code, output, and stderr." | |
p = Popen(command, stdout=PIPE, stderr=PIPE) | |
if print_command: print " ".join(command) | |
output, errput = p.communicate() | |
return p.returncode, output, errput |
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 find_setting(source, setting, unquote=True): | |
re_setting = r'^\s*' + re.escape(setting) + r'\s*=\s*(.+)$' | |
m = re.search(re_setting, source, re.M) | |
if not m: | |
return None | |
value = m.group(1).strip() | |
if unquote: | |
if value.startswith("'") and value.endswith("'") or \ | |
value.startswith('"') and value.endswith('"'): |
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/ruby | |
search = ARGV.first | |
manpath = `manpath`.split(':') | |
pages = Dir["/usr/share/man/man?/*"].map do |f| | |
File.basename f | |
end.map do |f| | |
f =~ /(.+?)(\.(gz|bz2|lzma|Z))?$/ | |
$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
#!/bin/bash | |
# Escaped color codes | |
BLACK=`echo -e '\033[0;30m'` | |
DK_GREY=`echo -e '\033[1;30m'` | |
RED=`echo -e '\033[0;31m'` | |
PINK=`echo -e '\033[1;31m'` | |
GREEN=`echo -e '\033[0;32m'` | |
LT_GREEN=`echo -e '\033[1;32m'` | |
BROWN=`echo -e '\033[0;33m'` |
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 jython -J-XstartOnFirstThread -Dpython.path=jms.jar:tibcrypt.jar:tibjms.jar | |
import time | |
from javax.jms import TopicConnectionFactory, MessageListener, Session | |
from com.tibco.tibjms import TibjmsQueueConnectionFactory, TibjmsTopicConnectionFactory | |
class Listener(MessageListener): | |
def onMessage(self, message): |
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 sys | |
import os | |
import contextlib | |
from subprocess import Popen, PIPE | |
def die(message, error_code=1): | |
print message | |
sys.exit(error_code) |