Skip to content

Instantly share code, notes, and snippets.

View krscott's full-sized avatar

Kris Scott krscott

View GitHub Profile
@krscott
krscott / c-sips.md
Created September 10, 2025 14:28
C clipboard

C Snippets

C standard version detection

#ifndef __STDC_VERSION__
#error "C90"
#elif __STDC_VERSION__ == 202000L
#error "C23"
#elif __STDC_VERSION__ == 201710L
#!/usr/bin/env bash
set -euo pipefail
shopt -s failglob
# Bash snippets
# Change pwd to this script's dir
cd "$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
# CLI Options
@krscott
krscott / flake.nix
Last active July 15, 2025 03:07
My flake.nix starter
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nix-github-actions = {
url = "github:nix-community/nix-github-actions";
inputs.nixpkgs.follows = "nixpkgs";
};
};
@krscott
krscott / nix-sips.md
Last active August 25, 2025 01:25
Nix snippets
@krscott
krscott / program-good.md
Last active September 10, 2025 14:26
How to Program Good
@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