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() { | |
const _Math = { | |
min: Math.min, | |
max: Math.max, | |
abs: Math.abs, | |
ceil: Math.ceil, | |
floor: Math.floor, | |
round: Math.round, | |
}; |
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() { | |
const | |
protoHas = Map.prototype.has, | |
protoGet = Map.prototype.get, | |
protoSet = Map.prototype.set, | |
protoDelete = Map.prototype.delete; | |
Map.prototype.has = function( id ) { | |
if ( typeof id === "string" && !isNaN( +id ) ) { | |
console.warn( `Map.has( "${ id }" )` ); |
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 Random() { | |
return crypto.getRandomValues( Random.arr )[ 0 ] / Random.limit; | |
} | |
Random.limit = 2 ** 32; | |
Random.arr = new Uint32Array( 1 ); |
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 lightSpeed = 299792458; // meter (per second) | |
const solarMass = 1.98855 * Math.pow( 10, 30 ); // kilograms | |
const gravity = 6.67408 * Math.pow( 10, -11 ); | |
function calcSchwarzschildRadius( nbSolarMass ) { | |
return ( 2 * gravity * nbSolarMass * solarMass ) / ( lightSpeed * lightSpeed ); | |
} |
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
{ | |
"Mr. Robot": { | |
"originalNetwork": "USA Network", | |
"seasons": [ | |
{ "nb": 1, "nbEpisodes": 10, "firstAired": "June 24, 2015", "lastAired": "September 2, 2015" }, | |
{ "nb": 2, "nbEpisodes": 12, "firstAired": "July 13, 2016", "lastAired": "September 21, 2016" }, | |
{ "nb": 3, "nbEpisodes": 10, "firstAired": "October 11, 2017", "lastAired": "December 13, 2017" }, | |
] | |
}, | |
"Breaking Bad": { |
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
"use strict"; | |
function diffObjects( a, b ) { | |
var ak, diff = {}; | |
Object.entries( b ).forEach( ( [ k, val ] ) => { | |
ak = a[ k ]; | |
if ( ak !== val ) { | |
if ( !val || typeof val !== "object" ) { | |
diff[ k ] = val; |
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 shrinkArray( arr, newlen ) { | |
var avg, | |
avglenj, | |
i = 0, | |
j = 0, | |
len = arr.length, | |
avglen = ~~( len / newlen ), | |
newarr = []; | |
for ( ; i < newlen; ++i ) { |
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> | |
<title>bug-analyserNode</title> | |
<meta charset="UTF-8"/> | |
</head> | |
<body> | |
<canvas width="512" height="128" id="gsuiOscilloscope"></canvas> |
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
/[^/]*$/.exec( "https://asd.x/file.wav" )[ 0 ]; // "file.wav" | |
/[^/]*$/.exec( "file.wav" )[ 0 ]; // "file.wav" | |
/[^/]*$/.exec( "qwe.rty/" )[ 0 ]; // "" | |
/(?:([^/]*)\.([a-zA-Z\d]*))?$/.exec( "" ); // [ "", undefined, undefined ] | |
/(?:([^/]*)\.([a-zA-Z\d]*))?$/.exec( ".wav" ); // [ ".wav", "", "wav" ] | |
/(?:([^/]*)\.([a-zA-Z\d]*))?$/.exec( "://a.b/q/a.b.mp3" ); // [ "a.b.mp3", "a.b", "mp3" ] |
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
"use strict"; | |
function diacriticsReplace( str ) { | |
return str.replace( /[^A-Za-z0-9\s]+/g, function( a ) { | |
return diacriticsMap[ a ] || a; | |
} ); | |
} | |
var diacriticsMap = { | |
"\u00C0": "A", // À |