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 / rsa_example.rs
Last active May 26, 2025 21:22 — forked from rust-play/playground.rs
rsa_example.rs
use num_bigint::{BigInt, BigUint, Sign};
use num_traits::{One, Zero};
use std::str::FromStr; // For parsing BigUint from strings (e.g., hex)
// --- RSA Core Functions ---
/// Performs modular exponentiation: base^exp % modulus
fn modpow(base: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint {
// This is the core of RSA. `num-bigint` provides an optimized `modpow` method.
base.modpow(exp, modulus)
@RandyMcMillan
RandyMcMillan / generate-ssh-key
Created May 26, 2025 20:28 — forked from hongkongkiwi/generate-ssh-key
Simple one liner to generate an SSH key without a password in the default place with the comment as hostname then print out the public key for copy and paste.
HOSTNAME=`hostname` ssh-keygen -t rsa -C "$HOSTNAME" -f "$HOME/.ssh/id_rsa" -P "" && cat ~/.ssh/id_rsa.pub
@RandyMcMillan
RandyMcMillan / tri_dragon_fractal.rs
Last active May 26, 2025 16:16 — forked from rust-play/playground.rs
tri_dragon_fractal.rs
use num_complex::Complex64;
/// Calculates the next iteration of the given complex number z using the formula:
/// Z_n+1 = (Z_n^3) / (Z_n^3 + 1) + c
///
/// # Arguments
/// * `z_n` - The current complex number Z_n.
/// * `c` - The complex constant c.
///
/// # Returns
@RandyMcMillan
RandyMcMillan / fs_read_key_values.rs
Last active May 26, 2025 11:53 — forked from rust-play/playground.rs
fs_read_key_values.rs
use std::io;
use std::fs;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a dummy config.toml file for demonstration purposes
fs::write("config.toml", "key = \"value\"\nother_key = 123\nanother_string_key = \"hello world\"")?;
let contents = fs::read_to_string("config.toml")?;
println!("Contents of config.toml:\n{}", contents);
println!("------------------------------------");
@RandyMcMillan
RandyMcMillan / pi_viete.rs
Last active May 18, 2025 14:11 — forked from rust-play/playground.rs
pi_viete.rs
fn calculate_pi_vieta(iterations: u32) -> f64 {
if iterations == 0 {
return 0.0; // Or handle as an error/special case
}
let mut current_sqrt_term = 0.0f64; // Represents the nested sqrt part (e.g., sqrt(2), sqrt(2+sqrt(2)))
let mut pi_approximation = 2.0f64; // Initialize with the leading '2' in the formula
for i in 0..iterations {
if i == 0 {
@RandyMcMillan
RandyMcMillan / vec_drain.rs
Last active May 14, 2025 13:11 — forked from rust-play/playground.rs
vec_drain.rs
fn main() {
let mut numbers = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
println!(" 0 1 (2 3 4 5]");
println!("Original vector: {:?}", numbers);
#[allow(unused_variables)]
for num in numbers.clone() {
//print!("{} ", num);
}
//println!();
// We want to drain elements from
@RandyMcMillan
RandyMcMillan / file_chunker.rs
Last active May 12, 2025 12:57 — forked from rust-play/playground.rs
Code shared from the Rust Playground
#[allow(dead_code)]
fn main() {
let file = std::fs::File::open("./file_chunker.rs").unwrap();
let chunker = FileChunker::new(&file).unwrap();
chunker
.chunks(1024, Some('\n'))
.unwrap()
.iter()
.for_each(|chunk| {

Caveat Emptor

I (instagibbs) was asked to draft a statement, I feel this is a fair summation of the project's direction. I might be wrong

Retiring the 80-Byte OP_RETURN Limit

Bitcoin Core’s next release will, by default, relay and mine transactions whose OP_RETURN outputs exceed 80 bytes and allow any number of these outputs. The long-standing cap, originally a gentle signal that block space should be used sparingly for non-consensus data has outlived its utility.

@RandyMcMillan
RandyMcMillan / sha2-to-png.rs
Last active May 18, 2025 14:26 — forked from rust-play/playground.rs
sha2-to-png.rs
use image::{ImageBuffer, Rgb};
use sha2::{Digest, Sha256};
const COLORS: [&str; 256] = [
"#c4b9b8", "#879f84", "#a6814c", "#ff9966", "#aa1155", "#7a81ff", "#8e473b", "#f3dfb6",
"#dfac4c", "#4b3621", "#feff32", "#a57c5b", "#52b4ca", "#fffc79", "#879877", "#bb1133",
"#eee9d9", "#52b4d3", "#ffff81", "#4f4554", "#c68f65", "#d2e7ca", "#0000ff", "#2ee8bb",
"#eebb88", "#eddd59", "#7f5f00", "#eeaa11", "#35fa00", "#ffefd6", "#bb11aa", "#dab4cc",
"#fff0db", "#987d73", "#c4fff7", "#eae0c8", "#e2c779", "#ff4d00", "#334d41", "#f83800",
"#ddedbd", "#ffdd44", "#efd7ab", "#66eeee", "#aa3333", "#006663", "#ffb75f", "#c6bb9c",
@RandyMcMillan
RandyMcMillan / usize_overflow.rs
Created April 12, 2025 15:07 — forked from rust-play/playground.rs
Code shared from the Rust Playground
fn main() {
let max_usize = std::usize::MAX;
println!("std::usize::MAX/2: {}", std::usize::MAX / 2);
if !is_debug() {
let overflow_release = max_usize.wrapping_add(1);
println!("Overflow: {}", overflow_release); // Output in release: 0
} else {
#[warn(arithmetic_overflow)]
#[cfg(debug_assertions)]