Skip to content

Instantly share code, notes, and snippets.

Avatar
🎹
Piano

earonesty

🎹
Piano
View GitHub Profile
View random_bytes.py
import os
import sys
import json
import math
from runstats import Statistics, Regression
__all__ = ["randtest", "randtestall", "buildstats"]
def primes(givenNumber):
# Initialize a list
@earonesty
earonesty / gist:c1cd4c634cfc1f9e3f34d0b4b056651c
Created Mar 21, 2022
extremely simple lru set in python
View gist:c1cd4c634cfc1f9e3f34d0b4b056651c
class LRUSet(set):
def __init__(self, *args, max_size=None, **kws):
self.max_size = max_size
super().__init__(*args, **kws)
def add(self, ent):
if len(self) >= self.max_size:
self.pop()
super().discard(ent)
super().add(ent)
View qpydoc.py
"""
Generate api-style github markdown-files from python docstrings.
Example:
qpydoc my_module > API.md
"""
import re
View mock for subprocess run
# allows you to say with mock_run(...):
# ....
# good for testing scripts that do a lot of subprocess.run calls
class CmdMatch(NamedTuple):
cmd: str
matches: str = ".*"
result: str = ""
side_effect: Union[Callable, Exception] = None
View quip.py
import requests
import string
import random
import argparse
import json
def main():
parser = argparse.ArgumentParser(description='Post cryptoquips')
parser.add_argument("--generate", action="store_true")
View coinmarketcap volume weighted mcap
import os
import argparse
from typing import NamedTuple
from coinmarketcapapi import CoinMarketCapAPI, CoinMarketCapAPIError
api_key = os.environ["COINMARKETCAP_API_KEY"]
cmc = CoinMarketCapAPI(api_key)
View propagating_thread.py
import threading
from typing import Any
class PropagatingThread(threading.Thread):
"""A Threading Class that raises errors it caught, and returns the return value of the target on join."""
def __init__(self, *args, **kwargs):
self._target = None
self._args = ()
@earonesty
earonesty / reno-report.py
Last active Nov 3, 2021
reno reporter & linter that is far faster and leverages filtered git logs to handle topology for you
View reno-report.py
#!/usr/bin/python
import argparse
import contextlib
import os.path
import re
import shutil
import subprocess
import logging
import time
import sys
@earonesty
earonesty / DPAPI keyring
Created Apr 22, 2021
Replacement keyring backend that uses DPAPI instead of credsmanager
View DPAPI keyring
import typing
from contextlib import suppress
from pathlib import Path
import logging
from logextension import LoggingContext
with LoggingContext(logging.getLogger("keyring.backend"), logging.ERROR):
import keyring.backend
View diffcount.py
#!/usr/bin/env python
import sys
import re
import configparser
from fnmatch import fnmatch
from unidiff import PatchSet
EXTS = ["py"]