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
| /** | |
| * At least two points are needed to interpolate something. | |
| * @class Lagrange polynomial interpolation. | |
| * The computed interpolation polynomial will be reffered to as L(x). | |
| * @example | |
| * var l = new Lagrange(0, 0, 1, 1); | |
| * var index = l.addPoint(0.5, 0.8); | |
| * console.log(l.valueOf(0.1)); | |
| * | |
| * l.changePoint(index, 0.5, 0.1); |
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 Promise = require('bluebird'); | |
| var promiseWhile = function(condition, action) { | |
| var resolver = Promise.defer(); | |
| var loop = function() { | |
| if (!condition()) return resolver.resolve(); | |
| return Promise.cast(action()) | |
| .then(loop) | |
| .catch(resolver.reject); |
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 getFnName(fn) { | |
| fn = Object(fn) | |
| var F = typeof fn == 'function' | |
| var N = fn.name | |
| var S = F && ((N && ['', N]) || fn.toString().match(/function ([^\(]+)/)) | |
| return (!F && 'not a function') || (S && S[1] || 'anonymous'); | |
| } | |
| console.log(getFnName(String)); // 'String' | |
| console.log(getFnName(function test(){})); // 'test' |
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 (window) {"use strict"; | |
| // by WebReflection - WTFPL License | |
| var | |
| prefixes = "r webkitR mozR msR oR".split(" "), | |
| process = "process", | |
| nextTick = "nextTick", | |
| i = 0, | |
| p = window[process] || (window[process] = {}) | |
| ; | |
| while (!p[nextTick] && i < prefixes.length) |
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 http = require('http'); | |
| var path = require('path'); | |
| var fs = require('fs'); | |
| var AUDIOFILE = "./audio.ogg"; | |
| function serveWithRanges(request, response, content) { | |
| var range = request.headers.range; | |
| var total = content.length; | |
| var parts = range.replace(/bytes=/, "").split("-"); |
NewerOlder