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 / .justfile
Created January 5, 2025 19:30
justfile
alias d := doc
alias u := update
alias r := run
alias t := test
alias b := build
alias c := check
alias ia := install-all
alias rr := run-release
alias w := watch
@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 / .justfile
Created December 28, 2024 20:05
cargo justfile
alias d := doc
alias l := nix-lint
alias uf := nix-update-flake-dependencies
alias uc := update-cargo-dependencies
#alias r := run
alias t := cargo-test
alias b := build
alias rr := run-release
alias cw := cargo-watch
@RandyMcMillan
RandyMcMillan / .justfile
Created December 18, 2024 13:11
justfile
alias d := doc
alias l := lint
alias uf := update-flake-dependencies
alias uc := update-cargo-dependencies
alias r := run
alias t := cargo-test
alias b := build
alias rr := run-release
alias cw := cargo-watch
@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;
// #![deny(warnings)]
use std::collections::HashMap;
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc,
};
use futures_util::{SinkExt, StreamExt, TryFutureExt};
use tokio::sync::{mpsc, RwLock};
use tokio_stream::wrappers::UnboundedReceiverStream;
@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.