Skip to content

Instantly share code, notes, and snippets.

@elazarcoh
elazarcoh / python-stdout-tee.py
Last active May 29, 2022 06:00
A Tee context manager to redirect `print` calls to a file, as a quick logging method
import sys
class Tee(object):
def __init__(self, name, mode, autoflush=False):
self.file = open(name, mode)
self.stdout = sys.stdout
sys.stdout = self
self.autoflush = autoflush
#!/bin/sh
URL="https://file.io"
DEFAULT_EXPIRE="14d" # Default to 14 days
if [ $# -eq 0 ]; then
echo "Usage: file.io FILE [DURATION]\n"
echo "Example: file.io path/to/my/file 1w\n"
exit 1
fi