Skip to content

Instantly share code, notes, and snippets.

@dmtucker
dmtucker / dynv6-update-host.bash
Last active October 23, 2023 07:00 — forked from corny/dynv6.sh
Update script for dynv6.com to set your IPv6 address
#!/usr/bin/env bash
update_via_http () {
if [ -z "${token+undefined}" ] || [ "$#" != 2 ]
then
echo 'usage: token=<your-HTTP-token> update_via_http zone ipv6' 1>&2
exit 1
fi
zone="$1"
ipv6="$2"
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=141323
import math
def apy(apr, periods=12):
return (((apr / periods) + 1) ** periods) - 1
def apr(apy, periods=12):
return (((apy + 1) ** (1 / periods)) - 1) * periods
#!/usr/bin/env python3
ROMAN_LEGEND = {
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
import os
import py
def _relpath(path, *, relto):
# TODO py35+ commonpath = os.path.commonpath([path, relto])
commonpath = str(py.path.local(path).common(py.path.local(relto)))
def _commonpath_to(_path):
return _path[len(commonpath):].strip(os.path.sep)

say we claim support for >=1, <3

  • 1.0 is the first supported version.
    • if this isn't tested, features from later versions may be depended on that break compatibility with this version.
  • 1.x adds to it.
    • test the latest version available to detect new features that collide (e.g. variables named async are fine in python 3.6 but async becomes a keyword in python 3.7).
      • only the latest version needs to be tested because features cannot be removed without a major version bump.
    • if something breaks, either
      • a new feature collided with existing code
      • upstream did not follow semver and broke compatibility
  • existing code uses upstream code that is not part of the public API
  • setuptools builds distributions from source code.
  • pip (un)installs distributions (optionally, from PyPI).
    • twine publishes distributions to PyPI.
  • pytest tests installed distributions.
why doesn't it make sense to mix strings and bytes in path components with posixpath.join? this Q is really only for py2 since 3 does away with implicit conversions, but the unicode could be encoded and the join would succeed. even if that results in a multi-encoding str, I've been told, that's ok in POSIX
$ python3 sep.py
different: cp037 b'a'
different: cp273 b'a'
different: cp424 b'a'
different: cp500 b'a'
different: cp875 b'a'
different: cp1026 b'a'
different: cp1140 b'a'
untested: cp65001
different: utf_32 b'\xff\xfe\x00\x00/\x00\x00\x00'
@dmtucker
dmtucker / 1.17
Last active April 25, 2020 04:07
What's up with Python 1.17 in the PyPI stats database?