Skip to content

Instantly share code, notes, and snippets.

@cdolek
cdolek / Tiny JavaScript tokenizer.js
Created January 22, 2021 06:13 — forked from borgar/Tiny JavaScript tokenizer.js
A compact tokenizer written in JavaScript.
/*
* Tiny tokenizer
*
* - Accepts a subject string and an object of regular expressions for parsing
* - Returns an array of token objects
*
* tokenize('this is text.', { word:/\w+/, whitespace:/\s+/, punctuation:/[^\w\s]/ }, 'invalid');
* result => [{ token="this", type="word" },{ token=" ", type="whitespace" }, Object { token="is", type="word" }, ... ]
*
*/
{
"orange": {
"hex": "#E69F00",
"hue": 41,
"hsl": "hsl(41, 100%, 45%)"
},
"sky blue": {
"hex": "#56B4E9",
"hue": 202,
"hsl": "hsl(202, 77%, 63%)"
@cdolek
cdolek / gist:b87af01c94dd49d780806d7f07e460a5
Created August 15, 2022 19:45
Monaco editor theme colors
{
"foreground": {
"type": "string",
"description": "Overall foreground color. This color is only used if not overridden by a component.",
"format": "color-hex",
"defaultSnippets": [
{
"body": "${1:#ff0000}"
}
]
@cdolek
cdolek / gist:198adb54ca7885d481144dfe51eec028
Created August 15, 2022 22:57
Percentage to hex map for 8 digit hex color alpha values
100% — FF
99% — FC
98% — FA
97% — F7
96% — F5
95% — F2
94% — F0
93% — ED
92% — EB
91% — E8