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 express = require('express'); | |
const app = express(); | |
app.use(express.static("./")); | |
const server = app.listen(8080, () => console.log("Listening for HTTP on port 8080\n")); |
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
// Returns the value of the URL hash parameter, or `null` if the value is empty. | |
function getHash() { | |
if (window.location.hash.length < 2) return null; | |
return window.location.hash.slice(1, window.location.hash.length) | |
} | |
const headingSelector = "h1, h2, h3, h4, h5, h6"; | |
// Scrolls to the first Heading element which matches `title`. | |
function scrollToHeading(title) { | |
const headings = document.querySelectorAll(headingSelector); | |
if (headings === null) return; |
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
/* Table Of Contents: | |
GeneratorFunction | |
The GeneratorFunction constructor, exposed. | |
isSetIterator | |
Returns true if the object is a bultin Set Iterator. | |
isMapIterator | |
Returns true if the object is a builtin Map Iterator. | |
iterableObject | |
Make a regular Object an iterable. | |
get |
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 isFloat(int) { | |
return int % 1 !== 0; | |
} | |
function padBinary(string, pad = 7) { | |
while(string.length < pad) string = "0".concat(string); | |
return string; | |
} | |
if ((typeof window) === "undefined" || !("btoa" in window)) var btoa = v => Buffer.from(v).toString("base64"); | |
if ((typeof window) === "undefined" || !("atob" in window)) var atob = v => Buffer.from(v, "base64").toString(); | |
const toBase64 = btoa; |
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 XHR(url = "/", verb = "GET", data = null) { | |
this.requestor = null; | |
this.url = url; | |
this.verb = verb; | |
this.data = data; | |
} | |
XHR.prototype.executor = function (resolve, reject) { | |
this.requestor.onreadystatechange = () => this.stateChange(resolve, reject); | |
this.requestor.ontimeout = () => this.timeout(resolve, reject); | |
this.requestor.onerror = reject; |
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
// Parses a CSV string into a Row-first array. | |
function parseCsv(csvString) { | |
const rows = [[]]; | |
var curRow = rows[0]; | |
var code; | |
for (var loc = 0; loc < csvString.length; loc++) { | |
code = csvString.charCodeAt(loc); | |
if (code === 10 && loc !== csvString.length - 1) { | |
// Add a Row | |
curRow = []; |
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 SEMICOLON = [[59, 59]]; | |
const SPACE = [[32, 32]]; | |
const NUMERIC = [[48, 57]]; | |
const ALPHA = [[65, 90], [97, 122]]; | |
const ALPHA_SPACE = [...SPACE, ...ALPHA]; | |
const ALPHA_NUMERIC = [...NUMERIC, ...ALPHA]; | |
const ALPHA_NUMERIC_SPACE = [...SPACE, ...ALPHA_NUMERIC]; | |
// Returns the first contiguous substring in `string`, starting at `start`, which precedes symbols found in `nt`. | |
function scanToken(string, start = 0, nt = [" "]) { | |
var subString = ""; |
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 BG_QUANTUM = 50; | |
const FG_QUANTUM = 300; | |
function Kernel() { | |
this.queue = new this.stdLib.CircularDoubleLinkedList(); | |
this.backgroundQueue = new this.stdLib.CircularDoubleLinkedList(); | |
this.queue.tail.next = this.backgroundQueue.head; | |
this.queue.head.prev = this.backgroundQueue.tail; | |
this.backgroundQueue.tail.next = this.queue.head; | |
this.backgroundQueue.head.prev = this.queue.tail; | |
this.procs = new Map(); |
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
/** | |
* assert - Logs or throws an Error if `boolean` is false, | |
* If `boolean` is `true`, nothing happens. | |
* If `errorType` is set, throws a new Error of type `errorType` instead of logging to console. | |
* @param {Boolean} boolean The activation Boolean. | |
* @param {String} message The message to log, or include in the Error. | |
* @param {Error} errorType = null If not `null`, throws a new error of `errorType`. | |
*/ | |
function assert(boolean, message, errorType = null) { | |
if (boolean) return; |
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 IntervalTree() { | |
this.intervals = []; | |
this.intervals[0] = []; | |
this.nodes = []; | |
} | |
IntervalTree.prototype.addInterval = function (unit, id) { | |
if (id > this.intervals.length - 1) { | |
this.intervals[id] = []; | |
} | |
this.intervals[id][this.intervals[id].length] = unit; |
NewerOlder