Skip to content

Instantly share code, notes, and snippets.

View fabiospampinato's full-sized avatar
✏️
Making Notable awesome.

Fabio Spampinato fabiospampinato

✏️
Making Notable awesome.
View GitHub Profile
@fabiospampinato
fabiospampinato / use_rulers.ts
Created September 15, 2023 11:02
A little Voby hook for rendering rulers around an element on the page
View use_rulers.ts
/* IMPORT */
import {$} from 'voby';
import {useCanvasOverlay, useEffect, useEventListener, useRect, useResolved} from '~/hooks';
/* TYPES */
type Line = {
offset: number
@fabiospampinato
fabiospampinato / nitropack_duplicates_report.txt
Created August 11, 2023 23:13
Duplicates report for Nitropack v2.5.2
View nitropack_duplicates_report.txt
- string_decoder
- 1.1.1
- Repository: https://github.com/nodejs/string_decoder
- Readme: https://raw.githubusercontent.com/nodejs/string_decoder/master/README.md
- License: https://raw.githubusercontent.com/nodejs/string_decoder/master/LICENSE
- 1.3.0
- Repository: https://github.com/nodejs/string_decoder
- Readme: https://raw.githubusercontent.com/nodejs/string_decoder/master/README.md
- License: https://raw.githubusercontent.com/nodejs/string_decoder/master/LICENSE
- source-map
@fabiospampinato
fabiospampinato / sieve.js
Created August 4, 2023 22:19
A little Sieve of Eratosthenes
View sieve.js
const sieve = ( size ) => {
//TODO: add windowing for the buffer, allocating a fixed-size buffer that gets repopulated when needed
const buffer = new Uint8Array ( Math.ceil ( size / 8 ) ).fill ( 255 );
const primes = [];
let prev = 2;
@fabiospampinato
fabiospampinato / use_boxer.ts
Created May 1, 2023 17:34
A little Voby hook for rendering hit boxes around each element on the page
View use_boxer.ts
/* IMPORT */
import {$$} from 'voby';
import {useEffect} from '~/hooks';
/* MAIN */
const useResizeObserver = ( ref: $<Element | undefined>, fn: ResizeObserverCallback, options: ResizeObserverOptions = {} ): void => {
@fabiospampinato
fabiospampinato / fast_css_reset.css
Last active July 18, 2023 18:07
The fastest CSS reset possible
View fast_css_reset.css
:where(abbr), :where(address), :where(area), :where(article), :where(aside), :where(audio), :where(b), :where(base), :where(bdi), :where(bdo), :where(big), :where(blockquote), :where(body), :where(br), :where(caption), :where(cite), :where(code), :where(col), :where(colgroup), :where(data), :where(datalist), :where(dd), :where(del), :where(details), :where(dfn), :where(dialog), :where(dl), :where(dt), :where(em), :where(embed), :where(fieldset), :where(figcaption), :where(figure), :where(footer), :where(form), :where(h1), :where(h2), :where(h3), :where(h4), :where(h5), :where(h6), :where(head), :where(header), :where(hgroup), :where(hr), :where(i), :where(input), :where(ins), :where(kbd), :where(keygen), :where(label), :where(legend), :where(li), :where(link), :where(main), :where(map), :where(mark), :where(menu), :where(menuitem), :where(meta), :where(meter), :where(nav), :where(object), :where(ol), :where(optgroup), :where(option), :where(output), :where(param), :where(picture), :where(pre), :where(progress
@fabiospampinato
fabiospampinato / lag_bar.tsx
Created April 23, 2023 19:56
My lag bar implementation for Voby
View lag_bar.tsx
/* IMPORT */
import {$, $$, useEffect, useInterval} from 'voby';
/* STYLE */
css`
:root {
--lag-bar-color-bg: var(--color-black-bg);
@fabiospampinato
fabiospampinato / range_slider.tsx
Created April 19, 2023 13:55
Some code that will probably look pretty weird to you
View range_slider.tsx
/* IMPORT */
import './styles.scss';
import _ from '_';
import {$, $$} from 'voby';
import {If} from '~/components';
import {useActiving, useDragger} from '~/hooks';
import type {Props} from './types';
@fabiospampinato
fabiospampinato / fast-npm-run.sh
Last active March 10, 2023 00:51
20x faster replacement for "npm run"
View fast-npm-run.sh
# 20x faster replacement for "npm run"
# - It supports scripts executing a built-in shell function
# - It supports scripts executing a binary found in PATH
# - It supports scripts executing a binary found in node_modules
# - It supports passing arguments and options to scripts
# - It supports reading scripts either via ripgrep (fast) or via jq (slower, but safer)
# - It adds ./node_modules/.bin to the $PATH
# - It handles gracefully when a script has not been found
# - It handles gracefully when "&", "&&", "|", "||", or ENV variables are used, falling back to "npm run"
@fabiospampinato
fabiospampinato / lzw.js
Last active January 19, 2023 20:27
A rough implementation of the LZW algorithm
View lzw.js
import * as assert from 'node:assert';
import Buffer from 'node:buffer';
import fs from 'node:fs';
import {deflateSync, inflateSync} from 'fflate';
import * as LZW from '@amoutonbrady/lz-string'
import * as Huffy from 'huffy';
import Base64 from 'radix64-encoding';
const encoder = new TextEncoder ();
@fabiospampinato
fabiospampinato / hash-ish.js
Created December 21, 2022 15:04
A little toy hash function that maybe works somewhat
View hash-ish.js
/* IMPORT */
const crypto = require ( 'crypto' );
/* MAIN */
// const hash = str => {
// const PRIMEn = 115792089237316195423570985008687907853269984665640564039457584007913129639349n; // 2**256-587 - https://primes.utm.edu/lists/2small/200bit.html
// const SEEDn = 340282366920938463463374607431768211099n; // 2**128-357 - https://primes.utm.edu/lists/2small/100bit.html