Skip to content

Instantly share code, notes, and snippets.

View mplovepop's full-sized avatar

Mike Prentice mplovepop

View GitHub Profile
@mplovepop
mplovepop / sqlfilequery.py
Created December 22, 2017 21:53
Utility class to load a named SQL file and use as a query
class SqlFileQuery:
"""Utility class to load a named SQL file and use as a query."""
def __init__(self, filename):
self.filename = filename
@property
def dirpath(self):
return os.path.dirname(os.path.realpath(__file__))
@property
def filepath(self):
return os.path.join(self.dirpath, self.filename)
@mplovepop
mplovepop / eliot-papertrail.sh
Last active October 29, 2018 18:29
Use eliot-tree to view papertrail logs. Requires: papertrail, jq, eliot-tree, and a papertrail API token
#!/bin/bash
set -o errexit
eliot_cmd="eliot-prettyprint"
eliot_args=()
papertrail_args=("--json")
jq_term=".events[].message"
grep_cmd="cat"
grep_args=("-")
@mplovepop
mplovepop / mkpass.py
Created April 2, 2019 22:02
~/.local/bin/mkpass
#!/usr/bin/python
import os, sys, random, string
length = int(sys.argv[1]) if len(sys.argv) > 1 else 4
if length < 8:
with open('/usr/share/dict/words', 'r') as f:
choice_list = [l.strip() for l in f.readlines()]
ch = ' '
@mplovepop
mplovepop / cli_test.py
Created July 12, 2019 15:26
Click testing with patch
import click.testing
import os
import snowtool.cli
import unittest
from unittest import mock
from ..mocks import MOCK_ENV, MOCK_SNOWFLAKE_VERSION, MockSnowflakeServer
@mock.patch.dict(os.environ, MOCK_ENV)