Skip to content

Instantly share code, notes, and snippets.

src/dstr-binding-for-await/default/for-await-of-async-func-let.template:43: macro name not found: body, in case: src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
src/dstr-binding-for-await/default/for-await-of-async-gen-let-async.template:46: macro name not found: body, in case: src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
src/dstr-binding-for-await/default/for-await-of-async-gen-var-async.template:46: macro name not found: body, in case: src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
src/dstr-binding-for-await/default/for-await-of-async-gen-const.template:43: macro name not found: body, in case: src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
src/dstr-binding-for-await/default/for-await-of-async-func-const.template:43: macro name not found: body, in case: src/dstr-binding-for-await/ary-ptrn-rest-not-final-id.case
src/dstr-binding-for-await/default/for-await-of-async-func-const-async.template:46: macro name not found: body, in case: src/dstr-binding-for-await/ary
@thejoshwolfe
thejoshwolfe / README.md
Last active April 22, 2023 23:55
Plan for publishing the Hollow Knight Modding API to GitHub without infringing on copyright
op_list = [
("<", lambda a, b: a < b, "less-than"),
("<=", lambda a, b: a <= b, "less-than-or-equal"),
(">", lambda a, b: a > b, "greater-than"),
(">=", lambda a, b: a >= b, "greater-than-or-equal"),
]
# This is the hex representation of Number.MAX_VALUE.
max_value_digits = "0xfffffffffffff8" + "0" * 242
function generateCases(a, b, cmp) {
function generateCase(a, op, b, result) {
print("assert.sameValue(" + a + " " + op + " " + b + ", " + result + ");");
}
generateCase(a, "<", b, cmp < 0);
generateCase(a, "<=", b, cmp <= 0);
generateCase(a, ">", b, cmp > 0);
generateCase(a, ">=", b, cmp >= 0);
generateCase(b, "<", a, 0 < cmp);
generateCase(b, "<=", a, 0 <= cmp);
function assertSameValue(result, expected, resultStr) {
if (result === expected) return;
$ERROR("Expected (" + resultStr + ") to be " + expected + " but it was " + result);
}
function compare(a, aStr, b, bStr, cmp) {
assertSameValue(a < b, cmp < 0, aStr + " < " + bStr);
assertSameValue(a <= b, cmp <= 0, aStr + " <= " + bStr);
assertSameValue(a > b, cmp > 0, aStr + " > " + bStr);
assertSameValue(a >= b, cmp >= 0, aStr + " >= " + bStr);
@thejoshwolfe
thejoshwolfe / main.c
Created August 25, 2017 23:28
given 3 ints, return the median
int median3(int a, int b, int c) {
int index =
((a < b) << 0) |
((b < c) << 1) |
((c < a) << 2);
switch (index) {
case 0: unreachable();
case 1: return c;
case 2: return a;
case 3: return b;
@thejoshwolfe
thejoshwolfe / harness_verifyParameter.js
Created August 23, 2017 21:30
Idea for generic parameter type coercion checking
function verifyParameterToIndex(testCases) {
// TODO: Something similar to verifyParameterToInteger, possibly begin by calling it first.
// TODO: Then also test that outside [0, 2**53-1] throws a RangeError.
}
function verifyParameterToInteger(testCases) {
function MyError() {}
var simpleValues = [
[
@thejoshwolfe
thejoshwolfe / a.js
Created April 17, 2017 19:59
testing if abandoning a zlib inflate stream causes a memory leak
var zlib = require("zlib");
var Transform = require("stream").Transform;
var BufferList = require("bl");
function createDeflatedBuffer(size, cb) {
var inputBuffer = new Buffer(size);
for (var i = 0; i < size; i++) {
inputBuffer[i] = Math.floor(Math.random() * 0x100);
}
var deflater = zlib.createDeflateRaw();
pub struct AllocatorVtable {
allocFn: fn (self: &Allocator, n: usize) -> %[]u8,
reallocFn: fn (self: &Allocator, old_mem: []u8, new_size: usize) -> %[]u8,
freeFn: fn (self: &Allocator, mem: []u8),
}
pub struct Allocator {
vtable: &AllocatorVtable,
}
...................................................................................................#
...............................................................................................#####
..........................................................................................##########
.....................................................................................###############
................................................................................####################
..........................................................................##########################
......................................................................##############################
.................................................................###################################
...........................................................#########################################
.......................................................#############################################