Skip to content

Instantly share code, notes, and snippets.

View automagisch's full-sized avatar

Koen Houtman automagisch

View GitHub Profile
@automagisch
automagisch / chunkify.js
Last active October 31, 2019 13:31
chunkify.js
/**
* const data = [...new Array(10000)]; // some huge array, browser compensates rendering because of size
* const pages = chunk(data, 200); // create pages from huge array
* pages.size; // size of the results per page
* pages.index; // current page index
* pages.data; // complete data set
* pages.chunks; // data set in chunks
* pages.get(0); // returns {pages.size} results at index [0-{pages.chunks.length}]
* pages.next(); // increments index and returns the result index page
* pages.prev(); // decrements index and returns the result index page
@automagisch
automagisch / tests-against-humanity.js
Last active December 24, 2019 12:08
Placeholder tests for npm package when you haven't written any yet and are not planning to do that for a longer time. Let's play 'Tests Against Humanity'
/** Tests against humanity v1
* 1. add this file to something like `{project}/tests/test.js`
* 2. add command `node tests/test.js` to package.json.scripts under the key "test"
* 3. run `npm test`
*/
const { log } = console;
const lameExcuses = [
"I guess it's allright-ish. Just do not take my word for it.",
@automagisch
automagisch / hashrouter.js
Last active March 30, 2021 15:32
Hash Router is a utility that handles hash navigation, e.g for client tab bars.
/*
* hash-based inline navigation 1.0
*
* This script utilizes HTML5 'role' attributes to determine its contribution
* to inline navigation methods. Using that, and a format that works for
* single-level tabs as well as multi-dimensional deep tabs.
*
* <div role="tablist" id="tabs-index">
* <a role="tab" href="#test"></a>
* <a role="tab" href="#test-two"></a>
@automagisch
automagisch / .env
Last active May 19, 2022 08:19
PostCSS boilerplate
env=develop
@automagisch
automagisch / package.json
Last active May 21, 2022 10:32
TypeScript (client) + PostCSS + Serve with Concurrently
{
"name": "postcss-ts-serve-boilerplate",
"version": "1.0.0",
"description": "",
"main": "src/ts/main.ts",
"scripts": {
"postinstall": "npm run build",
"postcss": "postcss src/pcss/main.pcss --output dist/css/style.css --verbose",
"postcss:watch": "postcss src/pcss/main.pcss --output dist/css/style.css --verbose --watch",
"esbuild": "esbuild ./src/ts/*.ts --splitting --bundle --minify --format=esm --log-level=info --outdir=dist/js",