Skip to content

Instantly share code, notes, and snippets.

View MatrixManAtYrService's full-sized avatar

Matt Rixman MatrixManAtYrService

View GitHub Profile
@MatrixManAtYrService
MatrixManAtYrService / fancydict.py
Last active June 5, 2024 22:14
Using generics and abstract base classes to create something like a dict which maps between two custom types
from abc import ABC, abstractmethod
from collections.abc import Iterator, MutableMapping
from pathlib import Path
from typing import Generic, TypeVar, cast, Type, Dict
from pydantic import BaseModel, Field
K = TypeVar('K', bound='Key')
V = TypeVar('V', bound='Value')

Some more of the standard library

You already know something about sys and pathlib. Now it's time to learn about venv.

venv creates virtual environments (which are a more lightweight than a virtual machine, but they're similar in how they isolate their contents from the rest of your system. This lets us install third-party libraries in a sane way. If you don't use them, things get cluttered quickly.

Please read/watch the following:

@MatrixManAtYrService
MatrixManAtYrService / flake.nix
Last active March 5, 2024 21:59
radicle in a nix devshell
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs?ref=23.11";
radicle.url = "git+https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5?ref=master";
};
outputs = { self, nixpkgs, flake-utils, radicle }:
flake-utils.lib.eachDefaultSystem (system:
let
@MatrixManAtYrService
MatrixManAtYrService / 1_intro.md
Last active March 1, 2024 20:44
libcst vs refactor, an unfair trial

This analysis of libcst vs refactor is incomplete. I probably won't come back and complete it (maybe your case warrants more analysis than my case did).

I had a difficult time with refactor a while back, so I recently tried libcst. I couldn't remember exactly why I had a difficult time, maybe I just didn't sleep well the night before or some kind of non-reason like that. Rather than justify this to myself, I just went with libcst.

I ended up with this:

from time import sleep
def main() -> None:
foo(
json={"code": 200, "response": data.dict(), # <-- missing '}'
headers={"Content-Type": "application/json"}
)
sleep(1) #<-- green
sleep(1)
sleep(1) #<-- white
@MatrixManAtYrService
MatrixManAtYrService / git.nix
Created February 6, 2024 03:54
home manager git config to use ssh instead of http for github
git = {
enable = true;
extraConfig = {
"url \"[email protected]:\"".insteadOf = "https://github.com/";
};
};
@MatrixManAtYrService
MatrixManAtYrService / resume.json
Last active September 30, 2023 01:16
resume.json
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "Matt Rixman",
"label": "Bits, Bytes, and Theorems",
"image": "https://avatars.githubusercontent.com/u/5834582?s=96&v=4",
"email": "[email protected]",
"summary": "I am in search of interesting problems that can be solved with code. Bonus points if they're socially impactful, open source, or peer-to-peer.",
"profiles": [
{
@MatrixManAtYrService
MatrixManAtYrService / genome.txt
Last active August 25, 2023 04:39
Gene Structure
GCAAAGGCTCACCCAAGGCTCCGAATCACACTATCTGAGCAACATTTCAAGACACTCTGCAACACCACGCCAGCCTCGGAAAAGCGTGCAAATCTGCTGTGAAGATGCTCAGGCCTTCATTGCCAAAGACTCTGACGGCTTTTGGCCCGCCTTAACCAGCTGGGTGGCCGGCCCGGACAGTGCCCGTCGCGGATCTCTGCATGGCTTCAAACCAGAAAGGTGCTCTCAACGTCGGGCAACAGTGAGGTATGCGACTCCCCTTGCATCACATGGACTTGTCCTGGGAGGCCTTTTCTTGGGCCGTTCATTGCGGAGATGTCGGCAAGGTTCTCTGCAAGACCGTGTCAGCCACGGCCCTTGCGAGGCTGAGTTGAGGTCTGGCTATCTGTCTCGAGATGGACCTCACTGGGTCGTCATGGCTGGCTCGAGGCCTTGCTGGCTGGGCCTTTGCCTGGAGCTTCATGATATTGCCAAGCCTCGGAGCTCCCTTCGAATTGGTCAAGTGGTCTGCTTGGCTCGCCGTACCCAAGGTTACCCCAAGGTACCTACCTACCTACCTACACTAACCTACCTACCCTCCCTCTGCGGAGGAGGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATCAGCAACAGCGACAAATCAGCACACACGGCAAGCAAAGCACCCACGGGAGCTGGCTGTTAGCTGACTGAGCTCGAGCTTCCATCCCTTCGCTTAGCTTGGACGTCGGCACCTTCCCTCCTGTACGGACGCATGTCTCAGGCGCGGTTGCGCTCAAACACGGCGGGCAATCACCTGGAAGGACACAACATCAAAGGGCCCATCAGTGGCATGCATCTTCGGCCCTTCTGAATTTTCGAGCGTCTCCTGGCGCCAACTTCAACACCAAACCTCGTCGCGATCATCCTTCCGGCCAAAACACCACTTTTCCATCCGCCAACCCCGCTTCATCCACTTCCACCAGTTCCACGCAAATCCCGCGCCGTTGCCCCGTCAATATCAACATCCAGCATCGTCACG
@MatrixManAtYrService
MatrixManAtYrService / Error if proxyVendor = true;
Last active March 15, 2023 06:20
> go: -mod may only be set to readonly when in workspace mode, but it is set to "vendor"
❯ nix log /nix/store/zp4vz01wk21ym5nixhhcva1nmvxqw0kc-kustomize-4.5.4.drv
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/kr8qsxkf90anrkdl98kw6cdyagcpprx1-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
@nix { "action": "setPhase", "phase": "buildPhase" }
@MatrixManAtYrService
MatrixManAtYrService / shim.sh
Last active December 20, 2022 17:53
capturing stdin, stdout, stderr, argv, pid, and return code, while forwarding (some) signals to a subprocess
[[ $SHIMAGE_PROCIO_VERBOSE -eq 1 ]] && set -x
# a folder for this process's outputs
DATA="{data}/$$"
mkdir -p $DATA
# capture argv
echo "$@" > $DATA/argv
# assume we'll be terminatged