Skip to content

Instantly share code, notes, and snippets.

@Strikeless
Strikeless / natural_string_cmp.rs
Created May 24, 2026 14:10
Small utility useful for "natural" file name sorting, where numbers are ordered numerically instead of alphabetically
use std::{cmp::Ordering, iter};
use itertools::Itertools;
pub fn natural_string_cmp(a: &str, b: &str) -> Ordering {
let mut a_chars_iter = a.chars().peekable();
let mut b_chars_iter = b.chars().peekable();
loop {
match (a_chars_iter.next(), b_chars_iter.next()) {
@Strikeless
Strikeless / quantization.rs
Last active December 25, 2023 14:44
Small and convenient utility for intercompatibility between the image and imagequant crate. Not to be used with arbitrary input due to the unwraps. Not even near zero-copy.
use image::{Rgba, ImageBuffer};
const MAX_COLOR_MAP_SIZE: u32 = 256;
type PixelColor = Rgba<u8>;
type Image = ImageBuffer<PixelColor, Vec<u8>>;
pub struct ImageQuantization {
pub palette: Vec<PixelColor>,
pub indices: Vec<u8>,