Skip to content

Instantly share code, notes, and snippets.

View KyleJamesWalker's full-sized avatar
😃
Hello!

Kyle James Walker (he/him) KyleJamesWalker

😃
Hello!
View GitHub Profile
@KyleJamesWalker
KyleJamesWalker / simple_random_ytvideo.py
Last active December 9, 2016 00:23
Generates a random YouTube like Video ID
"""Generate a random YouTube like Video ID, supports deterministic generation
if seed is passed.
"""
import random
import string
import sys
YT_SET = (string.ascii_letters + string.digits + "-_") * 2
@KyleJamesWalker
KyleJamesWalker / try_snappy_py3.py
Created January 5, 2017 20:02
AVRO and Snappy within Python 3
"""Checking to see if snappy works with Python 3 recent updates to libraries
Requires:
python-snappy==0.5
fastavro==0.9.9
"""
import random
import string
@KyleJamesWalker
KyleJamesWalker / fortune.py
Last active January 7, 2017 01:20
Generator that can tell the future based on a iterable object
'''Generator that can tell the future based on a iterable object
Update: Created a helper class to simplify the core generator code, left original to verify against.
'''
from collections import deque
class Bucket(object):
@KyleJamesWalker
KyleJamesWalker / _README.md
Created February 25, 2017 18:05
Convert directory of files with ffmpeg

Converts a directory of low bitrate mp4 audio files to window media audio with ffmpeg.

This is a quick conversion for my car's CD player as it doesn't support mp4.

Keybase proof

I hereby claim:

  • I am kylejameswalker on github.
  • I am kylejameswalker (https://keybase.io/kylejameswalker) on keybase.
  • I have a public key ASCW21fjaLLt721meHzL4foAVr3V44KfM0EX8cjlRUFDywo

To claim this, I am signing this object:

@KyleJamesWalker
KyleJamesWalker / README.md
Last active November 6, 2017 23:51
Templated yamlsettings example

A quick example to allow easy environment variable injection for yamlsettings in lists. Normally a list can only be completely overriden via environement variables, this allows you to pick specific values to load in to a given entry.

Run with something like:

BAR_PASS=s3cr3t BAZ_PASS=god python example.py
@KyleJamesWalker
KyleJamesWalker / datadog_lambda.py
Created November 9, 2017 22:40
Monitoring AWS Lambda functions with Datadog Example
"""Send metrics over stdout for datadog lambda monitoring.
Monitoring details:
https://www.datadoghq.com/blog/monitoring-lambda-functions-datadog/
"""
import time
from copy import copy
@KyleJamesWalker
KyleJamesWalker / README.md
Last active December 26, 2017 21:47
YamlSettings Example with Null Validation

Failures:

python -m example
SERVICE_USER=foo python -m example

Valid:

SERVICE_USER=foo SERVICE_PASS=bar python -m example
@KyleJamesWalker
KyleJamesWalker / pretty_json_file.py
Created December 29, 2017 23:07
Print a JSON file with color!
import json
from pygments import highlight, lexers, formatters
def pretty_json_file(fn):
print(highlight(
json.dumps(json.load(open(fn)), sort_keys=True, indent=2),
lexers.JsonLexer(),
formatters.TerminalFormatter(),
))
@KyleJamesWalker
KyleJamesWalker / kms_edit
Created February 3, 2018 00:03
Quickly Edit KMS Documents
#!/usr/bin/env python
import argparse
import hashlib
import os
import tempfile
import sys
def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.