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 / lamport_with_breach.rs
Last active February 16, 2026 17:58 — forked from rust-play/playground.rs
lamport_with_breach.rs
use sha2::{Digest, Sha256};
use std::collections::HashSet;
use rand_0_8_5/*_0_9_2*/::{RngCore, thread_rng};
/// For a 256-bit security level, we need 256 pairs of preimages (512 total).
const BITS: usize = 256;
/// The Private Key: Two lists (Secret-0 and Secret-1).
struct PrivateKey {
pairs: [[[u8; 32]; BITS]; 2],
@RandyMcMillan
RandyMcMillan / detach.js
Created February 15, 2026 14:30 — forked from piscisaureus/detach.js
detach.js
var spawn = require('child_process').spawn;
// spawn_detached(file, [args = []], [options = {}], [callback]);
function spawn_detached(file, args, options, callback) {
if (arguments.length == 2 &&
typeof args == 'function') {
callback = arguments[1];
args = undefined;
}
@RandyMcMillan
RandyMcMillan / microgpt.py
Created February 15, 2026 14:11 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and inference a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@RandyMcMillan
RandyMcMillan / mini_gpt.rs
Last active February 14, 2026 20:57 — forked from rust-play/playground.rs
mini_gpt.rs
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader, Read, Write, Result};
/* ------------------------------------------------------------------ */
/* Model hyper-parameters */
/* ------------------------------------------------------------------ */
const N_EMBD: usize = 32;
const N_HEAD: usize = 4;
const N_LAYER: usize = 1;
@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 / artificial_neuron.rs
Last active February 18, 2026 13:15 — forked from rust-play/playground.rs
artificial_neuron.rs
use ndarray::Array1;
use rand::Rng;
// The playground often requires RngExt for sampling distributions
use rand::distr::{Distribution, StandardUniform};
#[derive(Debug)]
enum Activation {
Logistic,
ReLU,
Linear,
@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>>>,