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 connect_retry(exceptions, max=5, first=2, multiplier=2): | |
def decorator(fun): | |
@functools.wraps(fun) | |
def retrier(*args, **kwargs): | |
tried = 0 | |
wait = first | |
while tried <= max: | |
try: | |
conn = fun(*args, **kwargs) | |
print "reconnected!" |
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 Queue | |
import random | |
class RandomQueue(Queue.Queue): | |
"""A queue that gets a random item from the queue | |
""" | |
def _init(self, maxsize): | |
self.queue = [] |
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 is the default .slate file. | |
# If no ~/.slate file exists this is the file that will be used. | |
config defaultToCurrentScreen true | |
config nudgePercentOf screenSize | |
config resizePercentOf screenSize | |
# Resize Bindings | |
# bind right:alt resize +10% +0 | |
# bind left:alt resize -10% +0 |
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 logging | |
import json | |
import argparse | |
import requests | |
github_base = "https://api.github.com" | |
github_status_url = github_base + "/repos/{repo_name}/statuses/{sha}?access_token={token}" | |
token = '' |
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 boto.s3.connection import S3Connection | |
from futures import ThreadPoolExecutor | |
import futures | |
connection = S3Connection('id', 'key') | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
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 time | |
def await_data(func, *args, **kwargs): | |
""" | |
Given a function and its args keep calling until data is returned | |
Tries do deal with mongo slowness to show recently inserted data | |
""" | |
thefunc = partial(func, *args, **kwargs) | |
max_times = 10 |
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
package main | |
import "fmt" | |
import "math/cmplx" | |
func Cbrt(x complex128) complex128 { | |
z := 1.0+0i | |
zold := z | |
cont := true | |
for i := 0; cont == true ; i++ { |
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
# todo: check working copy is clean, master branch etc | |
@runs_once | |
def build(): | |
"Build source distribution locally" | |
store_git_revision() | |
with settings(warn_only=True): | |
local("rm dist/*") | |
local("python setup.py sdist") |
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
"""KDE knotify logging handler""" | |
import logging | |
import dbus | |
class KNotifyHandler(logging.Handler): | |
"""Log messages to kde notifications""" | |
def __init__(self, level=logging.NOTSET): |
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
""" | |
Parallel remote logs | |
$ fab hoststask tail_log --linewise | |
""" | |
from fabric.decorators import parallel, task | |
from fabric.tasks import run | |
@task |