Skip to content

Instantly share code, notes, and snippets.

View n8henrie's full-sized avatar

Nathan Henrie n8henrie

View GitHub Profile
#!/usr/bin/env python3
"""Send files to MacOS trash bin via applescript."""
import os
from pathlib import Path
import sys
import subprocess
from typing import Iterable, Union
def trash(paths: Iterable[Union[str, Path]]) -> int:
@n8henrie
n8henrie / sd_shrink.sh
Last active May 25, 2021 20:40 — forked from Pesticles/gist:d16ad533a09927362a80
SD Card image shrinker
#!/bin/bash
######################################################
# sd_shrink.sh
# Usage: sudo bash sd_shrink.sh /dev/DEVICE FILENAME
# Backs up and shrinks DEVICE to FILENAME_YYYYmmdd.img
######################################################
set -euf -o pipefail
@n8henrie
n8henrie / pyscript.py
Last active January 3, 2022 20:03 — forked from nhoffman/pyscript.py
Python script template
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""pyscript.py
A simple python script template.
http://ajminich.com/2013/08/01/10-things-i-wish-every-python-script-did/
"""
import argparse
  • Update HISTORY.md
  • Update version number in my_project/__init__.py
  • Update version number in setup.py
  • Install the package again for local development, but with the new version number:
python3 setup.py develop
  • Run the tests:
python3 setup.py test
#! /usr/bin/env python3
import datetime
import sys
try:
import xmlrpc.client as xmlrpclib
except:
import xmlrpclib