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 / async_trait_json.rs
Last active December 21, 2025 12:57 — forked from rust-play/playground.rs
async_trait_json.rs
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use thiserror::Error;
use anyhow::{Context, Result};
use std::time::Duration;
use tokio::task::JoinSet;
use std::sync::Arc;
// --- 1. Error Definitions ---
@RandyMcMillan
RandyMcMillan / RMS-Norm.rs
Last active December 20, 2025 14:30 — forked from rust-play/playground.rs
RMS-Norm.rs
use ndarray::{Array1, Array2, Axis}; // ndarray 0.16.1
use num_traits::Float; // num-traits 0.2.19
pub struct RmsNorm {
pub weight: Array1<f32>,
pub eps: f32,
}
impl RmsNorm {
pub fn new(dim: usize, eps: f32) -> Self {
@RandyMcMillan
RandyMcMillan / detach_process.rs
Last active December 17, 2025 21:44 — forked from rust-play/playground.rs
detach_process.rs
use clap::Parser;
use libc::{dup2, fork, setsid, STDERR_FILENO, STDIN_FILENO, STDOUT_FILENO};
use log::{info, error};
use std::fs::File;
use std::os::unix::io::AsRawFd;
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(author, version, about = "A detached Rust background service")]
struct Args {
@RandyMcMillan
RandyMcMillan / cmd.sh
Created December 14, 2025 15:49 — forked from colinhacks/cmd.sh
no-http-clones
git config --global url."git@github.com:".insteadof "https://github.com/"
@RandyMcMillan
RandyMcMillan / byzantine_quorum.rs
Last active December 3, 2025 15:12 — forked from rust-play/playground.rs
byzantine_quorum.rs
use std::collections::HashMap;
use rand::{seq::SliceRandom, thread_rng};
// --- BQS Constants ---
// Maximum number of Byzantine faults (f or b) the system can tolerate.
const F: u32 = 4;
// The required supermajority count for a client to accept a value as correct.
// A value is only considered valid if F + 1 servers report it, allowing the
// client to mask 'F' colluding malicious responses.
@RandyMcMillan
RandyMcMillan / minimal_crust.rs
Last active December 2, 2025 16:35 — forked from rust-play/playground.rs
minimal_crust.rs
// main.rs - A minimal Crust program with tests
//
#![cfg_attr(not(test), no_std)]
#![cfg_attr(not(test), no_main)]
extern crate libc;
#[cfg(not(test))]
use core::panic::PanicInfo;
@RandyMcMillan
RandyMcMillan / lojban_gemini.rs
Last active November 30, 2025 20:46 — forked from rust-play/playground.rs
lojban_gemini.rs
// --- Dependencies ---
// This simple example relies only on standard library features.
use std::error::Error;
use std::fmt;
// --- Error Handling ---
/// A simple custom error type for parsing issues.
#[derive(Debug)]
struct ParseError {
@RandyMcMillan
RandyMcMillan / divisibility.rs
Last active November 25, 2025 15:45 — forked from rust-play/playground.rs
divisibility.rs
// The core concept is that for a number 'n', if 'n % d == 0', then 'n' is divisible by 'd'.
// Divisibility tests rely on properties of the digits.
/// 🔢 Divisibility Tests Module
mod divisibility_tests {
// Helper function to get the sum of digits
pub fn sum_digits(n: u64) -> u64 {
let mut sum = 0;
let mut num = n;
while num > 0 {
@RandyMcMillan
RandyMcMillan / gamma_1_2_squared.rs
Last active November 19, 2025 19:14 — forked from rust-play/playground.rs
gamma_1_2_squared.rs
// Verbose Script: Corrected Floating-Point Comparison
fn main() {
// ----------------------------------------------------
// 1. Define Constants
// ----------------------------------------------------
const PI: f64 = std::f64::consts::PI;
let gamma_one_half: f64 = PI.sqrt();
@RandyMcMillan
RandyMcMillan / grind.py
Created November 19, 2025 00:39 — forked from djkazic/grind.py
import secrets
from statistics import mean
# secp256k1 parameters
p = 2**256 - 2**32 - 977
b = 7 # y^2 = x^3 + 7
def is_quadratic_residue(n):
"""Return True if n is a quadratic residue mod p (including 0)."""
if n == 0: