Skip to content

Instantly share code, notes, and snippets.

Sean Johnson pirogoeth

View GitHub Profile
View introspect.py
import typing
from functools import partial
from typing import Optional, Tuple, Type, Union
K = typing.TypeVar("K")
V = typing.TypeVar("V")
class TypedDict(typing.Dict[K, V]):
pass
View backup-convoy-volumes.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import asyncio
import json
import os
import re
import shutil
import sys
from datetime import datetime
View call_inspection.py
# -*- coding: utf-8 -*-
import inspect
def get_caller():
""" Inspects the call stack to determine the path of a caller.
Returns a string representing the full path to the caller.
"""
View raygun_sample_2.py
from raygun import json
from raygun.params import parse_str
class Account(mongoengine.Document, raygun.params.CustomKind):
""" Account object for database storage AND request body schema
"""
name = StringField(required=True)
@classmethod
View gist:dbac151ecf39650c44b7333ffe6f9f55
In [1]: import timeit
In [4]: class A(object):
...: pass
...:
In [5]: item = object()
In [6]: item_a = A()
View test_model.py
class Item(mongoengine.Document):
@raygun.openapi_schema
class Schema(object):
id = schema.Int()
name = schema.String(required=True)
created_at = schema.DateTime()
name = mongoengine.StringField(required=True)
created_at = mongoengine.DateTimeField(default=datetime.utcnow)
View gist:0d42652ea33de140e945c4190a6199ca
root@cloud bin # upsc usbhid
battery.charge: 67
battery.charge.low: 10
battery.charge.warning: 50
battery.date: 2001/09/25
battery.mfr.date: 2013/10/04
battery.runtime: 1007
battery.runtime.low: 120
battery.type: PbAc
battery.voltage: 27.0
View envmgr.sh
#!/usr/bin/env zsh
# -*- coding: utf-8 -*-
# vim: set ai et ts=4 sts=4 sw=4 syntax=zsh:
set -o pipefail
function __ensure_envdir() {
[[ ! -d "${HOME}/.envmgr.d/" ]] && mkdir -p "${HOME}/.envmgr.d/"
return 0
}
@pirogoeth
pirogoeth / snipe-it-entrypoint.sh
Last active Dec 26, 2018
slightly modified entrypoint for snipe-it's docker build
View snipe-it-entrypoint.sh
#!/bin/sh
# fix key if needed
if [ -z "$APP_KEY" ]
then
echo "Please re-run this container with an environment variable \$APP_KEY"
echo "An example APP_KEY you could use is: "
php artisan key:generate --show
exit
fi
@pirogoeth
pirogoeth / poller.py
Last active Feb 22, 2019
a stdlib replacement for twisted's LoopingCall.
View poller.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
__doc__ = """
This module contains a polling caller, built on top of Python's
stdlib `threading` module. It can be used as an alternative to
twisted's `LoopingCall`.
Usage:
You can’t perform that action at this time.