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
#!/usr/bin/env python | |
"""\ | |
looks for non-utf8, windows-style encodings in filenames and fixes them. | |
""" | |
__version__ = "0.0" | |
import os, sys |
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
#!/usr/bin/env python | |
import sys | |
import json | |
def diff_objects(left, right): | |
if not (type(left) == type(right) == dict): | |
return right | |
result = {} | |
keys = 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
/** random 128-bit number as a string */ | |
function random128() { | |
var result = ""; | |
for (var i = 0; i < 8; i++) | |
result += String.fromCharCode(Math.random() * 0x10000); | |
return result; | |
} | |
/** random 128-bit number in canonical uuid format. all bits are random. */ | |
function random128Hex() { |
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
...................................................................................................# | |
...............................................................................................##### | |
..........................................................................................########## | |
.....................................................................................############### | |
................................................................................#################### | |
..........................................................................########################## | |
......................................................................############################## | |
.................................................................################################### | |
...........................................................######################################### | |
.......................................................############################################# |
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
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, | |
} |
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
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(); |
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 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 = [ | |
[ |
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
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; |
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 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); |
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 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); |
OlderNewer