Skip to content

Instantly share code, notes, and snippets.

View annibal's full-sized avatar

Arthur Annibal annibal

View GitHub Profile
@annibal
annibal / Text-Border.css
Created November 12, 2026 04:46
CSS Text Border simulation using 24 shadows
.text-border {
/* ___________ Parameters */
/* Alpha */ --ts_a: 100%;
/* Blur */ --ts_b: 0px;
/* Color */ --ts_c: 136 136 136;
/* Distance */ --ts_d: 0.2px;
/* ⌢⌣⌢⌣⌢⌣⌢⌣⌢⌣⌢⌣⌢⌣⌢⌣⌢⌣⌢⌣⌢⌣⌢⌣ */
/* Variables Math */
/* */
/* K Shell */

prepareInjection

Prepares and Injects an script into the DOM

const injectScriptURL = "https://gist.g.../annibal/.../raw/.../prepareInjection.js";
const injectParams = {
  bustCache     : true,
  fetchCode     : false, 
 ROSE : true,
@annibal
annibal / README.md
Last active April 13, 2026 14:08
A way to check how random is your random function. Invokes it billions of times and counts each result for you.

testRandomFunction

Invokes a fn() many times and analyzes the result types.

// import myRandomFunction from testRandomFunction.ts
const rand100() { return Math.random() * 100 | 0; }

const testRF = testRandomFunction({
 randFn: () => { rand100(); },
@annibal
annibal / README.md
Last active November 22, 2025 21:12
i think PRIMARY KEY INTEGER AUTOINCREMENT ids are ugly.

Custom UID generator

const { uid: customUID } = CreateNibolsUID();
const thingID = customUID(4);
const otherID = customUID(8);

// decode uid
log(thingID === otherID); // true
log( customUID(thingID, true), customUID(otherID, true) ); // 4, 8
@annibal
annibal / aboutURL.json
Last active November 14, 2025 03:48
Examples of URL - both Valid and Invalid, plus some more info about URL validation. Someday i'll build the perfect URL validation, then from it, the amazing "makeValidThisURL()"
{
"rules": {
"domain": [
".com .net .org and .info domain names cannot exceed 67 characters",
".info and .biz must have at least 3 characters not including .info and .biz",
"Other domain names cannot exceed 22 characters not including the extension",
"2 letter domains are not allowed."
],
"edge-cases": [
"'http://url.com/path///////otherpath' is technically valid per RFC 3986 and 9110. Most servers normalize or collapse them ('/path///////otherpath' and '/path/otherpath' yield the same resource), others don't (several empty segments (\"\") between 'path' and 'otherpath').",
@annibal
annibal / getValidatedVersionParam.js
Last active November 14, 2025 03:47
Validates "v1" or "v0.1" or "v0.0.1" but not "v01" nor "v1.01" nor "v0.0.01" nor "vRegExp"
const regExVersion = new RegExp([
// starts with "v" ➔ v1, v2, v56, v100 works. vv1, 12345, 1.2.3 fails.
"^(?:v)",
// major version: either "0" or a number that not starts with 0. ➔ v01 fails
"(?<major>(?:[1-9][0-9]*)|(?:0))",
// minor version (optional) - same as major ➔ v1.1, v0.1, v2.15, v9, v9.0, v9.9 works. v9.09 fails
"(?:\.(?<minor>(?:[1-9][0-9]*)|(?:0)))?",
// revision (optional too) - same as major ➔ v1.2.3, v0.0.1, v9.0.9 works, v0.0.0, v6.5.04 fails.
"(?:\.(?<revision>(?:[1-9][0-9]*)|(?:0)))?",
@annibal
annibal / BEM.css
Last active April 13, 2026 14:28
B.E.M. :: Block Element Modifier - naming standard - Cascading Style Sheets
.BEM { /* Quick Reference Sheet + Comments */
--def: B "Block", E "Element", M "Modifier";
--usage:
"block" "__element" "--modifier || _name_value",
"button" "button__icon" "button__icon--disabled",
"card" "card__footer" "card__footer--is_bad" "card__footer_is_bad"
"nibol-slider__item--active"
;
}
@annibal
annibal / ColorFormatConverterHelpers.js
Last active August 13, 2025 19:24
Converts many of the most common color formats, from and to. Also generates a monochromatic palette.
const makeColorFormatConverterHelpers = (() => {
function rgbToHsl([r, g, b]) {
r /= 255; g /= 255; b /= 255;
const max = Math.max(r, g, b), min = Math.min(r, g, b);
let h, s, l = (max + min) / 2, d = max - min;
if (!d) h = s = 0;
else {
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch (max) {
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
@annibal
annibal / H_and_Q.js
Last active November 25, 2026 05:55
Generate HTML and Query elements with the H() and Q() functions
(() => {
const NoneOneAll = (predicate) => [
() => null,
(p) => p[0],
(p) => Array.from(p),
][((len) => +!!len + (len > 1))(predicate?.length)](predicate);
let defaultRootElm = [];
try {
if (!document) throw new Error("[H()+Q()]: Global variable Document (<html />) is not accessible");
@annibal
annibal / bidi-tests.js
Last active November 14, 2025 03:47
Unicode Combination and Width Tests
// Example usage:
console.log(testWidthReductionTechniques("Hello World"));
console.log(runWidthTests());
function testWidthReductionTechniques(inputText) {
// Store original for comparison
const original = inputText;
// Key directional control characters
const RLM = "\u200F"; // Right-to-Left Mark