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
/* | |
Decimal 64 bit numbers that make sense | |
Format: | |
======= | |
seeeeeee eepmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm mmmmmmmm | |
s = sign bit | |
e = 10-bit exponent (with p) | |
p = lowest bit of exponent or highest bit of mantissa (subnormal numbers) |
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
Bit 63 = sign | |
Subnormal | |
0.0-9.999 999 999 999 999E-511 | |
Stored as uint64 | |
Normal fp | |
Bit 62-53 = exponent | |
Bit 52-0 = mantissa | |
Mantissa range 0-8 999 999 999 999 999 |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
char * numberAsString(uint64_t num) { | |
static char result[] = "+1.234567890123456e-123"; | |
char sign = (num & 0x8000000000000000L) ? '-' : '+'; | |
uint16_t scale = (num >> 50) & 0x1fff; | |
if (scale << 2 == 0x7ff0) |
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
$ git push | |
fatal: You are not currently on a branch. | |
To push the history leading to the current (detached HEAD) | |
state now, use | |
git push origin HEAD:<name-of-remote-branch> |
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
private static final Pattern parser = Pattern.compile("/(\\S+)/"); | |
private String parseAction(String tag) { | |
Matcher them = parser.matcher(tag); | |
if (!them.find()) return "YOLO"; | |
return them.group(1); | |
} | |
Result: |
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
# An implementation of the Mafia party game state machine. | |
import "lib/enum" =~ [=> makeEnum] | |
exports (makeMafia, DAY, NIGHT) | |
def [MafiaState :DeepFrozen, | |
DAY :DeepFrozen, | |
NIGHT :DeepFrozen] := makeEnum(["day", "night"]) |
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
"use strict"; | |
function copy(proto, changes) { | |
if (changes === undefined) return Object.create(proto); | |
var props = Object.keys(changes).map(function(attr) { | |
var single = {}; | |
single[attr] = {value: changes[attr], writable: false, enumerable: true}; | |
return single; | |
}); | |
return Object.create(proto, Object.assign.apply(props)); |
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
> console.log(Promise.toString()) | |
function Promise() { [native code] } | |
undefined | |
> function Promise(execute) { | |
... this.then = execute; | |
... this.catch = function catch(handler) { | |
..... return this; | |
..... }; | |
... } | |
... ; |
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
var mistigri = (function(){ | |
/* | |
if (Promise === undefined) | |
{ | |
console.log("Making a fake Promise"); | |
var Promise = function Promise(execute) { | |
this.then = execute; // Mistigri always returns, even if it ran into problems | |
this.catch = function(onrej) { | |
return this; |
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
var handleAllIncludes = function handleAllIncludes(includes, config, rendered, size, finish) { | |
if (includes.work.length === 0) | |
{ | |
if (finish !== undefined) finish(rendered); | |
return; | |
} | |
if (finish === undefined) | |
{ | |
console.warn("Mistigri needs a callback - ignoring all includes"); | |
return; |