Skip to content

Instantly share code, notes, and snippets.

View eiriklv's full-sized avatar

Eirik L. Vullum eiriklv

View GitHub Profile
@LewisJEllis
LewisJEllis / gist:1ac2e10e9309b3f59017
Last active July 2, 2016 01:12
Highland reduce example
var express = require('express');
var _ = require('highland');
var fs = require('fs');
var app = express();
function chain(s, f) {
return s.flatMap(_.wrapCallback(f))
}
app.post('/process-file', function(req, res) {
// clean and pure:
function cons(x, y) {
return function(pick) {
return pick(x, y);
}
}
// does more stuff:
function cons(x, y) {
var fn = function(pick) {
@simenbrekken
simenbrekken / context.js
Created April 24, 2014 12:48
Manipulating React immutable stores with context
var Application = React.createClass({
childContextTypes: {
createProduct: React.PropTypes.func
},
getChildContext: function() {
return {
createProduct: this.createProduct
}
},
@branneman
branneman / pair.js
Last active September 27, 2016 12:06
Pairs (length 2 tuples) in JavaScript
/**
* Pair
* @todo Implement algebraic structures: Setoid, Functor
*/
var Pair = function(fst, snd) {
if (this instanceof Pair) {
if (Array.isArray(fst) && fst.length === 2 && typeof snd == 'undefined') {
this[0] = fst[0];
this[1] = fst[1];
} else {
@anantn
anantn / firebase_workers.js
Created December 27, 2012 22:11
Firebase: Implementing a worker queue pattern using firebase_queue_pop.js
var Firebase = require("./firebase-node.js");
function Queue(ref) {
this._ref = ref;
}
Queue.prototype.pop = function(cb) {
this._ref.startAt().limit(1).once("child_added", this._pop.bind(this, cb));
}
@hsribei
hsribei / putting-the-tor-back-in-torrent.md
Last active January 18, 2017 22:08
Putting the "Tor" back in Torrent

Putting the "Tor" back in Torrent

How a Popcorn Time fork patch could incentivize people to run thousands of new Tor relays

This is a follow-up to this discussion: Can NAT traversal be Tor's killer feature?

If torrents are P2P's killer application, and NAT traversal/"static IP" are Tor's (via hidden services), putting them together could prove to be the best incentivization scheme for growing the Tor network other than cold crypto cash.

You're stupid

Everybody knows you're not supposed to use torrents with tor, right?

@sockdrawermoney
sockdrawermoney / deehock-leadership.md
Last active April 2, 2017 07:07
Dee Hock on Leadership

Leader presumes follower. Follower presumes choice. One who is coerced to the purposes, objectives, or preferences of another is not a follower in any true sense of the word, but an object of manipulation. Nor is the relationship materially altered if both parties voluntarily accept the dominance of one by the other. A true leader cannot be bound to lead. A true follower cannot be bound to follow. The moment they are bound they are no longer leader or follower. If the behavior of either is compelled, whether by force, economic necessity, or contractual arrangement, the relationship is altered to one of superior/subordinate, manager/employee, master/servant, or owner/slave. All such relationships are materially different from leader/follower.

Induced behavior is the essence of leader-follower. Compelled behavior is the essence of all the others. Where behavior is compelled, there lies tyranny, however benign. Mere behavior is induced, there lies leadership, however powerful. Leadership does not imply construc

@donspaulding
donspaulding / pooFlinger.js
Created July 13, 2015 21:32
Continually fling poo at someone...
'use strict';
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
function flingPoo(){
res.write("💩");
setTimeout(flingPoo, 1000);
}
flingPoo();
@jixunmoe
jixunmoe / bind.gen.without.ctx.js
Last active July 6, 2017 12:27
[ES6] Bind generator without context.
/**
* Bind generator with context preserved.
* @param {Generator} fn The generator
* @return {Generator} Generator with arguments bind.
*/
var _bind = function (fn) {
var args = [].slice.call(arguments, 1);
return function * () {
var ir = fn.apply (this, args.concat.apply(args, arguments));
var n;
@mikermcneil
mikermcneil / outcome-oriented-programming.md
Last active July 13, 2017 14:34
Outcome Oriented Programming - Software as a plan

Outcome-Oriented Programming

Mike McNeil, Aug 2014

Humans are not very good at planning. We have no problem running scenarios, thinking through possibilities, and pondering "what if?" questions. I might plan to not eat my cousin's birthday cake before she gets home, for instance. If I'm very serious, I might write down my commitment; or if I'm unsure about the pros and cons, use some organizational tool like a T-chart.

But when it comes to making a decision in the moment, all bets are off. The cake is a goner.

Predictive Analysis vs. Process Design

Below, I've included a figure containing a decision tree diagram.