So you're in posix sh and you want to do the equivalent of this in bash:
foo | tee >(bar) >(baz) >/dev/null(Suppose that bar and baz don't produce output. Add redirections where
needed if that's not the case.)
| #!/bin/sh | |
| #If already set (e.g. in github actions); use that instead | |
| if [ -z "$GITHUB_TOKEN" ]; then | |
| nix run nixpkgs#gh auth status || nix run nixpkgs#gh auth login | |
| GITHUB_TOKEN="$(nix run nixpkgs#gh auth token)" | |
| export GITHUB_TOKEN | |
| fi | |
| NIX_CONFIG="access-tokens = github.com=$GITHUB_TOKEN" |
| #!/usr/bin/env bash | |
| HELP="Usage: $0 [-n LINES] [-p PREFIX] [-w] [-h] | |
| Continuously displays the last '-n' lines of 'stdin'. | |
| Parameters: | |
| -n Number of lines to display (default: 5). | |
| -p PREFIX Prefix lines with 'PREFIX'. | |
| -w Preserve blank lines (default: false). | |
| -h Display this help |
We have a number of problems that currently require full rebuilds of nixpkgs:
Interestingly, Nix's deep pinning of cacerts and tzdata gets in the way of Nix's promise of packages working over the long term in an archival sense:
| # shellcheck shell=ksh | |
| # If SH_LIBPATH is not set or null, then we try to build it | |
| if [ -z "${SH_LIBPATH+x}" ] || [ "${#SH_LIBPATH}" -eq "0" ]; then | |
| for _path in /usr/local/lib/sh "${HOME}"/.local/lib/sh; do | |
| [ -d "${_path}" ] && SH_LIBPATH="${SH_LIBPATH}:${_path}" | |
| done | |
| fi | |
| unset -v _path | |
| # Remove any leading colons from the construction process and export | |
| SH_LIBPATH="${SH_LIBPATH#:}" |
| #!/usr/bin/env bash | |
| set -Eeuo pipefail | |
| trap cleanup SIGINT SIGTERM ERR EXIT | |
| script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) | |
| usage() { | |
| cat <<EOF | |
| Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...] |
Note: The code links are to CPython 3.8.5, the most recent release when this was written.
I was recently asked about a performance optimization in CPython around using += and + for string objects.
As some people may already know, if you use += or + a string, it can sometimes be just as fast as ''.join.
The question was to explain when that optimization couldn't be performed.
We will be going through the following example scenarios:
| #!/usr/bin/awk -f | |
| # This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff | |
| # My copy here is written in awk instead of C, has no compelling benefit. | |
| # Public domain. @thingskatedid | |
| # Run as awk -v x=xyz ... or env variables for stuff? | |
| # Assumptions: the data is evenly spaced along the x-axis | |
| # TODO: moving average |
| # typed: true | |
| # frozen_string_literal: true | |
| require('dev') | |
| require('fileutils') | |
| module Dev | |
| module Helpers | |
| class APFSVolume | |
| extend(T::Sig) |