Skip to content

Instantly share code, notes, and snippets.

View nicholaswmin's full-sized avatar
💭
I may be slow to respond.

Nicholas Kyriakides nicholaswmin

💭
I may be slow to respond.
View GitHub Profile
@nicholaswmin
nicholaswmin / decimators.js
Created March 27, 2025 11:08
functional time-series downsampling algorithms
/* Largest-Triangle-3-Buckets/MinMax in ES6
+ unit tests, run by node --test foo.js
- authors: Nicholas Kyriakides, @nicholasmin
- license: MIT
from: Downsampling Time Series for Visual Representation
Sveinn Steinarsson
University of Iceland,
https://skemman.is/handle/1946/15343
Downsampling/Decimation Algorithms
@nicholaswmin
nicholaswmin / browzen.js
Last active March 7, 2025 16:39
update a chrome tab without losing focus; macos-only
/**l
* Opens Chrome tab to a specified URL(or reload if exists)
* without the usual ballbusting focus loss on every file change.
*
* Meant for:
* `$ node --watch` or `$ nodemon app.js`
* type of orkflows where you don't
* want each file-save taking you to the browser.
*
* macOS only; no Linux/Windows
@nicholaswmin
nicholaswmin / flow.spec.md
Last active February 17, 2025 11:10
flow documentation format for LLM-assisted refactoring

flow

format for flow documenation in [LLM][llm]-assisted refactoring

This spec is given to the LLM which in turn utilizes it to
produce documentation of [system flows][flow], each showing
[state transitions][state], [steps][step], and [side effects][effect].

These flow documents support:

@nicholaswmin
nicholaswmin / test-runner.sh
Last active February 14, 2025 16:27
POSIX test runner
#!/bin/sh
# test.sh
# ----------------------
# scaffold example test:
# sh --init
#
# quickstart:
#
@nicholaswmin
nicholaswmin / validated.js
Last active February 15, 2025 11:26
type-validator function for primitives, null & array. Includes unit-tests and docs
/** @function
* @name validated
* @summary validate the type of a value
*
* @description
* validates a value against a {spec}. object, specifying:
* - parameter {name}
* - expected {type}
* {type} suppers & differentiates non-standard "array" and "null" types.
*
@nicholaswmin
nicholaswmin / reset.js
Created December 16, 2024 16:49
sensible DOM in 3 lines of code
/* examples:
$$('.button').map(el => el.on('click', console.log))
$('body').on('mouseenter', console.log) */
Node.prototype.on = Node.prototype.addEventListener
window.$ = document.querySelectorAll.bind(document)
window.$$ = (...a) => Array.from(document.querySelectorAll(...a))
@nicholaswmin
nicholaswmin / README.md
Last active December 12, 2024 14:40
pretty-inspect.js

pretty printer for object/arrays

CLI screenshot of result: 2D table. everything is colourized dimmed, except the values

const result = inspect([ { index: 1,   value: 'foo bar baz '.repeat(100) },
                         { index: 2,   value: 'foo bar baz '.repeat(10)  },
                         { index: 125, value:  null                      },
                         { index: 16,  value: 0123456789                 },
{ index: 300, value: function foo() {} },
@nicholaswmin
nicholaswmin / undo.md
Last active December 19, 2024 17:24
oops
@nicholaswmin
nicholaswmin / calc.js
Last active December 8, 2024 09:03
majestically tiny, stack-based calculator in ES6+
/*
tiny stack-based calculator
- If you're looking for a fancier expression calculator,
this isn't it. What you're looking for is a "Shunting Yard"
implementation. This is intentionally simple.
@nicholaswmin, MIT License
-- Usage: --
@nicholaswmin
nicholaswmin / pptr.mixin.test.js
Last active December 8, 2024 12:36
minimally extended puppeteer for clutter-free test files. unit-tests below.
/*
** IMPORTANT: This is rather pointless. The Locator API does most of the work replicated here **
Browser unit-tests for: `pptr.mixin.js`
> in chrome ~~& firefox~~
The following should have beeen installed on `npm install`:
```bash