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 CLI flag --size <number> (or -s <number>) to set board dimensions | |
// Use CLI flag --count <number> (or -c <number>) to set bomb count | |
const argv = require('minimist')(process.argv.slice(2)) | |
const minesweeper = require('minesweeper') | |
const size = Math.max(Math.floor(Number(argv.size || argv.s)) || 8, 4) | |
const count = Math.min(Math.max(Math.floor(Number(argv.count || argv.c)) || Math.floor(size**2 / 6), 4), size**2) | |
const mineArray = minesweeper.generateMineArray({ |
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
let marginAdjust = 0 | |
setInterval(function() { | |
// Find and research ready active projects | |
const readyProject = activeProjects.find(project => project.cost()) | |
if(readyProject) return readyProject.effect() | |
// Free-will era | |
if(humanFlag) { |
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
// Skip delay in milliseconds | |
// Raise if your connection is slow | |
const delay = 8000; | |
function autolike() { | |
const likeButton = document.querySelector('button[aria-label^=like]') | |
const nextButton = document.querySelector('.ytp-next-button') | |
if(!isSelected(likeButton)) likeButton.click() | |
nextButton.click(); | |
setTimeout(autolike, delay) |
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 polynomial(...coefficients) { | |
return function(x) { | |
let result = 0; | |
for(const [index, coefficient] of coefficients.entries()) result += coefficient * x ** index; | |
return 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
class Color { | |
enum { | |
RED(0xff0000), | |
GREEN(0x00ff00), | |
BLUE(0x0000ff) | |
} | |
constructor(hex) { | |
hex %= 0x1000000; | |
this.red = hex >> 0x10; | |
this.green = (hex >> 0x8) % 0x100; |
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 AWS = require('aws-sdk'); | |
/** | |
S3 service interface | |
@type {S3} | |
@see {@link https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html} | |
**/ | |
const s3 = new AWS.S3({ | |
signatureVersion: 'v4' | |
}); |
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
/** | |
Check if value is a float-point number | |
@param {value} value | |
@return {*} | |
**/ | |
function isFloat(value) { | |
const float = Number.parseFloat(value); | |
return !Number.isNaN(float) && float % 1 !== 0; | |
} |
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
Object.defineProperty(BigInt.prototype, 'abs', { | |
get() { | |
return this.valueOf() < 0n | |
? this.valueOf() * -1n | |
: this.valueOf(); | |
} | |
}) | |
(15n).abs; // 15n | |
(-5n).abs; // 5n |
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
Math.symbol = { | |
ceil: Symbol('Math.symbol.ceil') | |
}; | |
class ComplexNumber { | |
constructor(a, b) { | |
this.a = a; | |
this.b = b; | |
} | |
toString() { |
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
import { UUIDGen } from './utils/UUID.js'; | |
const uuidGen = UUIDGen(); | |
// Object property definition method | |
class User { | |
constructor() { | |
Object.define(this, 'uuid', { | |
value: uuidGen.next(), | |
writable: false, | |
configurable: false |
OlderNewer