Skip to content

Instantly share code, notes, and snippets.

View Raynos's full-sized avatar

Jake Verbaten Raynos

View GitHub Profile
@Raynos
Raynos / trace-timer-leak.js
Created November 29, 2014 02:48
Find any timers that have been leaked.
var timeoutStacks = (function () {
var $timers = require('timers');
var $setInterval = $timers.setInterval;
var $setTimeout = $timers.setTimeout;
var stacks = {};
global.setInterval = function (fn, timeout) {
var stack = new Error().stack;

What is an FRP application.

An FRP application has the following properties

  • Functional, pure, immutable.
  • Reactive, your application is a DAG, you react to "core" inputs and from new outputs.

Being an immutable DAG

If your application is an immutable DAG it has certain properties

@Raynos
Raynos / click-event.js
Created August 31, 2014 05:43
Mercury router
module.exports = clickEvent;
function clickEvent(handler, opts) {
opts = opts || {};
return function clickHandler(ev) {
if (!opts.ctrl && ev.ctrlKey) {
return;
}
var STATUS_CODES = require('http').STATUS_CODES;
var sendJson = require('send-data/json');
var url = require('url');
function (req, res, opts) {
var clients = opts.clients;
var config = opts.config;
var errOpts = {
// verbose is true in dev where it prints stacks
// lib/create-server.js
var http = require('http');
var perf = require('playdoh-server/perf');
module.exports = createServer;
function createServer(handler, opts) {
// boot your app here
var server = http.createServer(handler);
var config = opts.config;
@Raynos
Raynos / index.js
Created July 23, 2014 02:51 — forked from jfsiii/index.js
requirebin sketch
var diff = require('virtual-dom/diff');
var patch = require('virtual-dom/patch');
var h = require('virtual-dom/h');
var createElement = require('virtual-dom/create-element');
var virtualize = require('vdom-virtualize');
// 1: Create a function that declares what the DOM should look like
function render(count) {
// var html = '<div id="test">Count is <span>' + count + '</span></div>';
//return virtualize.fromHTML(html);
@Raynos
Raynos / .jscsrc
Last active August 29, 2015 14:04
{
"validateIndentation": 4,
"maximumLineLength": {
"value": 80,
"allowUrlComments": true,
"allowComments": false,
"allowRegex": false
},
"requireSpaceAfterKeywords": [
"if",
var jsonBody = require('body/json');
/* usage
```js
router.addRoute('/foo/bar',
bodyParser(function (req, res, opts, cb)))
```
using multiple "middlewares"
/*
concatMap takes an iter and returns one.
It takes a mapper of (value, push, done)
You may call `push` zero or more times with a value.
You must call `done` with either `Error` or `null`
You may not call `push` after `done`