Skip to content

Instantly share code, notes, and snippets.

View tmehlinger's full-sized avatar

Travis Mehlinger tmehlinger

  • Cisco
  • Olathe, KS
View GitHub Profile
import pytest
suffixes = {
'1': 'st',
'2': 'nd',
'3': 'rd',
}
@tmehlinger
tmehlinger / run.sh
Last active February 21, 2023 12:02
gstreamer RTP to RTMP
#!/bin/bash
# tested on Ubuntu 16.04
apt-get install -y \
gstreamer1.0-libav \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-tools

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:

@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 / 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:
from collections import defaultdict
import json
import logging
import salt.minion
import salt.utils
import salt.utils.event
log = logging.getLogger(__name__)
@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
@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
@tmehlinger
tmehlinger / kms.py
Created May 3, 2016 20:47
ext_pillar module for decrypting secrets with AWS KMS
# -*- coding: utf-8 -*-
'''
Decrypt secrets in pillar data using AWS KMS.
This module uses boto3 to connect to KMS and decrypt secrets in pillar data
using keys stored in KMS. It will recurse the supplied pillar data, scanning
for any keys marked by the configured delimiter. If it finds any interesting
keys, it will communicate with KMS to decrypt the respective values with the
suppled key ID.
@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)