This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* use sleep from below, or bring your own */ | |
// export const sleep = millis => new Promise(_ => setTimeout(_, millis)); | |
async function impl(sentinel, func, interval, args) { | |
for (; !sentinel.aborted; await sleep(interval)) { | |
await func(...args); | |
} | |
} | |
export default function runAtIntervals(func, interval, ...args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function onLoad() { | |
cfg.load(); | |
const prefix = 'div.' + webm.getStyle('cozyMessage') + ' '; | |
const q = Object.values(sites).flatMap(({ patterns: p }) => p.map(x => 'a[href*="' + x +'"]')); | |
q.push('a[href*="//t.co/"]'); | |
links.query = prefix + q.join(',' + prefix); | |
links.process(d.body); | |
new MutationObserver(onMutations).observe(d.body, {childList:true, subtree:true}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const languageCache = new Map(); | |
let visitedNodes; | |
let language; | |
const resetVisitedNodes = () => { | |
visitedNodes = new WeakSet(); | |
}; | |
const formatRegex = /\{([^\}]*)\}/gui; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const benchmark = require("benchmark"); | |
const suite = new benchmark.Suite; | |
/** SETUP BEGIN */ | |
const length = 100; | |
const value = ""; | |
const arrayOf = (function () { | |
function* generator(length, fill) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const limits = [ | |
{ "x<": [90, 8] }, | |
{ "x<": [80, 7.9] }, | |
]; | |
const re = /^x?([<>]=?)$|^([<>]=?)x$/i; | |
const comparators = { | |
"<": (a, b) => a < b, | |
"<=": (a, b) => a <= b, | |
">": (a, b) => a > b, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SuppressWarnings("ForLoopReplaceableByForEach") | |
public final class Sum { | |
private Sum() {} | |
public static byte of(byte[] array) { | |
if (array == null) { | |
return 0; | |
} | |
byte result = 0; | |
for (int i = 0, length = array.length; i < length; ++i) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const partialBinder = ((hole, rest) => { | |
"use strict"; | |
function partiallyBound(fn, args, ...missing) { | |
const argsLen = args.length; | |
const missingIter = missing[Symbol.iterator](); | |
for (let i = 0; i < argsLen; ++i) { | |
switch (args[i]) { | |
case hole: break; | |
case rest: args.splice(i, 1, ...missing); return fn.apply(this, args); | |
default: continue; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const csvEscape = function() { | |
const map = { | |
";": ",", | |
"\n": "\\n" | |
}; | |
const replacerRe = /./gsm; | |
const replacer = x => `\\x${x.charCodeAt(0).toString(16).padStart(2, 0)}`; | |
const escaped = Object.keys(map).map(x => x.replace(replacerRe, replacer)); | |
const escapeRe = new RegExp(escaped.join("|"), "g"); | |
const escape = x => map[x]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Twitter Gallery tweaks | |
// @namespace intermission | |
// @include https://twitter.com/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
"use strict"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isLetter(codePoint) { | |
if (65 <= codePoint && codePoint <= 90) return true; | |
if (97 <= codePoint && codePoint < 123) return true; | |
// maybe more cases for unicode | |
return false; | |
} | |
function reverseOnlyLetters(string) { | |
if (typeof string !== "string") return; | |
const length = string.length; |