Skip to content

Instantly share code, notes, and snippets.

View RandyMcMillan's full-sized avatar
🛰️
Those who know - do not speak of it.

@RandyMcMillan RandyMcMillan

🛰️
Those who know - do not speak of it.
View GitHub Profile
@RandyMcMillan
RandyMcMillan / peace_effort.rs
Last active February 12, 2026 03:51 — forked from rust-play/playground.rs
peace_effort.rs
// Dependencies used: tokio, hyper, hyper-util, http-body-util, serde, serde_json, url
use http_body_util::Full;
use hyper::body::Bytes;
use hyper::server::conn::http1;
use hyper::service::service_fn;
use hyper::{Request, Response, StatusCode};
use hyper_util::rt::TokioIo;
use std::net::SocketAddr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
@RandyMcMillan
RandyMcMillan / tetrahedron.rs
Last active February 9, 2026 13:28 — forked from rust-play/playground.rs
tetrahedron.rs
use nalgebra::{DMatrix, DVector};
use ndarray::{Array1, Array2, Axis};
struct Simplex;
impl Simplex {
pub fn volume_lagrange(vertices: &Array2<f64>) -> f64 {
let (num_pts, dim) = vertices.dim();
assert_eq!(num_pts, dim + 1);
// Explicitly annotate Vec<f64> to satisfy the compiler
@RandyMcMillan
RandyMcMillan / bayes_theorum.rs
Last active February 9, 2026 02:57 — forked from rust-play/playground.rs
bayes_theorum.rs
struct Probability {
value: f64,
}
impl Probability {
fn new(p: f64) -> Self {
assert!(
(0.0..=1.0).contains(&p),
"Probability must be between 0 and 1"
);
@RandyMcMillan
RandyMcMillan / landauer_principle.rs
Last active February 7, 2026 03:02 — forked from rust-play/playground.rs
landauer_principle.rs
/// Exploring Landauer's Principle with Joule and BTU heat dissipation.
use std::f64::consts::LN_2;
const BOLTZMANN_CONSTANT: f64 = 1.380649e_23;
const JOULES_TO_BTU: f64 = 9.4781712e_4;
// --- 1. Logic Gate Definitions ---
#[allow(unused)]
#[derive(Debug, Clone, Copy)]
enum Gate {
@RandyMcMillan
RandyMcMillan / morse_binary_tree.rs
Last active February 4, 2026 16:51 — forked from rust-play/playground.rs
morse_binary_tree.rs
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::HashMap;
use anyhow::{anyhow, Result};
/// A node in our Morse Virtual Circuit binary tree.
#[derive(Debug, Default)]
struct Node {
value: Option<char>,
dot: Option<Rc<RefCell<Node>>>,
@RandyMcMillan
RandyMcMillan / Copeland-Erdős_Constant.rs
Last active February 2, 2026 23:22 — forked from rust-play/playground.rs
Copeland-Erdős_Constant.rs
// To run this, you can use: cargo run
// Or if using a single file: rustc constants.rs && ./constants
use std::fmt::Write;
/// Generates the Champernowne constant string: 0.123456789101112...
fn generate_champernowne(n_digits: usize) -> String {
let mut result = String::from("0.");
let mut current = 1;
@RandyMcMillan
RandyMcMillan / get_library_reports.rs
Last active January 25, 2026 18:41 — forked from rust-play/playground.rs
get_library_reports.rs
use anyhow::Context;
use serde::Serialize;
use std::hash::{Hash, Hasher};
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
#[derive(Serialize)]
struct LibReport {
name: String,
fingerprint: String,
@RandyMcMillan
RandyMcMillan / verify_libraries.rs
Last active January 25, 2026 18:14 — forked from rust-play/playground.rs
verify_libraries.rs
/// This macro takes a list of crate names and "touches" them
/// by referencing their absolute path. If the crate is missing,
/// the code will fail to compile.
macro_rules! verify_libraries {
($($lib:ident),*) => {
println!("--- Verifying Library Linkage ---");
$(
// We use a statement that references the crate without side effects
let _ = stringify!($lib);
println!("✅ [{}] is linked and accessible.", stringify!($lib));
@RandyMcMillan
RandyMcMillan / myip.rs
Last active January 26, 2026 05:15 — forked from rust-play/playground.rs
myip.rs
use anyhow::{anyhow, Result};
use serde::Deserialize;
use async_trait::async_trait; // Using async-trait from your list
#[derive(Debug, Deserialize, Clone)]
struct SimpleIpResponse {
ip: String,
}
// 1. Define a trait for the fetching logic
@RandyMcMillan
RandyMcMillan / tesseract.rs
Last active January 24, 2026 18:29 — forked from rust-play/playground.rs
tesseract.rs
/// Represents a point in 4D space
#[derive(Debug, Clone, Copy)]
struct Point4D {
x: i32,
y: i32,
z: i32,
w: i32,
}
impl Point4D {