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 / 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| {
@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 / 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 {