Skip to content

Instantly share code, notes, and snippets.

Verifying that +lennym is my openname (Bitcoin username). https://onename.com/lennym
@ldm5180
ldm5180 / lrhttp-status-cats.js
Last active August 29, 2015 14:08
LineRate HTTP Status Cats
var cats = require('http-status-cats').cats;
var vsm = require('lrs/virtualServerModule');
function addRespHandler(req, res, next) {
next.on('response', function(clires) {
clires.bindHeaders(res);
res.setHeader('X-Status-Cat', cats[clires.statusCode]);
clires.fastPipe(res);
});
next();
@ldm5180
ldm5180 / stack-test-snippet.cpp
Last active August 29, 2015 14:06
Testing containers for depth-first tree traversal
template <typename Container> void tester(int iterations) {
srandom(1337); // Seed PRNG to a known value for reproducibility.
Container nodesToProcess(1); // Start with the first node to process.
for (auto i = 0; i < iterations; ++i) {
// Nodes are provided. Isolate and commonize generation.
auto rand = random() % 128; // Determine number of nodes at this level.
std::vector<typename Container::value_type> nodes(rand);
// Process a node.
if (!nodesToProcess.empty()) {