Skip to content

Instantly share code, notes, and snippets.

View lmmx's full-sized avatar
💡
lights, camera, action

Louis Maddox lmmx

💡
lights, camera, action
View GitHub Profile
@lmmx
lmmx / main.rs
Last active May 16, 2025 20:32
spez! macro monomorphisation to detect type parameterised Spans
//! ```cargo
//! [dependencies]
//! spez = "0.1.2"
//! ```
use spez::spez;
use core::marker::PhantomData;
#[derive(Debug)] pub enum Cooked {}
#[derive(Debug)] pub enum Raw {}
@lmmx
lmmx / helper.sh
Created May 10, 2025 15:29
Loop through workspace crates running tests one by one to review outputs
for x in *-*; do pushd $x >/dev/null; echo $x; cargo test -q --no-run; just -f ../Justfile -d . test; read dummyvar; popd; clear; done
@lmmx
lmmx / find-distinct-dup-versions.sh
Created May 8, 2025 16:59
Find Rust dependencies with distinctly versioned duplicates
cargo tree -e no-dev --duplicates --depth 0 | sed '/^$/d' | grep -v 'dependencies]' | uniq | cut -d ' ' -f 1 | uniq -d
@lmmx
lmmx / gh-set-upstream.sh
Created May 8, 2025 16:51
Set upstream on a repo you forked with gh after cloning
gh repo set-default $(git remote get-url upstream | sed 's/.*github.com[:/]\(.*\).git/\1/')
@lmmx
lmmx / sync_fork.sh
Created April 25, 2025 12:54
Sync your remote git repo with its upstream (default branch), so you can then pull the changes to your local repo
function sync-fork() {
local origin_url=$(git config --get remote.origin.url)
local fork_repo=""
if [[ $origin_url =~ github\.com[:/]([^/]+/[^/.]+) ]]; then
fork_repo="${BASH_REMATCH[1]}"
else
echo "Error: Could not parse origin remote URL"
return 1
fi
local upstream_url=$(git config --get remote.upstream.url)
@lmmx
lmmx / script.sh
Last active March 24, 2025 15:34
All the things I needed to install to run the Dioxus 0.6 demo tutorial (line 1 via https://github.com/DioxusLabs/dioxus/blob/9e09bcf3f79aa7b349da23ca80cb2a214230562b/notes/CONTRIBUTING.md?plain=1#L6)
sudo apt install libgdk3.0-cil libatk1.0-dev libcairo2-dev libpango1.0-dev libgdk-pixbuf2.0-dev libsoup-3.0-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev libxdo-dev -y
@lmmx
lmmx / gifopt.sh
Created March 23, 2025 13:48
Gif optimisation using gifski, a fast Rust GIF encoder https://github.com/ImageOptim/gifski/
gifopt() {
local inputgif="${1:?Missing input GIF filename}"
local quality="${2:-80}"
if ! [[ "$quality" =~ ^[0-9]+$ ]] || [ "$quality" -lt 1 ] || [ "$quality" -gt 100 ]; then
echo "Quality parameter must be an integer from 1 to 100" >&2
return 1
fi
local tmpdir="$(mktemp -d)"
@lmmx
lmmx / Cargo.toml
Last active March 21, 2025 16:52
A minimal Rust + WASM demo simulating 2,000 vehicles (buses/trains) moving on a canvas, using a shared `RefCell` for state https://qrx.spin.systems/transport-network-sim/
[package]
name = "trunk-hello-world"
version = "0.1.0"
edition = "2024"
[lib]
crate-type = ["cdylib"]
path = "lib.rs"
[dependencies]
@lmmx
lmmx / Cargo.lock
Last active March 25, 2025 14:21
A simple Rust & WebAssembly example that uses a thread-local RefCell to manage shared state, updated via an HTML slider.
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bumpalo"
version = "3.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
@lmmx
lmmx / one_liner.sh
Last active May 12, 2025 22:49
Merge all dependency bot PRs (e.g. pre-commit)
PR_CMDS=$(gh search prs --limit 100 --owner $(gh api user -q '.login') --author pre-commit-ci[bot] --state open --json repository,number | jq -r '.[] | "gh pr merge \(.number) -R \(.repository.nameWithOwner) -s -d"' | awk '{printf "%s%s", (NR==1 ? "" : " && \n"), $0} END{print ""}'); echo "$PR_CMDS"; eval "$PR_CMDS"