Skip to content

Instantly share code, notes, and snippets.

View gwerbin's full-sized avatar
💭
I might be slow to respond.

Greg Werbin gwerbin

💭
I might be slow to respond.
View GitHub Profile
@gwerbin
gwerbin / column_align.py
Last active June 16, 2021 23:45
Sketch of a solution for aligning matrix columns, intended for aligning columns emitted from Scikit-learn classifiers. See https://github.com/scikit-learn/scikit-learn/issues/12845
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')
else:
@gwerbin
gwerbin / pipx-metadata_v0.2.0_draft00.json
Last active May 16, 2021 13:43
JSON Schema for Pipx Metadata v0.2.0, draft 00; see https://github.com/pipxproject/pipx/pull/660. The regex for package version is [not trivial](https://regex101.com/r/BbPqar/1), and is copied verbatim from [Pep 440](https://www.python.org/dev/peps/pep-0440/#appendix-b-parsing-version-strings-with-regular-expressions).
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://pipxproject.github.io/pipx/schema/pipx-metadata_v0.2.0_draft00.json",
"$defs": {
"package_name": {
"type": "string",
"pattern": "^[A-Za-z][0-9A-Za-z_-]*$"
},
"python_version": {
"type": "string",
@gwerbin
gwerbin / Dockerfile
Last active May 12, 2021 17:59
Attempt at setting up Debugpy
FROM $REDACTED
# 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
gwerbin / Matrix.idr
Last active May 4, 2021 06:10
Sketch of a matrix data type in Idris
module Matrix
import Data.Vect
%default total
---- Interface ----
AbstractMatrix : Type
@gwerbin
gwerbin / conda_env_export.py
Last active March 6, 2024 06:23
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,
e.g. https://github.com/conda/conda/issues/9628
@gwerbin
gwerbin / gitpath.zsh
Created August 27, 2020 14:23
Gitpath
# 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)
git_dir="${git_dir}/.git"
else
git_dir="$GIT_DIR"
@gwerbin
gwerbin / NHST.md
Created August 27, 2020 06:17
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

@gwerbin
gwerbin / writeup.md
Last active August 8, 2020 19:53
My attempt to understand Sans I/O style.

My attempt to understand Sans IO

The basic machinery is:

  1. An Event type
  2. A Client that receives "inbound events" (responses from previous i/o) and emits "outbound events"; one core implementation
  3. An IOClient that performs i/o based on outbound events and forms inbound events from i/o results; one implementation per i/o framework

Hypothetical implementations

@gwerbin
gwerbin / # openssl@1.1 - 2020-05-07_11-46-25.txt
Created May 7, 2020 15:46
openssl@1.1 on 3.10.0-1062.12.1.el7.x86_64 - Homebrew build logs
Homebrew build logs for openssl@1.1 on 3.10.0-1062.12.1.el7.x86_64
Build date: 2020-05-07 11:46:25
@gwerbin
gwerbin / kmscon-install.sh
Last active April 23, 2020 03:37
Build KMSCon on Linux Mint 19.3
#!/bin/sh
uname -a | grep --quiet 'Debian\|Ubuntu' || {
echo 'Refusing to run on a potentially incompatible system.'
return 1
}
# Build dependencies
sudo apt install \
autoconf \