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 / 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 {
@RandyMcMillan
RandyMcMillan / logic_gates.rs
Last active January 20, 2026 12:09 — forked from rust-play/playground.rs
logic_gates.rs
/// A collection of digital logic gate algorithms.
struct LogicGates;
impl LogicGates {
/// NOT gate: The output is the opposite of the input.
fn not(a: u8) -> u8 {
match a {
0 => 1,
_ => 0,
}
@RandyMcMillan
RandyMcMillan / varint_bitcoin.rs
Last active January 18, 2026 14:22 — forked from rust-play/playground.rs
varint_bitcoin.rs
/// A verbose example of Bitcoin's two variable integer types.
fn main() {
let value: u64 = 515;
// 1. CompactSize (Little-Endian) - Used in P2P/Transactions
let compact = encode_compact_size(value);
println!("Value: {}", value);
println!("CompactSize (LE-based) hex: {:02x?}", compact);
// 2. VarInt (Base-128 Big-Endian) - Used in LevelDB/Disk
@RandyMcMillan
RandyMcMillan / shannon_entropy.rs
Last active January 13, 2026 02:45 — forked from rust-play/playground.rs
shannon_entropy.rs
use std::collections::HashMap;
/// Calculates Shannon Entropy for a slice of data.
/// H = -sum(p(x) * log2(p(x)))
fn calculate_entropy(data: &[&str]) -> f64 {
let len = data.len() as f64;
if len == 0.0 {
return 0.0;
}
@RandyMcMillan
RandyMcMillan / rose_curves.rs
Last active January 10, 2026 15:59 — forked from rust-play/playground.rs
rose_curves.rs
use image::{ImageBuffer, Rgb};
use std::f64::consts::PI;
fn main() {
let grid_size = 11;
let cell_size = 200;
let padding = 20;
let width = grid_size * cell_size;
let height = grid_size * cell_size;
@RandyMcMillan
RandyMcMillan / guassian_pi_approx.rs
Last active January 8, 2026 15:25 — forked from rust-play/playground.rs
guassian_pi_approx.rs
use approx::assert_relative_eq;
fn gaussian_integral_approximation(start: f64, end: f64, steps: usize) -> f64 {
let dx = (end - start) / steps as f64;
let f = |x: f64| (-x.powi(2)).exp();
let mut sum = (f(start) + f(end)) * 0.5;
for i in 1..steps {
let x = start + (i as f64 * dx);
@RandyMcMillan
RandyMcMillan / killall-gpg-agent.sh
Last active January 4, 2026 18:11
killall-gpg-agent.sh
#!/bin/bash
# GPG Lock Recovery Script
echo "Cleaning up GPG processes..."
# Kill the specific PID mentioned in your error
kill -9 81453 2>/dev/null
# Kill all standard GPG components
gpgconf --kill all
killall gpg-agent 2>/dev/null