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
var hypercore = require('hypercore')
var ram = require('random-access-memory')
var feed = hypercore(ram)
feed.append('hello world')
@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.

@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 / 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 / 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 / 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 / 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 / clap_basic.rs
Last active January 10, 2025 15:27 — forked from rust-play/playground.rs
clap_basic.rs
use std::path::PathBuf;
use clap::{arg, command, value_parser, ArgAction, Command};
fn main() {
let matches = command!() // requires `cargo` feature
.arg(arg!([name] "Optional name to operate on"))
.arg(
arg!(
-c --config <FILE> "Sets a custom config file"
@RandyMcMillan
RandyMcMillan / bitcoin_supply.rs
Last active January 10, 2025 16:28 — forked from rust-play/playground.rs
bitcoin_supply.rs
fn main() {
let mut sum: u64 = 0;
for x in 0..=32 {
// Calculate the term inside the summation
let term: f64 = (50.0 * 1e8) / (2.0_f64.powi(x as i32));
println!("{} {}", x, term.to_string());
// Take the floor of the result
let floor_term: u64 = term.floor() as u64;
// Add it to the sum
sum += floor_term;
@RandyMcMillan
RandyMcMillan / get_matching_enum.rs
Last active January 10, 2025 16:27 — forked from rust-play/playground.rs
get_matching_enum.rs
//#[allow(dead_code)]
enum Point {
Nothing,
TuplePoint(i32, i32),
StructPoint {
x: i32,
y: i32
}
}