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 datetime import datetime | |
class RateLimiter: | |
def __init__(self, seconds=1): | |
self.count = 0 | |
self.last_time = datetime.now() | |
self.seconds = float(seconds) | |
self.step = 1 | |
def stepping(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
# http://en.wikipedia.org/wiki/ANSI_escape_code | |
color_code_template = """\x1b[{}m""" | |
colors = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white') | |
color_codes = dict(zip(colors, range(len(colors)))) | |
bold_code = 1 | |
clear_code = 0 | |
def get_code(code): | |
return color_code_template.format(code) |
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
# https://code.google.com/p/google-api-python-client/source/browse/samples/threadqueue/main.py?spec=svn67b8dcf946169e1ad62ecb0555942865b9186ea8&r=67b8dcf946169e1ad62ecb0555942865b9186ea8 | |
from __future__ import print_function | |
from random import randint | |
import sys | |
from time import sleep | |
class Backoff: | |
"""Exponential Backoff |
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 capnames(line): | |
if isinstance(line, basestring): | |
was_string = isinstance(line, str) | |
if was_string: | |
line = line.decode('utf-8') | |
line = line.lower() \ | |
.replace(u'otoole', u'o\'toole') \ | |
.replace(u'\\', u'') | |
line = u'-'.join(_.strip() for _ in line.split(u'-')) | |
line = u"'".join(_.strip() for _ in line.split(u"'")) |
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
<?php | |
/** | |
* This class can add WSSecurity authentication support to SOAP clients | |
* implemented with the PHP 5 SOAP extension. | |
* | |
* It extends the PHP 5 SOAP client support to add the necessary XML tags to | |
* the SOAP client requests in order to authenticate on behalf of a given | |
* user with a given password. | |
* |
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 | |
"""\ | |
A command-line utility that can (re)send all messages in an mbox file | |
to a specific email address, with options for controlling the rate at | |
which they are sent, etc. | |
""" | |
# I got this script from Robin Dunn a few years ago, see | |
# https://github.com/wojdyr/fityk/wiki/MigrationToGoogleGroups |