Skip to content

Instantly share code, notes, and snippets.

View hperantunes's full-sized avatar

Hilton Perantunes hperantunes

  • Montreal, Canada
View GitHub Profile
tiddlywiki ~/projects/flwiki --listen port=2999
const pattern = /[^\d.,-]|[.,]{2,}|(?<=.)-/;
console.log("1-1".match(pattern));
const a = {
CoolButton: {
fr: "Omelette du fromage",
en: "Black pudding"
},
NotSoCoolButton: {
fr: "Une baguette",
en: "Apple pie"
}
};
function decimalPlaces(value) {
const match = ("" + value).match(/(?:[,.](\d+))?(?:[eE]([+-]?\d+))?$/);
if (!match) {
return 0;
}
return Math.max(0, (match[1] ? match[1].length : 0) - (match[2] ? +match[2] : 0));
}
export function* range(start, end = 0, step = 1) {
for (let value = start; value <= end; value += step) {
yield value;
}
}
declare namespace Chai {
interface Assertion {
style(property: string, value?: any): Assertion;
}
}
declare module "chai-style" {
const chaiStyle: Chai.ChaiPlugin;
export = chaiStyle;
}
$package = (Get-Content package.json) | ConvertFrom-Json | Select-Object -Property name,version
$versions = npm view $package.name versions | ConvertFrom-json
if ($versions[1] -split "`n" -contains $package.version) {
throw "Package $($package.name) already has version $($package.version) published"
}
function uniqueReducer(unique, item) {
return unique.includes(item) ? unique : [...unique, item];
}
function mergeObjectsReducer(accumulator, current) {
return {
...accumulator,
...Object.keys(current)
.filter(
key =>
Start-Process "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" `
-ArgumentList "--remote-debugging-port=9222",`
"--enable-features=`"dns-over-https<DoHTrial`"",`
"--force-fieldtrials=`"DoHTrial/Group1`"",`
"--force-fieldtrial-params=`"DoHTrial.Group1:server/https%3A%2F%2F1.1.1.1%2Fdns-query/method/POST`""
import retry from "async-retry";
const retryOptions = {
forever: true,
factor: 2
};
export default (url, options) => retry(async () => {
const response = await fetch(url, options);
if (response.status !== 200) {