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 / future_ready.rs
Last active January 10, 2025 16:29 — forked from rust-play/playground.rs
future_ready.rs
use futures::future::ready;
use std::future::Future;
async fn future_test() -> String {
"test".to_string()
}
fn future_test2() -> impl Future<Output=String> {
ready("test2".to_string())
}
@RandyMcMillan
RandyMcMillan / pi_pow.rs
Last active January 10, 2025 16:29 — forked from rust-play/playground.rs
pi_pow.rs
use std::f64::consts::PI;
fn main() {
let mut sum = 0.0;
let mut term = 1.0;
let mut k = 0;
loop {
sum += term;
k += 1;
@RandyMcMillan
RandyMcMillan / chunk_slice.rs
Last active January 10, 2025 16:31 — forked from rust-play/playground.rs
chunk_slice.rs
fn foo(slice: &[u8]) -> (&str, Option<&[u8]>) {
let mut iter = slice.utf8_chunks();
// Annoying behavior of this iterator
let Some(chunk) = iter.next() else {
return (std::str::from_utf8(slice).unwrap(), None)
};
let head = chunk.valid();
if head.len() < slice.len() {
(head, Some(&slice[head.len()..]))
@RandyMcMillan
RandyMcMillan / hash_map_count.rs
Last active January 10, 2025 16:33 — forked from rust-play/playground.rs
hash_map_count.rs
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
fn main() {
let mut counts = HashMap::new();
for i in 0..=144 {
let hash = hash_value(&i);
println!("{}",hash);
@RandyMcMillan
RandyMcMillan / std_hash.rs
Last active March 12, 2025 16:10 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
fn main() {
let mut counts = HashMap::new();
for i in 0..=144 {
let hash = hash_value(&i);
*counts.entry(hash).or_insert(0) += 1;
@RandyMcMillan
RandyMcMillan / build_guide.md
Created November 11, 2024 18:16 — forked from cwgem/build_guide.md
Building `dockerd` and `docker-cli` from source

Introduction

This guide looks at what it will take to build dockerd and docker-cli from source with Ubuntu. Ubuntu was chosen as the OS as it uses the same apt-get calls the standard Dockerfile method uses making the experience a bit more seamless. While the official method is building docker in a container, here are some reasons why you may want to build this way:

  • Custom source modifications for testing
  • System that does not yet have a docker(d) binary release
  • You want to test things on a non-standard toolchain
  • You just want to deep dive

As you can probably tell using this method means you're delving away from support. Please don't file issues/PRs unless you can reproduce in the official build environment. In fact unless you really have one of the strong needs above you're better off building off a container since this guide is mostly a lot of copy/paste from the Dockerfile used in the official build system.

var hypercore = require('hypercore')
var ram = require('random-access-memory')
var feed = hypercore(ram)
feed.append('hello world')
@RandyMcMillan
RandyMcMillan / playground.rs
Created July 20, 2024 16:52 — forked from rust-play/playground.rs
Code shared from the Rust Playground
fn random() {
let num1 = vec![2, 3];
let num2 = vec![2, 3];
let address1 = &num1 as *const Vec<i32>;
let address2 = &num2 as *const Vec<i32>;
let number1 = address1 as i32;
let number2 = address2 as i32;
let modulus: i32 = 13;
// println!("{}", number1);
@RandyMcMillan
RandyMcMillan / playground.rs
Created July 20, 2024 16:10 — forked from rust-play/playground.rs
Code shared from the Rust Playground
fn random() {
let num1 = vec![2, 3];
let num2 = vec![2, 3];
let address1 = &num1 as *const Vec<i32>;
let address2 = &num2 as *const Vec<i32>;
let number1 = address1 as i32;
let number2 = address2 as i32;
println!("{}", number1 % 13);
println!("{}", number2 % 13);
}
@RandyMcMillan
RandyMcMillan / main.rs
Created January 30, 2024 03:28 — forked from rot13maxi/main.rs
adaptor fun
use rand_chacha::ChaCha20Rng;
use schnorr_fun::fun::{KeyPair, Scalar};
use schnorr_fun::{Message, nonce, Schnorr};
use schnorr_fun::adaptor::Adaptor;
use schnorr_fun::fun::marker::Public;
use schnorr_fun::musig::MuSig;
use sha2::Sha256;
fn main() {
// Little proof of concept. Doesn't actually do real transactions, but you get the idea.