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
| const | |
| [div, span, button] = ["div", "span", "button"].map((name)=>React.createFactory(name)), | |
| myCounterComponent = function({ count, callback }){ | |
| return div({}, [], | |
| button({ onClick: ()=>callback('decrease') }, ["-"]), | |
| span({}, [count]), | |
| button({ onClick: ()=>callback('increase') }, ["+"]) | |
| ); | |
| }, | |
| myCounterCombo = function({ state: { counter_1, counter_2 }, callback }){ |
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
| const run = function(gen, ...args){ | |
| let iterator = gen.apply(undefined, args); | |
| return new Promise((resolve)=>{ | |
| const rep = function(previousValue){ | |
| let { done, value } = iterator[previousValue instanceof Error ? "throw" : "next"](previousValue); | |
| !done ? ((value instanceof Promise ? value.then((v)=>rep(v)).catch((v)=>rep(new Error(v))) : rep(value))) : resolve(value); | |
| } | |
| rep(); | |
| }) | |
| }; |
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
| define([ | |
| "jquery", | |
| "lodash", | |
| "three" | |
| ], function( | |
| $, | |
| _, | |
| Three | |
| ){ | |
| var requestAnimationFrame = (window.requestAnimationFrame || _.noop).bind(window), |
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
| const | |
| _ = require('lodash'), | |
| spawn = require('child_process').spawn, | |
| bacon = require('baconjs'); | |
| const bufferUp = function(stream){ | |
| return bacon | |
| .fromEvent(stream, 'data') | |
| .takeUntil(bacon.fromEvent(stream, 'close').take(1)) | |
| .fold([], '.concat') |
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
| function createLogger(writer = console.log.bind(console), bufferThreshold = 100, delay = 5000){ | |
| let buf = [], timer; | |
| const dispose = ()=>{ writer(buf.splice(0)); }; | |
| return function(obj){ | |
| buf.push(obj); | |
| clearTimeout(timer); | |
| (buf.length >= bufferThreshold ? dispose() : timer = setTimeout(dispose, delay)); | |
| } | |
| } |
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
| const QUEUE_TIMEOUT = 500, | |
| QUEUE_DEBOUNCE = 5; | |
| Bacon | |
| .repeatedly(10, ["*", "-"]) | |
| .flatMapLatest((function(buffer, stamp) { | |
| return function(request) { | |
| buffer.length === 0 && (stamp = Date.now()); | |
| buffer.push(request); | |
| return (stamp + QUEUE_TIMEOUT < Date.now()) ? Bacon.once(buffer.splice(0)) : Bacon.fromBinder(function(sink) { |
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
| let allConcurrent = function(limit, generators){ | |
| return new Promise(function(resolveAll){ | |
| let plan = generators.map((generator)=>({ value: undefined, executed: false, settled: false, generator: generator })); | |
| let executeBatch = () => { | |
| plan | |
| .filter(({ settled, executed })=> !executed || (executed && !settled)) | |
| .slice(0, limit) | |
| .filter(({ executed }) => !executed) | |
| .map(planItem => { | |
| planItem.executed = true; |
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
| _.jsonp('https://api.ipify.org/?format=jsonp', function(err, value){ | |
| console.log(err || 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
| define(["jquery", "lodash", "bacon"], function($, _, Bacon){ | |
| return function(url, cb) { | |
| var parseTimeCode = function (timeCodeStr) { | |
| return _(timeCodeStr.split(/[:,]/)) | |
| .map(Number) | |
| .zipWith([60 * 60 * 1000, 60 * 1000, 1000, 1], function(a, b){ return a * b; }) | |
| .reduce(_.add, 0); | |
| }; |
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
| 2e525e375740023525561b716918026c73560f312f194472695f5b631a6f0d7260540173754c436c | |
| 6d140e723611532a75175f3340131a3d3554423c201c57724056003b301c4421751d4a72505c137f | |
| 331142213004133f41401033271101323b141336565c1372220d01697c4c1c221a6f0d7260540173 | |
| 754c436c6d5d4331210744732c1f4672535c0d3625060d7321185a21045e06213315463675194072 | |
| 415d002039045536315046214d5d04722f1a44733a1613264c56433f2f07557325025a3f4d470a24 | |
| 2554443d36024a22505a0c3c600044303d1e5a23515610722215523631505c3c044116362919443d | |
| 2111412b046f412a2f06483d322c11724554023b2e0755733450413d5052173b2e13013830091d72 | |
| 6d13083c2f0301243d1147725d5c1675321101273d195d394d5d047e6016542775005f3745400672 | |
| 241b4f74215047205d1302223018583a3b17133b5013173d601c48373050523c5d470b3b2e130130 | |
| 2705503b455f4334321b4c732118567254411a3b2e1301362c1540724b55431c1335013c27504a3d |
NewerOlder