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 / moon_cat.rs
Last active March 28, 2025 21:52 — forked from rust-play/playground.rs
moon_cat.rs
fn print_moon_phases() {
let moon_phases = [
"🌕🌕🌕🌕🌕🌕🌕🌕🌕🌕🌕🌕",
"🌕🌕🌕🌒🌕🌖🌒🌕🌕🌕🌕🌕",
"🌕🌕🌖🌑🌓🌑🌑🌕🌕🌕🌕🌕",
"🌕🌕🌗🌑🌑🌑🌑🌔🌕🌕🌕🌕",
"🌕🌕🌘🌙🌑🌙🌑🌔🌖🌑🌕🌕",
"🌕🌕🌖🌑🌑🌑🌑🌕🌕🌑🌔🌕",
"🌕🌕🌕🌖🌑🌑🌔🌕🌕🌑🌔🌕",
"🌕🌕🌕🌘🌑🌑🌒🌕🌕🌑🌔🌕",
@RandyMcMillan
RandyMcMillan / sorted_hashmap.rs
Last active February 28, 2025 12:08 — forked from rust-play/playground.rs
sorted_hashmap.re
use std::collections::HashMap;
fn main() {
let mut hashmap: HashMap<i32, (i32, i32)> = HashMap::new();
for count in 0..1000 {
hashmap.insert(count, (count, count % 13));
}
let mut sorted_vec: Vec<(&i32, &(i32, i32))> = hashmap.iter().collect();
@RandyMcMillan
RandyMcMillan / index_prime_position.rs
Last active February 28, 2025 12:39 — forked from rust-play/playground.rs
index_prime_position.rs
use std::collections::HashMap;
fn is_prime(n: i32) -> bool {
if n <= 1 {
return false;
}
let mut i = 2;
while i * i <= n {
if n % i == 0 {
return false;
@RandyMcMillan
RandyMcMillan / make-to-just.sh
Created March 6, 2025 17:39 — forked from mnoumanshahzad/make-to-just.sh
Port Makefile targets to Justfile recipes to enable incremental deprecation of Makefile usage
#!/bin/bash
# Name of the Makefile to be converted
MAKEFILE="Makefile"
# Name of the output Justfile
JUSTFILE="Justfile"
# Check if the Makefile exists
if [ ! -f "$MAKEFILE" ]; then
@RandyMcMillan
RandyMcMillan / parse_env_args.rs
Created March 12, 2025 13:07 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::env;
fn main() {
let mut args: Vec<String> = env::args().collect();
let mut verbose = false;
let mut output_file: Option<String> = None;
args.push("-v".to_string());
args.push("-o".to_string());
args.push("test.txt".to_string());
let mut i = 1; // Start from 1 to skip the executable path
@RandyMcMillan
RandyMcMillan / parse_env_args_count.rs
Last active March 12, 2025 19:50 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::env;
fn main() {
let mut args: Vec<String> = env::args().collect();
let mut verbose_count = 0;
let mut output_count = 0;
let mut output_files: Vec<String> = Vec::new();
// Simulating command-line arguments (for testing)
args.push("-v".to_string());
@RandyMcMillan
RandyMcMillan / pi_mantissa_hex.rs
Created March 14, 2025 17:43 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::f64;
use std::u8;
#[allow(dead_code)]
fn print_gnostr() {
let s = "gnostr";
for byte in s.as_bytes() {
print!("{:02X} ", byte);
}
@RandyMcMillan
RandyMcMillan / if_git.rs
Created March 15, 2025 12:10 — forked from rust-play/playground.rs
if_git.rs
use std::process::Command;
fn main() {
if is_git_installed() {
println!("Git is installed. Initializing Git repository...");
if let Err(e) = initialize_git_repo() {
eprintln!("Failed to initialize Git repository: {}", e);
} else {
println!("Git repository initialized successfully.");
}
@RandyMcMillan
RandyMcMillan / psuedo_rand_bloch_vec.rs
Last active March 22, 2025 15:18 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::time::{SystemTime, UNIX_EPOCH};
const EPSILON_TWEAK: f64 = f64::EPSILON * /*adjust for granularity*/ 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct BlochVector {
pub x: f64,
pub y: f64,
pub z: f64,
}
@RandyMcMillan
RandyMcMillan / global_rt.rs
Created March 26, 2025 04:04 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use once_cell::sync::OnceCell;
// global_rt
pub fn global_rt() -> &'static tokio::runtime::Runtime {
static RT: OnceCell<tokio::runtime::Runtime> = OnceCell::new();
RT.get_or_init(|| tokio::runtime::Runtime::new().unwrap())
}
#[cfg(test)]
mod tests {