Skip to content

Instantly share code, notes, and snippets.

@chadaustin
chadaustin / .inputrc
Created February 11, 2024 20:39
readline configuration
# Based on Cygwin /etc/skel/.inputrc
# the following line is actually
# equivalent to "\C-?": delete-char
"\e[3~": delete-char
# VT
"\e[1~": beginning-of-line
"\e[4~": end-of-line
@chadaustin
chadaustin / .tmux.conf
Last active April 28, 2024 05:36
my tmux config
# Detect the correct TERM value for new sessions.
# if-shell uses /bin/sh, so bashisms like [[ do not work.
if "[ $(tput colors) = 16777216 ]" {
set -g default-terminal "tmux-direct"
} {
if "[ $(tput colors) = 256 ]" {
set -g default-terminal "tmux-256color"
} {
set -g default-terminal "tmux"
}
@chadaustin
chadaustin / palettetest.rs
Created January 22, 2024 08:26
Tests animating the ANSI color palette
#!/usr/bin/env -S rust-script -t nightly
#![allow(dead_code)]
#![feature(unix_sigpipe)]
use std::io::Write;
fn title(t: &str) {
println!("{}\n{:-<2$}", t, "", t.len())
}
@chadaustin
chadaustin / detect-mosh.rs
Created January 18, 2024 07:37
Script to detect whether mosh-server is a parent process
#!/usr/bin/env rust-script
//! ```cargo
//! [dependencies]
//! anyhow = "1"
//! libc = "0.2"
//! procfs = { version = "0.16", default-features = false }
//! ```
use procfs::process::Process;
@chadaustin
chadaustin / colortest.rs
Created January 2, 2024 04:52
Detect Terminal Color and Character Attribute Support
#!/usr/bin/env -S rust-script -t nightly
#![feature(unix_sigpipe)]
use std::cmp::max;
const BASIC_COLORS: &[&str] = &[
"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white",
];
fn title(t: &str) {
#!/usr/bin/env rust-script
//! ```cargo
//! [dependencies]
//! anyhow = "1"
//! libc = "0.2"
//! procfs = "0.16"
//! ```
use procfs::process::Process;
use std::collections::VecDeque;
use std::future::Future;
use std::pin::Pin;
use std::sync::atomic::AtomicUsize;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll, Waker};
struct State<T> {
queue: VecDeque<T>,
tx_count: usize,
0eNq9XctuHUeS/ZWG1mYj3w9vZzW72Q8aA0q6tomhSA4fjTYa/ve5ktzNsliRdc4J6+4kUTwRGZWZERnPf757f/tyeni8uXt+9+M/3918uL97evfjf//z3dPNz3fXt5//7fnXh9O7H9/dPJ8+vfvh3d31p89/+3B//uFvP7y7uft4+se7H+NvPxz+ysPt9dPzzYer99ePm99Mv/3th3enu+eb55vTV8pf/vLr/9y9fHp/ejxD/xvgp/PvXz0/Xt89Pdw/Pl+9P90+n9Ef7p/Ov3t/95nuGe8qpvLX+sO7X8+/GeNf65nSx5vH04ev/6V85vMbAslBICAEMk2gcisoDgLQCurrR7x5OF0931/9/Hj/cvdxD/sz4ob5HbSmoUGcdgI7tCNOh4YGcTrZjxbIjxaDgwK07yJ9NgN5NmNyUMCk9Ho6T/94eDw9PV09PdzePD+ff7h7cn4HzxB4cdwtCaJQHWcfo/DH47oLmf66FcseSD8GyYcg4xgkHILMY5B4BJLCIUgchyDxGGQegqRjkHYIko9B+iFIOQYphyD1GKQeghzv2Hi4Y9Pxjo2HOzYNxxUMnc7kUSPQHZaD4wrGKHjUCCSlnN5c8mctfnr8qs2Ry7i8IfPDv63cu4eX53d7VL8x/CCS1Ufy+BBuFlX3d21mzL3NtV0MuKbB1W/X3/bAGYNvox3egKc98Nfj+/7+5nbfIthc9PvLnwhIXYOUgICkA5CoGd4FeoMAiigc7bySHbcZxmZxUKgQheq4zTAKzUEBk1L33pfdvrzuX56N26sM14Wp0ZzMBfK6wLa/g+vrQQVM8WDzvncf1dcDfHP3dHo03igbq7FBr/tE8LwBx3jODPggwQsD3knwyoA3Erxhn7KQn7IzPFeS58GAFxJ8YgLJnEAacx434BDPTVSoxt3RkkM3YdLIDs2BUSiUOyXYd/ceePWqpSHY1K25tJJEsjNm/DS2E+AuqYcgr8fywy+nTzcfrm+vHm6v757XjpP0xvd2FuL5zzdf1v10f3v
@chadaustin
chadaustin / Coal to Plastic
Last active December 12, 2020 09:10
Factorio Blueprints
0eNq9XctuHUeS/ZWG1qaR74cXs5kfmP2gMaCka5sYiuTwYbTR8L/PleRulqSKrHNOWHcnieKJyKjMjMh4/vPN29uX08Pjzd3zm5/++ebm3f3d05uf/vufb55ufrm7vv34b8+/P5ze/PTm5vn04c0Pb+6uP3z827v78w//+OHNzd370z/e/BT/+OHwVx5ur5+eb95dvb1+3Pxm+uPvP7w53T3fPN+cPlP+9Jff/+fu5cPb0+MZ+t8AP59//+r58fru6eH+8fnq7en2+Yz+cP90/t37u490z3hXMZUf6w9vfj//Zow/1jOl9zePp3ef/0v5yOdXBJKDQEAIZJpA5VZQHASgFdTXj3jzcLp6vr/65fH+5e79HvZHxA3zO2hNQ4M47QR2aEecDg0N4nSyHy2QHy0GBwVo30X6bAbybMbkoIBJ6fV0nv7x8Hh6erp6eri9eX4+/3D35PwJniHw4rhbEkShOs4+RuHL47oLmX7cimUPpB+D5EOQcQwSDkHmMUg8AknhECSOQ5B4DDIPQdIxSDsEyccg/RCkHIOUQ5B6DFIPQY53bDzcsel4x8bDHZuG4wqGTmfyqBHoDsvBcQVjFDxqBJJSTt9c8mctfnr8rM2Ry7h8Q+aHf1u5dw8vz2/2qH5l+EEkq4/k8SHcLKru79rMmHuba7sYcE2Dq1+vv+2BMwbfRjt8A572wF+P79v7m9t9i2Bz0e8vfyIgdQ1SAgKSDkCiZngX6A0CKKJwtPNKdtxmGJvFQaFCFKrjNsMoNAcFTErde192+/K6f3k2bq8yXBemRnMyF8jrAtv+Dq6vBxUwxYPN+959VF8P8M3d0+nReKNsrMYGve4TwfMGHOM5M+CDBC8MeCfBKwPeSPCGfcpCfsrO8FxJngcDXkjwiQkkcwJpzHncgEM8N1GhGndHSw7dhEkjOzQHRqFQ7pRg39174NWrloZgU7fm0koSyc6Y8dPYToC7pB6CvB7Ld7+ePty8u769eri9vnteO07SN763sxDPf775tO6n+9u
fn imagehash(path: &Path) -> std::io::Result<Digest> {
let mut f = File::open(path)?;
let mut buffer = [0u8; 1024*1024];
let mut context = Context::new();
loop {
let read = f.read(&mut buffer)?;
if 0 == read {
return Ok(context.compute());
}