1..toRoman() // "I"
18..toRoman() // "XVIII"
1910..toRoman() // "MCMX"
9999..toRoman() // "MMMMMMMMMCMXCIX"
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
$connectedSleep = 59 | |
$disconnectedSleep = 5 | |
$currentSleep = $connectedSleep | |
$vpnName = "Azure VPN" | |
while($true) { | |
$value = Get-NetIPInterface | findstr -i $vpnName | |
if ($value -eq $null) { | |
$currentSleep = $disconnectedSleep |
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 memoizer(fn) { | |
const cache = new Map([]); | |
return (...args) => { | |
let result; | |
const key = args.toString(); | |
if (cache.has(key)) | |
result = cache.get(key); | |
else { | |
result = fn(...args); | |
cache.set(key, result); |
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 GTIN_SSCC_LENGTH = 16; | |
const WEIGHT_EVEN = 3; | |
const WEIGHT_ODD = 1; | |
function ceil(n, base) { | |
// TODO: 0.1, 0.01, 0.001, etc. | |
return Math.ceil(n / base) * base; | |
} | |
function validateEan(str = '') { |
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 checkValidity(el) { | |
if (el.checkValidity()) { | |
el.$valid = true; | |
el.$invalid = false; | |
} else { | |
el.$valid = false; | |
el.$invalid = true; | |
} | |
} |
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
fun = (variations, matchIndex = 0) => (...appliedArgs) => (variations[appliedArgs[matchIndex]] || variations._)(...appliedArgs) | |
luck = fun({ | |
7: () => "LUCKY NUMBER SEVEN", | |
_: () => "Sorry, you're out of luck, pal!", | |
}) | |
luck(7) | |
// "LUCKY NUMBER SEVEN" |
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
.blink { | |
animation: fade 3000ms infinite; | |
} |
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 thueMorse(i) { | |
var a = '0', b = '1'; | |
for (; i--;) | |
a += [b, b += a][0]; | |
return a; | |
} | |
thueMorse(0); // 0 | |
thueMorse(1); // 01 | |
thueMorse(4); // 0110100110010110 |
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
// deburglar.getDupes(); | |
var deburglar = (function () { | |
var dict = {}; | |
var maybeTheOriginalOpen = XMLHttpRequest.prototype.open; | |
XMLHttpRequest.prototype.open = function (method, url) { | |
if (!dict[url]) | |
dict[url] = 0; | |
dict[url]++; | |
return maybeTheOriginalOpen.apply(this, arguments); | |
}; |
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 int32toIP(nMask) { | |
for (var nFlag = 0, nShifted = nMask, sMask = ''; nFlag < 32; | |
nFlag++, sMask += String(nShifted >>> 31), nShifted <<= 1); | |
return sMask.match(/.{1,8}/g).map(function (x) { return parseInt(x, 2); }).join('.'); | |
} | |
int32toIP(255); // "0.0.0.255" | |
int32toIP(256); // "0.0.1.0" | |
int32toIP(1333333337); // "79.121.13.89" | |
int32toIP(7527203073); // "192.168.1.1" |
NewerOlder