Skip to content

Instantly share code, notes, and snippets.

View unforswearing's full-sized avatar

Alvin Charity unforswearing

View GitHub Profile
@unforswearing
unforswearing / helpers.sh
Last active February 24, 2023 05:24 — forked from jgornick/helpers.sh
Bash: Helper Functions
export MARKPATH="$HOME/.marks"
function jump {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
}
function mark {
mkdir -p "$MARKPATH";
ln -s "$(pwd)" "$MARKPATH/$1"
}
function unmark {
@unforswearing
unforswearing / Tiny JavaScript tokenizer.js
Created May 12, 2022 00:05 — 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" }, ... ]
*
*/