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 time import time | |
from functools import wraps | |
MINUTE = 60 | |
HOUR = MINUTE * 60 | |
DAY = HOUR * 24 | |
class Metrics(object): | |
def __init__(self, redis, keyspace='metrics'): | |
self.db = redis |
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
# Postfix stuff | |
QUEUEID (?:[A-F0-9]+|NOQUEUE) | |
EMAILADDRESSPART [a-zA-Z0-9_.+-=:]+ | |
EMAILADDRESS %{EMAILADDRESSPART:local}@%{EMAILADDRESSPART:remote} | |
RELAY (?:%{HOSTNAME:relayhost}(?:\[%{IP:relayip}\](?::[0-9]+(.[0-9]+)?)?)?) |
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
QUEUEID (?:[A-F0-9]+|NOQUEUE) | |
EMAILADDRESSPART [a-zA-Z0-9_.+-=:]+ | |
EMAILADDRESS %{EMAILADDRESSPART:local}@%{EMAILADDRESSPART:remote} | |
RELAY (?:%{HOSTNAME:relayhost}(?:\[%{IP:relayip}\](?::%{POSREAL:relayport})?)?) | |
POSREAL [0-9]+(.[0-9]+)? | |
DELAYS %{POSREAL:a}/%{POSREAL:b}/%{POSREAL:c}/%{POSREAL:d} | |
DSN %{POSINT}.%{POSINT}.%{POSINT} | |
STATUS sent|deferred|bounced|expired | |
PERMERROR 5[0-9]{2} | |
MESSAGELEVEL reject|warning|error|fatal|panic |
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
# Postfix stuff | |
QUEUEID (?:[A-F0-9]+|NOQUEUE) | |
EMAILADDRESSPART [a-zA-Z0-9_.+-=:]+ | |
EMAILADDRESS %{EMAILADDRESSPART:local}@%{EMAILADDRESSPART:remote} | |
RELAY (?:%{HOSTNAME:relayhost}(?:\[%{IP:relayip}\](?::[0-9]+(.[0-9]+)?)?)?) | |
#RELAY (?:%{HOSTNAME:relayhost}(?:\[%{IP:relayip}\](?:%{POSREAL:relayport}))) | |
POSREAL [0-9]+(.[0-9]+)? | |
#DELAYS %{POSREAL:a}/%{POSREAL:b}/%{POSREAL:c}/%{POSREAL:d} | |
DELAYS (%{POSREAL}[/]*)+ | |
DSN %{NONNEGINT}.%{NONNEGINT}.%{NONNEGINT} |
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
"""Decorator to quickly add statsd (graphite) instrumentation to Celery | |
task functions. | |
With some slight modification, this could be used to instrument just | |
about any (non-celery) function and be made abstract enough to customize | |
metric names, etc. | |
Stats reported include number of times the task was accepted by a worker | |
(`started`), the number of successes, and the number of times the task | |
raised an exception. In addition, it also reports how long the task took |
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 PIL import Image, ImageDraw | |
import argparse | |
import sys | |
def get_colors(image_file, numcolors=10, resize=150): | |
# Resize image to speed up processing | |
img = Image.open(image_file) | |
img = img.copy() | |
img.thumbnail((resize, resize)) |
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 | |
from java.io import * | |
import java.io.InputStream | |
import java.io.FileInputStream | |
import java.lang.String # blah....converting String types between Java/Python is tedious | |
sys.path.append("pdfbox-1.0.0.jar") # or wherever you stashed it | |
import org.apache.pdfbox | |
""" | |
This method merges the FileInputStreams that the streamList points to, into the |
NewerOlder