Skip to content

Instantly share code, notes, and snippets.

View chottolabs's full-sized avatar
🚛
reincarnated

chottolabs chottolabs

🚛
reincarnated
View GitHub Profile

starting with the one that retrieved these gists

gh gist list --public | awk 'NR>1 {print $1, $2}' | parallel --colsep ' ' -j 4 gh gist clone {1} {2}

The Holy Trinity (ripgrep + fzf + bat)

type of thing you would alias away... but i have now seen the light of ripgrep + fzf + bat/batcat, honestly a good baseline check before you start trying to implement some kind of full-text search. If it doesn't beat this... then the design is not thoughtful enough.

search files

Third Law of Magic Systems: Expand what you already have before you add something new.

Result and Option

Inspired by A Simpler Way to See Results

"why do some things return result and some return option? i keep getting confused what combinators are available..." is what i thought initially, but leaning into the idea it's incredibly powerful.

  • Result as a generalization of Option, where there’s only one possible reason for missing a value - when reading a function signature, you immediately understand something about cardinality.
  • Result = Must use, Option is not

BAD

Vulnerable to TOCTOU (Time-of-Check to Time-of-Use) because you probably want to check path.is_file before attempting to read it.

Warning: this method may be error-prone, consider using try_exists() instead! It also has a risk of introducing time-of-check to time-of-use (TOCTOU) bugs.

This function will traverse symbolic links to query information about the destination file.

If you cannot access the metadata of the file, e.g. because of a permission error or broken symbolic links, this will return false.

use std::path::Path;
...
@chottolabs
chottolabs / LLVM.md
Last active September 25, 2024 03:36

MacOS

(from building Zig from source) .zshrc

export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
  1. clone maxxnino/tree-sitter-zig (https://github.com/maxxnino/tree-sitter-zig)

  2. compile the parser to replace the one installed by nvim-treesitter

gcc -shared -o ~/.local/share/nvim/lazy/nvim-treesitter/parser/zig.so -I./src src/parser.c -Os
  1. copy queries into the place where nvim-treesitter looks for it
cp queries/* ~/.local/share/nvim/lazy/nvim-treesitter/queries/zig/

TIL you can actually do this (???)

Maybe I've poked around enough w/ linux and I can just not install user applications on the machine at all...

docker context create chottolabs-remote --docker "host=ssh://chottolabs@research.local"
docker context use chottolabs-remote

e.g. running w/ my gpus

Patching a fresh ubuntu-server machine (Ubuntu 22.04.4 LTS) w/ 4x3090 - probably one of the first things you want to do.

Currently, i don't think there's a supported kernel module version on Debian 12

$ apt-cache search nvidia-open
...
nvidia-open - NVIDIA Driver meta-package, Open GPU kernel modules, latest version
nvidia-open-560 - NVIDIA Driver meta-package, Open GPU kernel modules, 560 branch-specific
nvidia-open-565 - NVIDIA Driver meta-package, Open GPU kernel modules, 565 branch-specific
perf record -F 9999 -g -o perf.data python bench.py
perf script report flamegraph --template index.html --output output/index.html
<head>
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/d3-flame-graph@4.1.3/dist/d3-flamegraph.css">
</head>

setting up debian machine from scratch

I would usually use ubuntu server by default on my ML rigs, but as I got more familiar with setting things up. Out of the box, debian doesn't really come with many things pre-installed... which is a good thing because most of the software I use is from more modern projects.

Some things I like are fd, ripgrep, hyperfine, uv, ninja

I find myself eventually installing all of these and I generally want to actually do it by hand so that I can see if anything breaks along the way.

cold start