Skip to content

Instantly share code, notes, and snippets.

@totherik
totherik / csr.js
Created April 7, 2017 19:12
Compressed Sparse Row (CSR) Matrix
// https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_row_.28CSR.2C_CRS_or_Yale_format.29
function csr(matrix) {
const A = [];
const IA = [0];
const JA = [];
const nnz = [];
for (const [ index, row ] of matrix.entries()) {
nnz[index] = 0;
/**
* A simple (and I assume fairly slow) function for generating a unique selector for a given element.
* @param element
* @returns {string}
*/
function generateSelector(element) {
let selector = [];
let root = document.body.parentElement;
while (element && element !== root && !element.id) {
import finished from 'on-finished';
let counts;
function reset() {
counts = {
/*
Synthesized properties...
http_200: 0,
+----------------+--------------------------+---------------------------+
| | | |
| | Synchronous | Asynchronous |
| | | |
+-----------------------------------------------------------------------+
| | | |
| function | T | Promise |
| | | |
+-----------------------------------------------------------------------+
| | | |
'use strict';
var http = require('http');
var express = require('express');
var enrouten = require('enrouten');
var app, server;
app = express();
@totherik
totherik / api.js
Last active August 29, 2015 14:10
DI Brainstorming
// Option 1: To be spec-ed
module.exports = function (router, obj1, obj2, obj3) {
// obj1
// obj2
// obj3
};
// Option 2: To be spec-ed. Counld behave similar to example below.
module.exports = function (router, context) {
@totherik
totherik / client.js
Last active August 29, 2015 14:08
Brainstorming read/write socket implementations.
'use strict';
var ToughSocket = require('./socket');
var socket = new ToughSocket(8124, 'localhost', { resetTimeout: 1000 });
socket.on('data', function (chunk) {
console.log('read', chunk.toString('utf8'));
});
@totherik
totherik / emitter.js
Last active August 29, 2015 14:07
Levee Emitter Wrapper
'use strict';
var Net = require('net');
var Promise = require('promise');
var Levee = require('levee');
// Experimental emitter wrapper for Levee circuits.
Levee.wrapEmitter = function wrapEmitter(factory, execute) {
return {

Issues

Triage immediately. Overnight issues triaged next morning. Label issues with one of the following:

support The issue is a question about how to use the software.

bug The issue reports a known, reproducible bug in the software.

@totherik
totherik / 0db-middleware.js
Last active August 29, 2015 14:06
Resilient MongoDb Connection using Promises and Levee
'use strict';
var DbConn = require('./conn');
var Levee = require('levee');
module.exports = function (options) {
var conn, breaker;
conn = new DbConn(options.uri);