Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 getSubstrings (string) { | |
var map = new Map | |
for (let n = 1; n < string.length; n++) { | |
for (let i = 0; i < string.length - n; i++) { | |
const item = string.substring(i, i + n) | |
if (!map.has(item)) | |
map.set(item, new Set) |
This file contains hidden or 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 InsertionSort (array, swap, compare) { | |
if (compare === null || compare === undefined) | |
compare = (a, b) => { | |
return a < b } | |
if (swap === null || swap === undefined) | |
swap = (a, b, c) => { | |
const [ x, y ] = [ a[b], a[c] ] | |
a[b] = y | |
a[c] = x; return a } |
This file contains hidden or 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 replacementExpression = /^s\/((?:\\.|[^\/\\])+)\/((?:\\.|[^\/\\])*)\/([gimuy]{0,5})$/ | |
const replacementExpressionCompiled = replacementExpression.exec(process.argv[2]) | |
function getReplacement (input, source, flags, replacement) { | |
const expression = new RegExp(source, flags) | |
return input.replace(expression, function (matched/*, ...captures, index, fulltext, groups? */) { | |
const parameters = Array.from(arguments) | |
const [index, fulltext, groups] = |
This file contains hidden or 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 env = this | |
module.exports = function* addMessage ({ who, what, when, where }) { | |
const command = (/^(?:official|\:)\:\s*(\S+)\s*(.*)/i).exec(what) | |
if (command === null) return | |
if (command[1].toLowerCase() === 'run') { | |
const expression = command[2].match(/\/((?:\\.|[^\/])+)\/([a-z]*)\s*(.+)/) | |
const compiled = new RegExp(expression[1], expression[2]) | |
const string = expression[3] |
This file contains hidden or 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 * getProperties (object) { | |
for (const [key, value] of Object.entries(object)) { | |
yield [key] | |
if (typeof value === 'object') | |
for (const each of getProperties(value)) | |
yield [key, ...each] | |
} | |
} |
This file contains hidden or 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
<form name="message"> | |
<input autofocus="" placeholder="type a message..." name="what" maxlength="510" minlength="1"> | |
<input type="submit" name="why" value="Send"> | |
</form> | |
<nav> | |
<a href="#localhost">localhost</a> | |
<section id="localhost"> | |
<a href="#localhost-#chat">#chat</a> | |
<a href="#localhost-yaclient">yaclient</a> | |
</section> |
This file contains hidden or 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 canvas; | |
let context; | |
let styles = []; | |
canvas = document.createElement('canvas'); | |
context = canvas.getContext('2d'); | |
function getDistance(point1, point2) { | |
return Math.sqrt(Math.pow(point2.y - point1.y, 2) + Math.pow(point2.x - point1.x, 2)); | |
} |
This file contains hidden or 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 expression = {} | |
expression.header_content_type = header_content_type: /(?<mimetype>(?<mimetype_type>[a-z]+|\*)\/(?<mimetype_subtype>[a-z][a-z0-9]*(?:\-[a-z0-9]+)*|\*))(?:\s*;\s*charset=(?<charset>\S+))?(?:\s*;\s*boundary=(?<boundary>\S+))?/ | |
expression.header_content_type.exec(request.headers['content-type']) | |
if (method === 'POST' || method === 'PUT' || method === 'PATCH' || method === 'DELETE') { | |
let data | |
if ((/(?:text|application)\/json/).test(request_contentType.groups.mimetype)) { | |
data = JSON.parse(packet.toString('utf8')) |
This file contains hidden or 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 { performance } = require('perf_hooks') | |
const cluster = require('cluster') | |
const os = require('os') | |
const MAXIMUM_N_VALUE = 1000000000 | |
process.nextTick(main) | |
function main () { |