This file contains hidden or 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 step = require("step"); | |
| var weasel1 = function(callback) { | |
| callback(null, 'first'); | |
| } | |
| var weasel2 = function(callback) { | |
| callback(null, 'second'); | |
| } |
This file contains hidden or 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 expected = new long[] {0, 1, 2, 3, 4}; | |
| var actual = new List<long>(); | |
| var scheduler = new TestScheduler(); | |
| var interval = Observable.Interval(TimeSpan.FromSeconds(1), scheduler).Take(5); | |
| interval.Subscribe(actual.Add); | |
| scheduler.Start(); | |
| CollectionAssert.AreEqual(expected, actual); |
This file contains hidden or 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
| public class SharedResource : IDisposable | |
| { | |
| public int SequenceNumber { get; private set; } | |
| public SharedResource() | |
| { | |
| Debug.WriteLine("SharedResource created."); | |
| } | |
| public void Increment() |
This file contains hidden or 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
| public class LRUObservableCollection<T> : ObservableCollection<T> | |
| { | |
| private readonly int _length; | |
| public LRUObservableCollection(int length) | |
| { | |
| _length = length; | |
| } | |
| protected override void InsertItem(int index, T item) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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(); |