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 / 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 / simple_logger.rs
Created March 3, 2025 13:08
simple_logger.rs
use std::env;
use std::process;
use std::io::{self, Write};
enum LogLevel {
Error,
Warn,
Info,
Debug,
}
@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 / 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 / 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 / factorial_gamma.rs
Last active February 25, 2025 13:12 — forked from rust-play/playground.rs
factorial_gamma.rs
fn gamma(n: f64) -> f64 {
// For simplicity, we'll use a basic approximation method.
// For higher accuracy, consider using a more sophisticated algorithm or a crate
// like `special_function` (if it provides Gamma).
// We can use integration techniques like the trapezoidal rule or Simpson's rule for approximation.
// Here's a basic trapezoidal rule example:
let mut result = 0.0;
let a = 0.0;
@RandyMcMillan
RandyMcMillan / .gitignore
Last active March 3, 2025 23:29
prime_clock.rs
prime_clock
simple_logger
prime_clock.dSYM
@RandyMcMillan
RandyMcMillan / hashmap.rs
Created January 27, 2025 16:32 — forked from rust-play/playground.rs
hashmap.rs
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
#[derive(Debug, Clone)]
struct HashMap<K, V>
where
K: Eq + Hash + Clone,
V: Clone,
{
// Buckets for storing key-value pairs
@RandyMcMillan
RandyMcMillan / walk_dir.rs
Last active January 26, 2025 19:26 — forked from rust-play/playground.rs
walk_dir.rs
use std::fs;
use std::path::Path;
fn main() {
let input = "/usr/share/doc";
fn action(path: &str) { println!("\t{}" , path); }
fn walk(path: &str) {
println!("Listing {} ..." , path);
@RandyMcMillan
RandyMcMillan / print_type.rs
Last active January 26, 2025 13:46 — forked from rust-play/playground.rs
print_type.rs
use std::any::Any;
use std::fmt::Debug;
fn print_type_name<T: Any + Debug>(value: &T) {
println!("Type of {:?} is: {}", value, std::any::type_name::<T>());
}
fn main() {
let i: i32 = 42;
print_type_name(&i);