Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View nathants's full-sized avatar

nathants nathants

View GitHub Profile
@nathants
nathants / pys.sh
Last active August 20, 2022 08:01
3 bash functions for quick python oneliners
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
PY_IMPORTS="
import datetime
import string
import random
@nathants
nathants / email.py
Last active August 20, 2022 08:01
a cli to interact with email via imap and smtp
#!/usr/bin/env python3
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
from dateutil import parser
from email.header import decode_header
from email.mime.text import MIMEText
import contextlib
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
set -eou pipefail
# usage: auto-restart.sh python program.py
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
set -euo pipefail
# usage: myprogram.py | rotate-logs /tmp/myprogram.log [1000000]
@nathants
nathants / pip-upgrade.py
Last active August 20, 2022 08:02
check for updates and optionally upgrade packages via pip
#!/usr/bin/env python3
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
"""
check for updates and optionally upgrade packages via pip
"""
#!/usr/bin/env python3
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
import secrets
import sys
import re
#!/usr/bin/env python3
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
import functools
import sys
import time
import collections
#!/bin/bash
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
# define the retry fn
retry() {
e=0
if [[ $- =~ e ]]; then
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
from hypothesis import given, settings
from hypothesis.strategies import lists, sampled_from
def new_state():
return {'big': 0, 'small': 0}
@nathants
nathants / monitor-usage.py
Last active August 20, 2022 08:01
simple server usage monitoring, writing json to stdout.
#!/usr/bin/env python3
# The MIT License (MIT)
# Copyright (c) 2022-present Nathan Todd-Stone
# https://en.wikipedia.org/wiki/MIT_License#License_terms
"""
simple server usage monitoring, writing json to stdout.