This file contains hidden or 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/python | |
# Usage: curl http://guest:guest@localhost:15672/api/queues | ./generate_config.py > /opt/stackdriver/collectd/etc/collectd.d/rabbitmq.conf | |
import sys, json; | |
queues = json.load(sys.stdin) | |
output = """ | |
# This is the monitoring configuration for RabbitMQ. |
This file contains hidden or 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
{% csrf_token %} | |
{% if form.non_field_errors %}<div class="non_field_errors">{{form.non_field_errors}}</div>{%endif %} | |
{% for field in form.visible_fields %} | |
{% load klass %} | |
<div class="field_wrapper field_{{field.name}} input_{{field.field.widget|klass}} {% if field.errors %}has_errors{% endif %}"> | |
{% if field.field.widget|klass == 'CheckboxInput' %} | |
{{ field }} | |
{{ field.label_tag }} | |
{% else %} | |
{{ field.label_tag }} |
This file contains hidden or 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
plugins = {} | |
def get_input_plugins(): | |
return plugins['input'].items() | |
class Plugin(object): | |
plugin_class = None | |
@classmethod | |
def register(cls, name): | |
plugins[cls.plugin_class][name] = cls |
This file contains hidden or 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
Usage is: | |
OrderedMixedQuerysets('-date',MyModel.objects.all(),MyOtherModel.objects.all()) |
This file contains hidden or 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 StringIO import StringIO | |
import boto.s3 | |
from django.conf import settings | |
class MultiPartUploader: | |
counter = 0 | |
def __init__(self, bucket_name, key_name, buf_size=32768): | |
self.connection = boto.connect_s3(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY) | |
self.bucket = self.connection.get_bucket(bucket_name) |