This file contains 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 string = ``; | |
const wrapWords = (string, width) => string.replace(new RegExp(`(?![^\\n]{1,${width}}$)([^\\n]{1,${width}})\\s`, 'g'), '$1\n'); | |
console.log(string.split('\n').map(value => wrapWords(value, 80)).join('\n\n')); |
This file contains 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 split(array, groups = 2) { | |
array = array.sort((a, b) => b - a); | |
const parts = Array.from({length: groups}, () => []); | |
const partLengths = Array.from({length: groups}, () => 0); | |
for (const item of array) { | |
const partIndex = partLengths.indexOf(Math.min(...partLengths)); | |
parts[partIndex].push(item); | |
partLengths[partIndex] += item; |
This file contains 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 I'm not a Fortnite player | |
// @namespace https://github.com/Richienb | |
// @version 0.1 | |
// @description Change ReCAPTCHA and hCaptcha labels to be something more epic | |
// @author Richie Bendall | |
// @match *://www.google.com/recaptcha/api2/anchor* | |
// @match *://newassets.hcaptcha.com/captcha/v1/*/static/hcaptcha-checkbox.html* | |
// @grant none | |
// ==/UserScript== |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Finding distinct items in an array - See https://stackoverflow.com/questions/63396741/how-do-i-get-the-numbers-that-do-not-have-a-duplicated-value-in-an-array-of-numb/63396901</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
This file contains 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
/* https://github.com/Richienb/scratch-http v0.1.0 */ | |
'use strict';(function(){function n(e){"@babel/helpers - typeof";n="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(c){return typeof c}:function(c){return c&&"function"===typeof Symbol&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c};return n(e)}function K(e,c){if(!(e instanceof c))throw new TypeError("Cannot call a class as a function");}function L(e,c){for(var b=0;b<c.length;b++){var a=c[b];a.enumerable=a.enumerable||!1;a.configurable=!0;"value"in a&&(a.writable= | |
!0);Object.defineProperty(e,a.key,a)}}function V(e,c,b){c&&L(e.prototype,c);b&&L(e,b);return e}function M(e,c){var b=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);c&&(a=a.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable}));b.push.apply(b,a)}return b}function y(e){for(var c=1;c<arguments.length;c++){var b=null!=arguments[c]?arguments[c]:{};c%2?M(Object(b),!0).forEach(function(a){var c=b[a];a in |
This file contains 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 copyText(text) { | |
const copyElement = document.createElement("textarea") | |
document.querySelector("body").appendChild(copyElement) | |
copyElement.textContent = text | |
copyElement.select() | |
document.execCommand("copy") | |
document.querySelector("body").removeChild(copyElement) | |
} |
This file contains 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
UPSTREAM_BRANCH=$1 | |
if [ -z "$UPSTREAM_BRANCH" ]; then | |
UPSTREAM_BRANCH=$(git branch --show-current) | |
fi | |
git fetch upstream && | |
git merge upstream/${UPSTREAM_BRANCH} |
This file contains 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 { search } = require("npms-api") | |
const got = require("got") | |
const totalled = require("totalled") | |
const pMap = require("p-map") | |
const npmUsername = "richienb" | |
const downloadCount = async packageName => { | |
try { | |
const {body} = await got(packageName, { |
This file contains 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
module.exports = taskFunction => { | |
return (...arguments_) => module.exports.task(taskFunction(...arguments_)) | |
} | |
module.exports.task = task => new Promise((resolve, reject) => { | |
task.fork(reject, resolve) | |
}) |
NewerOlder