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 AsyncWebSocket | |
{ | |
constructor() | |
{ | |
this.socket = null; | |
this.resolvers = []; | |
} | |
connect(remote) | |
{ |
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 gfm.math; | |
Vec project(Vec: Vector!(T, N), T, size_t N)(Vec a, Vec b) | |
{ | |
return b * scalarProject(a, b); | |
} | |
T scalarProject(Vec: Vector!(T, N), T, size_t N)(Vec a, Vec b) | |
{ | |
import std.math: cos; |
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 std.traits; | |
Type construct(Type)(RepresentationTypeTuple!Type args) | |
{ | |
static union Conv | |
{ | |
Type obj; | |
struct { typeof(args) fields; } | |
} | |
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 fs = require("fs"); | |
module.exports = function(source) | |
{ | |
const buffer = fs.readFileSync(this.resourcePath) | |
return `module.exports = Uint8Array.from([${buffer.toJSON().data}]);`; | |
} |
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 chunks = ( | |
(array, size) => | |
Array.from( | |
Array(array.length / size), | |
(_, x) => | |
Array.from( | |
Array(size), | |
(_, y) => array[size * x + y] | |
) | |
) |
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 cache = {}; | |
const queue = []; | |
export function enqueueImage(path) | |
{ | |
if(cache.hasOwnProperty(path)) | |
return; | |
queue.push(path); | |
} |
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
string[] shlex(string line) | |
{ | |
string[] result; | |
string current; | |
char quoteChr = 0; | |
bool escape; | |
foreach(chr; line) | |
{ | |
switch(chr) |
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
public import std.typecons: Yes, No; | |
struct ClampedNumber(NumericT) | |
{ | |
import std.traits: isNumeric; | |
import std.typecons: Flag; | |
alias Numeric = NumericT; | |
alias TrackUnclamped = Flag!"trackUnclamped"; | |
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
/* | |
Compiles SCSS files on-the-fly in the browser. Minimal example: | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- Strips content from the head of imported SCSS files to calculate the logical path. Optional. --> | |
<meta name="scss-prefix" content="src"> | |
<!-- Dependencies and this script. --> |
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
local SLOT_PICKAXE = 14 | |
local SLOT_AXE = 15 | |
local SLOT_COAL = 16 | |
local SLOT_LAST = 12 | |
local SLEEP_DELAY = 30 | |
local component = require("component") | |
local robot = require("robot") | |
local inv = component.inventory_controller | |
local geo = component.geolyzer |