Skip to content

Instantly share code, notes, and snippets.

View tmehlinger's full-sized avatar

Travis Mehlinger tmehlinger

  • Cisco
  • Olathe, KS
View GitHub Profile
#!/bin/bash
# This hook is sourced after a new virtualenv is activated.
POST_INSTALL_PKGS="pylint pudb"
PIP=$(which pip)
$PIP install $POST_INSTALL_PKGS
@tmehlinger
tmehlinger / yolosort.py
Last active August 29, 2015 14:22
#yolo sort
#!/usr/bin/env python3.4
from itertools import tee
from random import randint, shuffle
import sys
def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable)
from __future__ import with_statement
from kombu import BrokerConnection
from collections import defaultdict
import gevent
from gevent import monkey
monkey.patch_all()
class WorkerHub():
"""
WorkerHub controls the local mailboxes that the @worker decorator assigns.

Internet Scale Services Checklist

A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."

Basic tenets

  • Does the design expect failures to happen regularly and handle them gracefully?
  • Have we kept things as simple as possible?
@tmehlinger
tmehlinger / fabfile.py
Last active May 25, 2016 15:26
A decorator for turning boolean parameters into actual bool types in Fabric tasks
import distutils.util
import functools
import inspect
from fabric.decorators import task
class bool_args(object):
def __init__(self, *bool_arg_names):
self.bool_arg_names = bool_arg_names
from collections import defaultdict
import json
import logging
import salt.minion
import salt.utils
import salt.utils.event
log = logging.getLogger(__name__)
@tmehlinger
tmehlinger / flatten.py
Last active September 7, 2016 19:50
flatten arbitrarily nested iterables
from collections.abc import Iterable
def flatten(seq, maxdepth=10):
if maxdepth <= 0:
raise ValueError
if isinstance(seq, Iterable) and not isinstance(seq, str):
for item in seq:
yield from flatten(item, maxdepth - 1)
else:
@pytest.fixture
def GroupFixture():
def wrapper(name='Test Group'):
return Group(name=name)
return wrapper
@pytest.fixture
def UserFixture():
def wrapper(groups=None):
@tmehlinger
tmehlinger / check_version.sh
Last active March 16, 2017 19:12
Salt deployment for DynamoDB local development server
#!/bin/bash
URL=$1
DYNAMODB_PATH=$2
FULL_URL=$(curl -sI $1 | awk '/Location/{gsub(/Location: /, ""); print}')
LATEST_VERSION=$(echo $FULL_URL | cut -d _ -f 3 | sed 's/\..*//')
VERSION_FILE=$2/VERSION
INSTALLED_VERSION=$([[ -f $VERSION_FILE ]] && cat $VERSION_FILE || echo "NOT INSTALLED")
# if we couldn't extract location from headers (i.e., there's a problem with

Keybase proof

I hereby claim:

  • I am tmehlinger on github.
  • I am maber (https://keybase.io/maber) on keybase.
  • I have a public key ASAdqbIJx2SnFlxrDjGO0__WoD-1s4hJ9betGx9xf_oCMAo

To claim this, I am signing this object: