Skip to content

Instantly share code, notes, and snippets.

View sam0x17's full-sized avatar

sam0x17 sam0x17

View GitHub Profile
@sam0x17
sam0x17 / optimize.md
Last active June 17, 2026 13:30
/optimize claude skill for optimizing performance of a codebase that has benchmarks
name optimize
description Continuously iterate on a codebase to improve benchmark performance. Runs benchmarks, makes targeted optimizations, compares against baseline, validates improvements, and reverts regressions. Keeps looping until tangible improvements are achieved.
argument-hint [benchmark-command]
effort max

Optimizer — Iterative Benchmark Optimizer

You are an iterative performance optimizer. Your job is to repeatedly run benchmarks,

name cold-read
description Two-pass cold-reader review of a written work — paper, book, whitepaper, design doc, spec, or a code repo's README/docs — simulating a fresh reader. Auto-locates the primary artifact to review, tracks observations across two passes, and reports a synthesized punch list. Accepts optional focus arguments.

Cold Read

Perform a thorough cold-reader review of a repository's primary written artifact, simulating a fresh reader encountering it for the first time, and report back with substantive observations.

Strict process rules

@sam0x17
sam0x17 / fix_docker.sh
Created May 15, 2026 14:26
Fix docker upon restoring mac OS backup
# Quit Docker Desktop first, then:
rm -rf ~/Library/Containers/com.docker.docker/Data/vms
rm -rf ~/Library/Group\ Containers/group.com.docker/VirtualMachines
@sam0x17
sam0x17 / postgres_setup.sh
Created July 9, 2024 01:21
mac os postgresql setup 2024
#!/bin/sh
brew update
brew upgrade
brew install postgresql
createuser -s postgres
brew services start postgresql
@sam0x17
sam0x17 / keybase.md
Created November 30, 2023 21:48
keybase.md

Keybase proof

I hereby claim:

  • I am sam0x17 on github.
  • I am sam0x17 (https://keybase.io/sam0x17) on keybase.
  • I have a public key ASD59tnchzvt33Gvmfz_J-ooAwmgcVE5dopA3Nkd9RgNrwo

To claim this, I am signing this object:

@sam0x17
sam0x17 / evil_rust.rs
Created August 18, 2023 06:05
evil rust
trait RawBytes: Sized {
fn raw_bytes(&self) -> &[u8] {
let ptr = self as *const Self as *const u8;
unsafe { core::slice::from_raw_parts(ptr, std::mem::size_of::<Self>()) }
}
}
impl<T> RawBytes for T {}
@sam0x17
sam0x17 / question_closure_trick.rs
Created July 26, 2023 15:49
Rust workaround for "the `?` operator can only be used in a closure that returns `Result` or `Option`" when trying to use `?` inside a closure inside a `.map`
let const_fns: Vec<TraitItemFn> = const_fns
.into_iter()
.map(|item| match item {
TraitItem::Fn(trait_item_fn) => Ok(*trait_item_fn),
_ => return Err(Error::new(item.span(), "expected `fn`")),
})
.collect::<std::result::Result<_, Self::Error>>()?;
@sam0x17
sam0x17 / const_str_eq.rs
Created July 20, 2023 15:59
Rust const_str_eq
pub const fn const_str_eq(a: &str, b: &str) -> bool {
if a.as_bytes().len() != b.as_bytes().len() {
return false;
}
let mut i = 0;
while i < a.as_bytes().len() {
if a.as_bytes()[i] != b.as_bytes()[i] {
return false;
}
i += 1;
@sam0x17
sam0x17 / assert_impl.rs
Last active July 4, 2023 03:58
rust assert_impl!
macro_rules! assert_impl {
($typ:ty, $($trait:path),*$(,)?) => {
{
const fn _assert_impl<T>()
where
T: $($trait +)* ?Sized,
{}
_assert_impl::<$typ>();
}
}
@sam0x17
sam0x17 / modules_in_rust.md
Last active October 12, 2023 15:31
Cheat sheet / beginner guide for how modules work in Rust
mod some_mod;

Simply means "there exists some file called some_mod.rs in this directory, or there exists some directory called some_mod in this directory that contains a file called mod.rs. Typing this line will make whatever content contained within the file (some_mod/mod.rs or some_mod.rs) available in this file via some_mod::whatever.

So Rust source files are modules. There is also a handy inline syntax for defining a short sub-module in the current file/module without needing to have a separate file for this module. This syntax is the source of confusion for a lot of people as it makes them think they have to write mod some_mod { to define any modules. Nope, this is just an inline shortcut for making a separate file and putting stuff in there, like the following:

mod some_other_mod {
 // stuff in here