Skip to content

Instantly share code, notes, and snippets.

View pydis-paste
#!/usr/bin/env zsh
emulate zsh
setopt err_exit pipe_fail warn_create_global warn_nested_var no_unset
if (( ${#@} == 0 )); then
elif (( ${#@} == 1)); then
case $1 in
-) data="$(cat)" ;;
gwerbin /
Created Aug 4, 2021
Demo of logging in a multi-processing context.
"""Demo of logging in a multi-processing context.
Based on the Python "Logging Cookbook":
Note on `QueueListener`:
The main difference between the Cookbook example and this demo is that I use
the `QueueListener` convenience class, whereas they write a bespoke
`listener_process` function which does more or less the same thing as
gwerbin / TaxExample.idr
Last active Jul 6, 2021
Example of dependent types and "proof-carrying code" in a simple, practical programming task.
View TaxExample.idr
module TaxExample
import Data.So
-- Can't use `total` as a variable name! Boo :(
%default total
-- NOTE: Weird things happen when you use the same name in both a record
-- parameter and a record field name. Don't do it.
gwerbin /
Last active Jun 16, 2021
Sketch of a solution for aligning matrix columns, intended for aligning columns emitted from Scikit-learn classifiers. See
import numpy as np
import pandas as pd
def fill_array(fillvalue, shape):
"""Create an array filled with a specific value."""
if fillvalue == 0:
if isinstance(fillvalue, int):
array = np.zeros(shape, dtype='int')
gwerbin / pipx-metadata_v0.2.0_draft00.json
Last active May 16, 2021
JSON Schema for Pipx Metadata v0.2.0, draft 00; see The regex for package version is [not trivial](, and is copied verbatim from [Pep 440](
View pipx-metadata_v0.2.0_draft00.json
"$schema": "",
"$id": "",
"$defs": {
"package_name": {
"type": "string",
"pattern": "^[A-Za-z][0-9A-Za-z_-]*$"
"python_version": {
"type": "string",
gwerbin / Dockerfile
Last active May 12, 2021
Attempt at setting up Debugpy
View Dockerfile
# Install basics
RUN /opt/venv/bin/python -m pip install -U pip
RUN /opt/venv/bin/pip install -U setuptools wheel
# Install runtime deps
COPY requirements.txt /app/requirements.txt
RUN /opt/venv/bin/pip install -r /app/requirements.txt
gwerbin / Matrix.idr
Last active May 4, 2021
Sketch of a matrix data type in Idris
View Matrix.idr
module Matrix
import Data.Vect
%default total
---- Interface ----
AbstractMatrix : Type
gwerbin /
Last active Jul 15, 2021
Export a Conda environment with --from-history, but also append Pip-installed dependencies
Export a Conda environment with --from-history, but also append
Pip-installed dependencies
Exports only manually-installed dependencies, excluding build versions, but
including Pip-installed dependencies.
Lots of issues requesting this functionality in the Conda issue tracker, no
sign of progress (as of March 2020).
View gitpath.zsh
# TODO: should this have a --flag for dispatch to system/global/local? Currently only supports local.
function gitpath() {
local git_dir output_path
if [[ -z "$GIT_DIR" ]]; then
read -r -d '' git_dir < <(git rev-parse --show-toplevel)
gwerbin /
Created Aug 27, 2020
NHST draft writeup

Null Hypothesis Significance Testing (NHST) is a procedure in which we try to learn something about the data by forming an hypothesis and then ruling out (or "rejecting) that hypothesis. Conceptually, NHST is similar to "deductive reasoning" in philosophy, or "differential diagnosis" in medicine: we can arrive on a single unambiguous conclusion only by ruling out all other possibilities. Therefore we can "prove" that the alternative hypothesis is true by ruling out the only other possibility, the null hypothesis.

In order to perform NHST, have to specify a null hypothesis, typically denoted H0, and an alternative hypothesis, typically denoted HA. H0 and HA must be mutually exclusive for NHST to make sense: if H0 is true then HA must be false, and if HA is true then H0 must be false.

NHST has two possible outcomes: we reject the null hypothesis in favor of the alternative hypothesis, or we fail to reject the null hypothesis. Failing to reject the null hypothesis does not mean that we reject