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 / datalimits.md
Created June 24, 2025 13:18 — forked from sonnyxsm/datalimits.md
Weighing the choice of removing or keeping OP_RETURN data limits in Bitcoin Core 5/9/2025

From Bitcoin Core version 0.9.0 released:

On OP_RETURN: There was been some confusion and misunderstanding in the community, regarding the OP_RETURN feature in 0.9 and data in the blockchain. This change is not an endorsement of storing data in the blockchain. The OP_RETURN change creates a provably-prunable output, to avoid data storage schemes – some of which were already deployed – that were storing arbitrary data such as images as forever-unspendable TX outputs, bloating bitcoin's UTXO database.Storing arbitrary data in the blockchain is still a bad idea; it is less costly and far more efficient to store non-currency data elsewhere.

Pros

Limits the delays of block propagation

OP_RETURN data remains prunable

Less stress on the UTXO set, which causes the blockchain to bloat in size

Mitigates mining centralization

@RandyMcMillan
RandyMcMillan / sum_phi.rs
Created June 8, 2025 16:49 — forked from rust-play/playground.rs
sum_phi.rs
// A placeholder function for a_k.
// YOU WILL NEED TO REPLACE THIS WITH YOUR ACTUAL DEFINITION OF a_k.
fn get_a_k(_k: i32) -> f64 {
// Example: For demonstration, let's just return 1.0 for all k.
// In a real scenario, this could be:
// - a value from a lookup table (e.g., if a_k is stored in a Vec)
// - a result of a mathematical formula (e.g., k! or 1/k)
// - a coefficient of a specific series (e.g., Fourier series, Taylor series)
1.0
}
@RandyMcMillan
RandyMcMillan / pascals_triangle.rs
Last active May 31, 2025 20:51 — forked from rust-play/playground.rs
pascals_triangle.rs
fn print_pascals_triangle_in_binary(num_rows: usize) {
if num_rows == 0 {
return;
}
let mut current_row: Vec<u64> = vec![1]; // Using u64 for larger numbers
println!("{:b}", current_row[0]); // Print 1 in binary
for r in 1..num_rows {
let mut next_row: Vec<u64> = vec![1]; // First element is 1
@RandyMcMillan
RandyMcMillan / archive.rs
Last active May 31, 2025 20:53 — forked from rust-play/playground.rs
archive.rs
use std::{
io::{self, Write},
path::Path,
};
use tokio::io::AsyncWriteExt; // For async file writing
const DEST_DIR: &str = "torrents";
#[derive(Debug, serde::Deserialize)]
struct Torrent {
@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