Skip to content

Instantly share code, notes, and snippets.

Sequoia /
Last active Aug 8, 2019
Why not to export & test internal functions

Why Is It Bad To Export Functions Exclusively For Testing?

ℹ️ Summary: Test the destination, not the route.

We have a module that doubles numbers. It does this by bit-shifting the supplied number once left.

// double.js

// exported to allow testing...

Version 4

Type: Bug 🐞 || Feature 🚀

  • 🏷 JIRA Ticket: EXP-
  • 🚩 Feature Flag:

🌞 From a high level, what is this PR for?

(one sentence summary)

Sequoia / kv_server.go
Created Feb 23, 2019
My solution to the exercise
View kv_server.go
// Key Value Server
package main
import (
View addon.c
#include <unistd.h>
#include <node.h>
#include <string.h>
#include <v8.h>
using namespace v8;
unsigned long long count = 0;
// native blocking/compute intensive function
Sequoia / getFiles.js
Last active Nov 11, 2016
Get File Contents of Multiple Files as a Promise
View getFiles.js
import Promise from 'bluebird';
import {readFiles} from 'node-dir';
import {l} from './util';
* @param {String} root path
* @param {Object} options see:
* @return {Promise<String[]>}
export default function getFiles(root, options){
Sequoia / scan-file-contents.js
Created Nov 3, 2016
PoC for a static blog script written in RX.js
View scan-file-contents.js
const Rx = require('rxjs');
const debug = require('debug');
const chokidar = require('chokidar');
const dirWatcher ='./_data/*.md');
const readFile = require('fs').readFile;
const readFileAsObservable = Rx.Observable.bindNodeCallback(readFile);
const newFiles = Rx.Observable.fromEvent(dirWatcher, 'add');
View demo-schema.json
"$schema" : "",
"id": "",
"title": "More than one type",
"description": "This schema has a single property with multiple types",
"definitions" : {
"specialString" : {
"type" : "string",
"description": "(3) The String One!",
"enum" : ["yes", "no", "maybe"]
Sequoia /
Last active Jun 3, 2016
Why does VS Code not know what properties my SurveyQuestion type has?
Sequoia /
Created Jun 1, 2016
tool to run different functions based on the type of an object

I'm working with Leaflet.js & Leaflet-Editable.js there are a lot places where I need to respond to clicks on, creation of, etc. different types of map features differently. This function allows me to eschew if,else,if,else blocks for these cases.



if(is(L.Marker, feature)){
} else if(is(L.Polyline, feature)){
Sequoia / Agent.js
Created May 18, 2016
hasMany relationship
View Agent.js
* @return {Promise}
* @fulfill {Array} [{HomeActivityEvent}] array of digest sent events
Agent.sendDigestToClients = function(id){
let recordid;
return Agent.findById(id)
recordid =;
return agent;