This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""A command line interface to urllib.parse.urljoin""" | |
import argparse | |
from urllib.parse import urljoin | |
def main() -> None: | |
parser = argparse.ArgumentParser() | |
parser.add_argument("base", help="The base URL") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Strip line comments from a file | |
By default, this requires whitespace to surround a comment for it to be valid. | |
This means that `a#a` is not a valid comment. | |
""" | |
from __future__ import annotations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Print lines slowly | |
Intended for testing command line interfaces | |
""" | |
import argparse | |
import itertools | |
import time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env -S uv run --script | |
# Extracts data from the first markdown table found in the input file, | |
# converting it into CSV | |
# /// script | |
# dependencies = [ | |
# "marko~=2.1" | |
# ] | |
# /// | |
import csv | |
import sys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env fish | |
set --local openssl_prefix $(brew --prefix openssl) | |
set --local libssh_prefix $(brew --prefix libssh2) | |
set -gx CFLAGS "-I$openssl_prefix/include -I$libssh_prefix/include -lssl -lssh2" | |
set -gx LDFLAGS "-L$openssl_prefix/lib -L$libssh_prefix/lib -lssl -lssh2" | |
if not test -f ./nim.cfg; or not test -f ./README.md | |
echo "ERROR: Should be in chawan root directory" >&2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Return to the most recently used directory when starting fish shell | |
# | |
# Ported from this xontrib: https://github.com/anki-code/xontrib-back2dir | |
# | |
# Uses fish "universal variables" for storage | |
# | |
# TODO: Is using universal variables (as opposed to a dedicated file) | |
# going to slow things down or hurt SSD? | |
# Right before the first pompt is shown, we go back to the last directory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# A nice little script to hash the contents of tarfiles | |
# Works in parallel | |
import shutil | |
import os | |
import re | |
import sys | |
import subprocess | |
from math import ceil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Examples of how `str(x)` differs from x.__str__`() | |
This behavior is documented here: https://docs.python.org/3.11/reference/datamodel.html#special-lookup | |
The reason for this is performance, so `x + y` can avoid a dictionary lookup and/or `__getattribute__` call | |
""" | |
def override_str(*args): | |
return "bar" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state,census2020 | |
California,"39,538,223" | |
Texas,"29,145,505" | |
Florida,"21,538,187" | |
New York,"20,201,249" | |
Pennsylvania,"13,002,700" | |
Illinois,"12,812,508" | |
Ohio,"11,799,448" | |
Georgia,"10,711,908" | |
North Carolina,"10,439,388" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//! Defines the [`maybe_const_fn`] macro. | |
/// Mark a function as `const` if a `cfg!(...)` attribute evaluates to true. | |
/// | |
/// This has the same effect as using `#[rustversion::attr(version_test, const)]`, | |
/// but is implemented as a declarative macro instead of a procedural one. | |
/// | |
/// It is subject to some minor limitations (see below). | |
/// | |
/// If these are unacceptable, |
NewerOlder