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
function memoizer(fn) { | |
if (typeof fn !== 'function') { | |
console.error('Need a function.'); | |
return () => {}; | |
} else { | |
return (() => { | |
const cache = {}; | |
eval(` | |
function memoized(...args) { | |
const impl = ${fn.toString().replace('{', `{ const ${fn.name} = memoized; `)} |
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
// To run: `g++ -O3 calc.cc && ./a.out`. | |
// Example values to run on are commented out in lines 8..10. | |
#include <cmath> | |
#include <iostream> | |
#include <iomanip> | |
long double const range = std::pow(2.0, 64); // std::pow(1.0, 32); // 1e6; | |
long double const desired_p_of_collision = 0.01; // 1e-5; 1e-2; // 0.5; | |
long double const desired_log_p = logl(1.0 - desired_p_of_collision); |
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
let function_bodies = {}; | |
let plans = {}; | |
const opa_builtins = { | |
plus: (args) => { return { t: 'number', v: args[0].v + args[1].v }; }, | |
minus: (args) => { return { t: 'number', v: args[0].v - args[1].v }; }, | |
mul: (args) => { return { t: 'number', v: args[0].v * args[1].v }; }, | |
numbers: { | |
range: (args) => { | |
let v = []; | |
for (let i = args[0].v; i <= args[1].v; ++i) { |
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
{ | |
"static": { | |
"strings": [ | |
{ | |
"value": "result" | |
}, | |
{ | |
"value": "a" | |
}, | |
{ |
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
al = 0 | |
si = 0x500 | |
ram[si] = al | |
++si; | |
++al; | |
ram[si] = al | |
cx = ram[0] | |
cx -= 2; | |
while (cx) { | |
al = ram[si - 1] |
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
N = 8; | |
ram = []; | |
for (let i = 0; i < N; ++i) { | |
ram[0x500 + i] = 0; | |
} | |
ram[0] = N; | |
al = 0 | |
si = 0x500 | |
ram[si] = al |
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
digraph test_setup { | |
rankdir = LR; | |
node [ shape = cylinder; label = "DB" ]; | |
db_indexer; | |
db_forwarder; | |
node [ shape = box3d ]; | |
{ rank = same; indexer; db_indexer; } | |
{ rank = same; forwarder; db_forwarder; } | |
generator [ label = "Generator"; ]; | |
indexer [ label = "Indexer"; ]; |
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
digraph test_setup { | |
rankdir = LR; | |
node [ shape = cylinder; label = "DB" ]; | |
db_indexer; | |
db1; db11; db12; db2; db21; db22; db3; db4; db5; | |
node [ shape = box3d ]; | |
{ rank = same; indexer; db_indexer; } | |
source1 [ label = "Generator A"; ]; | |
source2 [ label = "Generator B"; ]; | |
source3 [ label = "RSocket Wrapper"; ]; |
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
dima@dima-x1:~/github/dkorolev/current/examples/datafest_talk/tier2_rides_by_months@unstable $ cat step5_rides_by_months_unoptimized.c | |
// To run: gcc -O3 step5_rides_by_months_unoptimized.c && time ./a.out | tee >(md5sum) | |
// | |
// Count rides by month, print the counters in the lexicographically sorted order of keys. | |
// The "canonical C" implementation, with no extra checks, unsafe in a few ways, but still only 2x slower than `wc -l`. | |
#include <stdio.h> | |
int MM[12]; |
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 <string.h> | |
#include <time.h> | |
int parse(const char* timestamp_as_string) { | |
struct tm struct_tm; | |
time_t t; | |
memset(&struct_tm, 0, sizeof(struct tm)); | |
if (strptime(timestamp_as_string, "%m/%d/%Y %H:%M", &struct_tm)) { | |
printf("strptime() returned `%d/%02d/%02d %02d:%02d:%02d; is_dst = %d`, ", |
NewerOlder