Skip to content

Instantly share code, notes, and snippets.

View krscott's full-sized avatar

Kris Scott krscott

View GitHub Profile
@krscott
krscott / nixos-eyd-install.sh
Last active March 12, 2024 03:27 — forked from mx00s/install.sh
NixOS install script based on @grahamc's "Erase Your Darlings" blog post
#!/usr/bin/env bash
#
# NixOS "Erase Your Darlings" ZFS install script based on:
#
# - Original install script by mx00s (https://gist.github.com/mx00s/ea2462a3fe6fdaa65692fe7ee824de3e)
# - Erase Your Darlings (https://grahamc.com/blog/erase-your-darlings)
# - ZFS Datasets for NixOS (https://grahamc.com/blog/nixos-on-zfs)
# - NixOS Manual (https://nixos.org/nixos/manual/)
#
@krscott
krscott / .gitconfig
Last active June 20, 2023 02:30
My git aliases
[alias]
lol = log --oneline --graph --decorate --date-order
lola = log --oneline --graph --decorate --date-order --all
s = status -s
ka = !gitk --all --date-order
k = !gitk --date-order
pull-sm = !git pull && git submodule update --recursive && git lfs fetch --all && git lfs pull
smu = !git submodule update --init --recursive && git lfs fetch --all && git lfs pull
smr = !git reset --hard --recurse-submodule && git submodule sync --recursive && git submodule update --init --force --recursive && git submodule foreach --recursive git clean -ffdx && git lfs fetch --all && git lfs pull
@krscott
krscott / handle-missing-types.py
Created May 15, 2023 12:14
Nicely handle missing typing info
# Disable "unknown" errors and missing type stubs...
# pyright: reportUnknownMemberType=false
# pyright: reportUnknownVariableType=false
# pyright: reportUnknownArgumentType=false
# pyright: reportMissingTypeStubs=false
# ...or, alternatively, only suppress individual objects (but disables intellisense)
from typing import Any
from __future__ import annotations
from dataclasses import dataclass, asdict, is_dataclass
from typing import Any
from typing_extensions import dataclass_transform # pip install typing-extensions
import dacite # pip install dacite
import json
@dataclass_transform(kw_only_default=True)
class SerdeJson:
def __init_subclass__(cls):
@krscott
krscott / gforth_cheat_sheet.md
Created March 17, 2023 20:07 — forked from RickCarlino/gforth_cheat_sheet.md
gforth cheat sheet

Math

  • .s - Show the stack
  • +, -, *, mod - Math operators
  • /mod - performs both / and mod

Stack manipulation

  • drop and 2drop - drop a stack item (once / twice)
  • dup - duplicate a stack item
  • rot - rotate the stack
Github goto line (alternative to using 'L' hotkey):
javascript:document.getElementById(`L${prompt("Line number")}`).click()
if [[ -z "$PROMPT_HOSTNAME" ]]; then
PROMPT_HOSTNAME="\h"
fi
# Set if using __git_ps1
# GIT_PS1_SHOWDIRTYSTATE=1
# GIT_PS1_SHOWSTASHSTATE=1
# GIT_PS1_SHOWUNTRACKEDFILES=1
[ -s "/etc/bash_completion.d/git" ] && source /etc/bash_completion.d/git
@krscott
krscott / bash-template.sh
Last active January 24, 2023 19:38
Bash script template
#!/usr/bin/env bash
# exit when any command fails
set -e
trap 'echo ''; echo Error at $(basename "$0"):${LINENO}: $BASH_COMMAND' ERR
# Get this script's directory
SDIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
@krscott
krscott / pyo3-venv-debugging.md
Last active September 23, 2021 18:33
Debugging pyo3 virtualenv issues