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 / 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:
@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 / 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 / README.md
Created June 7, 2021 13:46
Get info from MTN MF283 on the CLI

Show realtime information from the MTN MF283 Router

Get pretty display for realtime data

One-off query returning JSON data

@miraclx
miraclx / index.html
Created February 15, 2021 03:34
array accumulation by concat vs push (https://jsbench.github.io/#e27585fe2c271195762d88ecf0188ec3) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>array accumulation by concat vs push</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@miraclx
miraclx / index.html
Created February 15, 2021 03:23
join_split vs split_flat (https://jsbench.github.io/#355b4874bc15a7566433f1976369d984) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>join_split vs split_flat</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@miraclx
miraclx / GitHubRepoSize.user.js
Last active November 17, 2023 16:44
Calculate repo size and inject into GitHub page
// ==UserScript==
// @name GitHub Repo Size
// @namespace https://gist.github.com/miraclx/aad03f43fe8ac85682b0243f4f242f0d
// @description Calculate repo size and inject into GitHub page
// @icon https://github.githubassets.com/favicons/favicon.png
// @version 0.2.0
// @author miraclx
// @license Apache-2.0
// @supportURL https://gist.github.com/miraclx/aad03f43fe8ac85682b0243f4f242f0d
// @grant GM_xmlhttpRequest
@miraclx
miraclx / README.md
Last active January 22, 2021 03:15
Git hook for automating push to keybase git repos using a shared bare repo

How to

Don't forget to replace angle brackets <...> with actual values

  • Create a bare git repo (this would be the local shared remote)
git init --bare <repo-name>
cd <repo-name>

Keybase proof

I hereby claim:

  • I am miraclx on github.
  • I am miraclx (https://keybase.io/miraclx) on keybase.
  • I have a public key ASDqJGBAchG6iEbgiaOBRjmyKeUf_nx8Jo_sWtbqXr6K_go

To claim this, I am signing this object:

@miraclx
miraclx / fix_whatsapp.txt
Created November 11, 2020 21:48
Correct ctime on WhatsApp media artifacts
Correct timestamps on WhatsApp media artifacts
# How it works
WhatsApp saves its media files in the format `{TYPE}-{YYYY}{MM}{DD}-WA{NNNN}.{EXT}`
## Examples
- Image: `IMG-20190806-WA0026.jpg`
- Sticker: `STK-20191126-WA0010.webp`
- Audio: `AUD-20181227-WA0045.opus`
- Animated Gifs: `VID-20190103-WA0003.mp4`