Skip to content

Instantly share code, notes, and snippets.

View miraclx's full-sized avatar
🦀
Pirate of the Crab-ibean

Miraculous Owonubi miraclx

🦀
Pirate of the Crab-ibean
View GitHub Profile
@miraclx
miraclx / insanity.js
Created September 24, 2021 04:46
JS TypedMatcher: Workaround to mimic Rust's `match` in JS
export async function typedMatcher(val, handler) {
let register = {};
let value = valueSpec => {
let data, matchEntry;
register[(matchEntry = Object.assign(Symbol("matchEntry")))] = data = {0: valueSpec};
matchEntry.type = type => ((data._ = type), matchEntry);
return matchEntry;
};
let type = typeSpec => {
let data, matchEntry;
@miraclx
miraclx / playground.rs
Last active October 10, 2022 05:10 — forked from rust-play/playground.rs
Human List
fn human_list<I, T>(i: I) -> String
where
I: Iterator<Item = T>,
T: AsRef<str>,
{
let mut items = i.peekable();
let mut s = match items.next() {
Some(s) => s.as_ref().to_owned(),
None => return String::new(),
};
@miraclx
miraclx / README.md
Last active August 4, 2024 01:41
Generate a n-ary tree under specific constraints

n-ary

Generate a n-ary tree under specific constaints

Generate a n-ary tree under specific constaints

Usage: node n-ary.js [opts] <leaves> <branches>

Options: