This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('request-promise'); | |
state.orders = state.orders || []; | |
this.GET = getOrders; | |
this.POST = startOrderProcess; | |
this.DELETE = abortOrder; | |
if(!this[req.method]) return res.status(404).end(); | |
this[req.method](req.params, req.body); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Flow = function(){ | |
this.args = Array.prototype.slice.call(arguments); | |
var next = function(){ | |
if(this.args.length>0){ | |
this.args.shift(); | |
this.args[0].apply(next, Array.prototype.slice.call(arguments)); | |
} | |
}.bind(this); | |
this.args[0].apply(next); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
(function(exports){ | |
exports.Aggregate = function(){ | |
var events = [], | |
state = {}; | |
return { | |
when: function(match){ | |
state = match.$init ? match.$init : {}; | |
for (var i = 0; i < events.length; i++) { | |
if(match[events[i].type] && events[i].data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <ReactiveCocoa/ReactiveCocoa.h> | |
@interface EventAggregator : NSObject { | |
RACSubject *subject; | |
RACSignal *stream; | |
} | |
- (void) subscribe:(Class) type :(void (^)(id event))handler; | |
- (void) send:(id)event; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var calculator = { | |
add: function (node) { | |
return visit(this, node.l) + visit(this, node.r); | |
}, | |
sub: function (node) { | |
return visit(this, node.l) - visit(this, node.r); | |
}, | |
value: function (node) { | |
return node.value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>Reactive Applications</title> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.1.11/rx.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.1.11/rx.aggregates.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.1.18/rx.time.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.1.11/rx.binding.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs-dom/2.0.7/rx.dom.min.js"></script> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var amount = 99; | |
(from n in new[] { 1, 2, 5, 10, 20, 50, 100 } | |
orderby n descending | |
select new { Coin = n, Number = amount / n, Spare = (amount %= n) }).Dump(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>Reactive Coin Changer</title> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.1.11/rx.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.1.11/rx.aggregates.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.1.18/rx.time.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs/2.1.11/rx.binding.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/rxjs-dom/2.0.7/rx.dom.min.js"></script> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1,2,5,10,20,50,100].reverse() | |
.reduce(function(acc, n){ | |
return { | |
amount: acc.amount%n, | |
results: acc.results.concat({Coin:n, N: Math.floor(acc.amount/n)}) | |
} | |
}, {amount:99, results:[]}); |