Skip to content

Instantly share code, notes, and snippets.

View nortonwong's full-sized avatar

Norton Wong nortonwong

View GitHub Profile
((text = '') => {
const map = {
a: '𝓪',
A: '𝓐',
};
const shift = (char, shift) => String.fromCodePoint(char.codePointAt(0) + shift);
Object.entries(map).forEach(([from, to]) => {
for (let i = 0; i < 26; i++) {
map[shift(from, i)] = shift(to, i);
}
await (async () => {
const formUrlEncode = params => Object.entries(params).map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`).join(`&`)
const auth = `Bearer ` + await fetch(`https://www.example.com/api/oauth2`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: formUrlEncode({
username: 'admin',
password: '1234',
(({ strict = false, sort = true, trim = true, search = false } = {}) => {
const suffixes = ['s', 'ly', 'ing', 'd', 'ed', 'er', 'r', 'est', 'ist', 'al', 'ism', 'ity', 'ic'];
const isSuffixed = (string, strings, suffix) => string.endsWith(suffix) && strings.includes(string.substring(0, string.length - suffix.length));
const matchSearch = typeof search == 'string' ? e => e.includes(search)
: search instanceof RegExp ? e => e.match(search)
: search === false ? e => true
: search instanceof Array ? e => search.includes(e)
: typeof search == 'function' ? search
: (() => { throw new TypeError(`Search argument was ${typeof search}: ${search}`); })();
const words = strict
(() => {
const wrap = (prefix, suffix=prefix) => {
const pref = prefix instanceof Function ? prefix : () => prefix;
const suff = suffix instanceof Function ? suffix : () => suffix;
return e => e.innerHTML = `${pref(e)}${e.innerHTML}${suff(e)}`;
};
const tab = `<span style="white-space: pre;"> </span>`;
$$(`b, strong`).map(wrap(`*`));
$$(`h1, h2, h3, h4, h5, h6`).map(wrap(`**`));
$$(`i, em`).map(wrap(`/`));
const Lambdas = {
remove: (n) => n.remove(),
append: (n) => document.body.append(n),
appendTo: (target) => (n) => target.append(n),
sum: (a, b) => a+b,
product: (a, b) => a*b,
toggleClass: cl => el => el.classList.toggle(cl),
or: (...predicates) => (n) => predicates.filter(p => p).some(p => p(n)),
};
const Utils = {