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 / 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:
import secrets
# secp256k1 parameters
p = 2**256 - 2**32 - 977
a = 0
b = 7
def random_256bit_int():
# random 32-byte string interpreted as big-endian integer
return int.from_bytes(secrets.token_bytes(32), "big")
#!/usr/bin/env python3
import sys
import secrets
from statistics import mean
p = 2**256 - 2**32 - 977
b = 7 # y^2 = x^3 + 7
def is_quadratic_residue(n):
return n == 0 or pow(n, (p - 1) // 2, p) == 1
@RandyMcMillan
RandyMcMillan / 3D-Ulam-Spiral.rs
Last active November 16, 2025 03:01 — forked from rust-play/playground.rs
3D-Ulam-Spiral.rs
// a 3D Ulam Spiral
// projected onto a 2D grid,
// marking primes with their Z-index.
/// Generates a boolean vector where `is_prime[i]` is true if `i` is a prime number (Sieve of Eratosthenes).
fn sieve_of_eratosthenes(max_value: usize) -> Vec<bool> {
if max_value < 2 { return vec![]; }
let mut is_prime = vec![true; max_value + 1];
is_prime[0] = false;
is_prime[1] = false;
@RandyMcMillan
RandyMcMillan / cantor_diagonal.rs
Last active November 15, 2025 11:56 — forked from rust-play/playground.rs
cantor_diagonal.rs
use std::fmt::{self, Display};
// Define a type alias for a binary sequence (a vector of 0s and 1s)
type BinarySequence = Vec<u8>;
/// Attempts to demonstrate Cantor's Diagonal Argument.
///
/// It generates a list of sample binary sequences and constructs a new
/// diagonal sequence that is guaranteed to not be in the list.
fn main() {
@RandyMcMillan
RandyMcMillan / archmedes_pi.rs
Last active November 14, 2025 20:03 — forked from rust-play/playground.rs
archmedes_pi.rs
// Filename: archimedes_pi.rs
/// Approximates pi using Archimedes' method by iteratively calculating
/// the semi-perimeter of an inscribed regular polygon with 2^(k+1) sides
/// in a unit circle (r=1).
///
/// The formula used here is an iterative approach for the semi-perimeter (P_n),
/// where P_n is the semi-perimeter of the n-sided polygon.
///
/// # Arguments
@RandyMcMillan
RandyMcMillan / theodorus.rs
Last active November 7, 2025 12:20 — forked from rust-play/playground.rs
theodorus.rs
use num_traits::Float;
/// Calculates the lengths of the hypotenuses in the Spiral of Theodorus,
/// which are the square roots of integers starting from sqrt(2).
fn calculate_theodorus_hypotenuses<F: Float>(count: u32) -> Vec<F> {
// We want roots from sqrt(2) up to sqrt(count + 1).
// The number of triangles is 'count'.
let mut lengths = Vec::with_capacity(count as usize);
// The length of the first hypotenuse (the base of the spiral) is sqrt(1^2 + 1^2) = sqrt(2).
@RandyMcMillan
RandyMcMillan / git_vfs_v2.rs
Last active November 6, 2025 15:38 — forked from rust-play/playground.rs
git_vfs_v2.rs
use sha2::{Digest, Sha256};
use std::collections::{HashMap, HashSet};
use std::fs;
use std::io::{self, Read};
use serde::{Serialize, Deserialize};
use chrono::Utc;
// APPROVED DEPENDENCY: Using data_encoding for all hex operations
use data_encoding::HEXUPPER;
// ====================================================================
@RandyMcMillan
RandyMcMillan / git_vfs.rs
Last active November 6, 2025 15:29 — forked from rust-play/playground.rs
git_vfs.rs
use sha2::{Digest, Sha256};
use std::collections::{HashMap, HashSet};
use std::fs;
use std::io::{self, Read};
use serde::{Serialize, Deserialize};
use chrono::Utc;
// APPROVED DEPENDENCY: Using data_encoding for all hex operations
use data_encoding::HEXUPPER;
// ====================================================================
@RandyMcMillan
RandyMcMillan / bind_port_scan.rs
Last active November 6, 2025 13:42 — forked from rust-play/playground.rs
bind_port_scan.rs
use std::net::{TcpListener, TcpStream, /*ToSocketAddrs, */SocketAddr};
use std::time::Duration;
use std::thread;
use std::io::{self, Read, Write};
// --- Configuration ---
const TARGET_IP: &str = "127.0.0.1"; // The IP the scanner checks
const TIMEOUT_MS: u64 = 500; // Connection timeout in milliseconds
// ---------------------