Skip to content

Instantly share code, notes, and snippets.

@decatur
decatur / iso8601.rs
Last active May 6, 2025 05:27
Parse ISO8601 date/times and validates against the proleptic Gregorian calendar with no dependencies and no_std compliant.
// Parse ISO8601 date/times and validates against the proleptic Gregorian calendar with no dependencies and no_std compliant.
//
// If you want to convert a parsed date into a unix timestamp, I recommend [tz-rs="0.7.0"](https://docs.rs/tz-rs/0.7.0) , which also has no dependencies.
//
// See also
// * https://docs.rs/iso8601/0.6.2/iso8601/
// * https://github.com/BurntSushi/jiff
/// Parses ISO8601 dates and validates against the proleptic Gregorian calendar.
/// Usage:
@decatur
decatur / template_engine.rs
Last active September 26, 2025 15:16
Rust minimal template engine
/// Minimal template string substitution in 60 lines of code.
/// * No dependencies
/// * Single pass
///
/// Possible improvements: Write more tests.
#[cfg(test)]
mod tests {
use crate::fill_template;
use std::collections::HashMap;
@decatur
decatur / presentation.typ
Last active October 16, 2025 22:54
typst presentation
#set page("presentation-4-3",
header: [#text("From MPA to SPA and Back", size: 12pt)],
margin: (top: 2cm, left: 3cm,)
)
#show heading: it => [
#set text(font: "Inria Serif")
#pagebreak()
#text(it.body)
#linebreak()
@decatur
decatur / thread_as_task_or_service.rs
Created November 4, 2025 00:11
Threads can have task xor service semantics
use std::sync::mpsc::{Sender, Receiver};
use std::sync::mpsc;
use rayon::prelude::*;
fn main() {
let (tx, rx): (Sender<u8>, Receiver<u8>) = mpsc::channel();
// Thread as an event loop (service)
// Long lived
// May use messaging and shared state
std::thread::spawn(move || {
@decatur
decatur / who_is_talking.html
Last active November 10, 2025 11:50
Keeps monitoring talking time.
<!DOCTYPE html>
<html>
<head>
<style>
.time { padding: 1em }
/* https://developer.mozilla.org/de/docs/Web/CSS/Reference/Values/system-color */
.current { background-color: ActiveText !important; }
.speaker { margin: 1ex; padding: 1em; background-color: ButtonFace; }
</style>
</head>