Skip to content

Instantly share code, notes, and snippets.

@Sequoia
Sequoia / mermaid.md
Last active June 10, 2022 21:54 — forked from lhorie/mermaid.md
flow chart example
flowchart TB

start{Response is OK\n& complete?}
start-->|Yes|ok1[no log needed]
start-->|No|isclienterror{problem with input\ni.e. client error?}

isclienterror-->|Yes|warnclienterror[log warning]
isclienterror-->|No|blocksfunctionality{does this break\nuser experience?}
warnclienterror-.->m3Metric[Consider adding an M3 metric\nwith an associated alert]
@Sequoia
Sequoia / why.md
Last active August 8, 2019 14:01
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
Sequoia / kv_server.go
Created February 23, 2019 17:21
My solution to the Lynda.com exercise
// Key Value Server
package main
import (
"fmt"
"log"
"net/http"
"encoding/json"
"sync"
"strings"
#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
Sequoia / getFiles.js
Last active August 5, 2021 12:11
Get File Contents of Multiple Files as a Promise
import Promise from 'bluebird';
import {readFiles} from 'node-dir';
import {l} from './util';
/**
* @param {String} root path
* @param {Object} options see: https://www.npmjs.com/package/node-dir
* @return {Promise<String[]>}
*/
export default function getFiles(root, options){
@Sequoia
Sequoia / scan-file-contents.js
Created November 3, 2016 17:59
PoC for a static blog script written in RX.js
const Rx = require('rxjs');
const debug = require('debug');
const chokidar = require('chokidar');
const dirWatcher = chokidar.watch('./_data/*.md');
const readFile = require('fs').readFile;
const readFileAsObservable = Rx.Observable.bindNodeCallback(readFile);
const newFiles = Rx.Observable.fromEvent(dirWatcher, 'add');
{
"$schema" : "http://json-schema.org/draft-04/schema#",
"id": "https://gist.githubusercontent.com/Sequoia/d86032bff4413759c2f27e9cf852817b/raw/demo-schema.json",
"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
Sequoia / README.md
Last active June 3, 2016 19:35
Why does VS Code not know what properties my SurveyQuestion type has?

tooltip showing properties for other types

@Sequoia
Sequoia / README.md
Created June 1, 2016 21:30
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.

Example:

Before

if(is(L.Marker, feature)){
  setMarkerStyleActive(feature);
} else if(is(L.Polyline, feature)){
 setPolylineStyleActive(feature);