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
/* jshint node: true */ | |
'use strict'; | |
var avsc = require('avsc'); | |
/** | |
* Function returning an instrumented type. | |
* | |
* @param schema {Object} Schema to parse. |
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
s = "s = %j; t = %j; print t % (t, s)"; t = "var util = require('util'); var s = %r; var t = %r; console.log(util.format(t, t, s));"; print t % (t, s) |
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
"""JSON serialization with value expansion.""" | |
from json import JSONEncoder | |
import re | |
# Try 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
def indices(m, n): | |
"""Index generator to visit a 2-dimensional matrix in increasing i + j. | |
:param m: Number of rows. | |
:param n: Number of columns. | |
""" | |
for i in range(m): | |
for j in range(min(n, i + 1)): | |
yield (i - j, j) |
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
/* jshint browser: true, node: true */ | |
(function (root) { | |
'use strict'; | |
/** | |
* Bidirectional lazy loader. | |
* | |
* This class exposes a very simple API (`reset`, `next`, and `prev`) via | |
* which we can iterate (lazily and in both directions!) over a traditional |
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
/* jshint browser: true */ | |
(function (root) { | |
'use strict'; | |
/** | |
* Simple lazy asynchronous iterator. | |
* | |
* Lazily iterate over a collection served from a standard REST endpoint. | |
* Elements are loaded by batch (of size `highWaterMark`), and |
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 stream = require('stream'), | |
util = require('util'); | |
/** | |
* Batch loaded readable stream. | |
* | |
* @param {Function} `fn(cb)`, where `cb(err, iter)`. Function used to feed | |
* the stream. `iter` should either be an iterator or `null` to signal EOT. | |
* @param {Object} `opts` Options forwarded to `stream.Readable`, along with | |
* the following: `batchHighWatermark`, the maximum number of batches |
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
/** | |
* Benchmark functions serially. | |
* | |
* This is useful for async functions which yield too often to the event | |
* loop to be correctly benchmarked. | |
* | |
*/ | |
function Benchmark() { | |
var fns = {}; |
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
/** | |
* https://news.ycombinator.com/item?id=8737349 | |
* | |
*/ | |
#include <stdlib.h> | |
#define SIZE 1024 | |
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
"""Python numbers magic! | |
https://jakevdp.github.io/blog/2014/05/09/why-python-is-slow/ | |
Adapted for python 2.7. | |
""" |