Skip to content

Instantly share code, notes, and snippets.

Travis Mehlinger tmehlinger

Block or report user

Report or block tmehlinger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ordinal.py
import pytest
suffixes = {
'1': 'st',
'2': 'nd',
'3': 'rd',
}
@tmehlinger
tmehlinger / run.sh
Last active Dec 18, 2019
gstreamer RTP to RTMP
View run.sh
#!/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
View keybase.md

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:

View gist:84fadb0fe72fd1e2abe25da27d1f9d73
@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 Sep 7, 2016
flatten arbitrarily nested iterables
View flatten.py
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:
View my_orchestrate.py
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
A decorator for turning boolean parameters into actual bool types in Fabric tasks
View fabfile.py
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 Mar 16, 2017
Salt deployment for DynamoDB local development server
View check_version.sh
#!/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
ext_pillar module for decrypting secrets with AWS KMS
View kms.py
# -*- 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.
View yolosort.py
#!/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)
You can’t perform that action at this time.