Skip to content

Instantly share code, notes, and snippets.

View jadbox's full-sized avatar

Jonathan Rose Dunlap jadbox

View GitHub Profile
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
data1 = lambdaMap(data, "*", 3);
//lambdaMap *3: 3,6,9,12,15
trace("lambdaMap *3:", data1);
data1 = lambdaMap(data, "==", 3);
//lambdaMap ==3: false,false,true,false,false
trace("lambdaMap ==3:", data1);
data1 = lambdaMap([[1,2,3],[1,2]], "+", [4,5]);
//lambdaMap [[1,2,3],[1,2]] +[4,5]: [[1,2,3,4,5], [1,2,4,5]]
@jadbox
jadbox / render-react-with-rxjs.md
Last active August 26, 2015 18:28 — forked from zxbodya/render-react-with-rxjs.md
React with RxJS, reactive way :)

Observable React elements with RxJS

When I just started using RxJS with React, I was subscribing to observables in componentDidMount and disposing subscriptions at componentWillUnmount.

But, soon I realised that it is not fun to do all that subscriptions(that are just updating property in component state) manually, and written mixin for this...

Later I have rewritten it as "high order component" and added possibility to pass also obsarvers that will receive events from component.

But, shortly after, I realised that for server side rendering, I need to do something quite complicated(in order to wait until all data would be loaded, before rendering - actually, I was building an isomorphic application, and still working on it).

@jadbox
jadbox / gist:0077c2f0aebcf6db5807
Created February 11, 2016 22:34
NPM Argument #2: Expected string but got object
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'update',
1 verbose cli '--save',
1 verbose cli '--save-dev' ]
2 info using npm@3.3.12
3 info using node@v5.5.0
4 silly mapToRegistry name babel-core
5 silly mapToRegistry using default registry
@jadbox
jadbox / .git-commit-template.txt
Created March 10, 2016 23:28 — forked from adeekshith/.git-commit-template.txt
A Git commit template to make it easy to enforce a good and uniform commit message style across teams.
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
var nodeModules = { classnames: 'commonjs classnames', react: 'commonjs react' };
fs.readdirSync('node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
@jadbox
jadbox / System Design.md
Created April 19, 2016 04:50 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
import most, {
create, of, from
}
from 'most';
function fromNodeCallback(fun) {
return (...x) => create((add, end, error) => {
x.push(handleNodeCB);
fun.apply(null, x);
});
import {Stream} from 'most'
const fromNodeCallBack = fn => (...args) => new Stream(new CallBackSource(fn, args))
class CallBackSource {
constructor (fn, args) {
this.fn = fn
this.args = args
}
@jadbox
jadbox / gist:ae3065eb348b77e8bbcf94cc7181d04d
Created June 25, 2016 19:07 — forked from ralph-tice/gist:c2943aa672aaa65ecb59
PostgreSQL settings to aggressively vacuum, this config was used for an 18000 TPS steadystate workload on i2.xlarge
#------------------------------------------------------------------------------
# AUTOVACUUM PARAMETERS
#------------------------------------------------------------------------------
#autovacuum = on # Enable autovacuum subprocess? 'on'
# requires track_counts to also be on.
log_autovacuum_min_duration = 0 # -1 disables, 0 logs all actions and
# their durations, > 0 logs only
# actions running at least this number
# of milliseconds.