Skip to content

Instantly share code, notes, and snippets.

@orenshk
orenshk / boto-backoff.py
Created June 3, 2018 18:44
AWS exponential back off with boto3
import boto3
from botocore.exceptions import ClientError
class BotoBackoff(object):
"""
Wrap a client for an AWS service such that every call is backed by exponential backoff with jitter.
Examples:
>>> ecs = BotoBackoff('ecs')
>>> ecs.list_tasks(cluster='my-cluster')
@orenshk
orenshk / pre-commit.sh
Created November 15, 2016 17:41
Run autopep8 and any tests you can find. To have a as a pre-commit hook, add to .git/hooks/pre-commit
#!/usr/bin/env bash
# Script to run before doing a commit. This will run autopep8 and any unit tests it can find.
# Place this script in .git/hooks/ directory of your repo and rename it pre-commit (no extension)
# To have this file copied to every new repo you created, place it in $HOME/.git_template/hooks/pre-commit
# NOTES:
# 1. This is an opinionated script, following the notion that code formatting issues are the most contentious but the
# least consequential. As such it borrows a page from Go and lets the machine decide on the formatting. Concretely,
# this means that any PEP8 violations will be fixed before commit, so long as the semantics of the code aren't changed