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
| fractalModule =function(stdlib){ | |
| "use asm"; | |
| var pow = stdlib.Math.pow; | |
| var abs = stdlib.Math.abs; | |
| var atan2 = stdlib.Math.atan2; | |
| var cos = stdlib.Math.cos; | |
| var sin = stdlib.Math.sin; | |
| function mandlebrot(cx, cy, maxIter) { | |
| cx = +cx; | |
| cy = +cy; |
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 delay(expressionAsFunction) { | |
| var result; | |
| var isEvaluated = false; | |
| return function () { | |
| if (!isEvaluated) | |
| result = expressionAsFunction(); | |
| return result; | |
| }; | |
| } |
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
| db = db.getSisterDB("config"); | |
| var mongosConn = db; // assume we connected to a mongos to get going | |
| var res = null; | |
| function check() { | |
| printjson(res); | |
| if( !res || !res.ok ) { | |
| throw "check(): not ok, stopping"; |
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
| /** | |
| Workaround for iOS 6 setTimeout bug using requestAnimationFrame to simulate timers during Touch/Gesture-based events | |
| Author: Jack Pattishall (jpattishall@gmail.com) | |
| This code is free to use anywhere (MIT, etc.) | |
| Note: UIWebView does not support requestAnimationFrames. If your timer is failing during a scroll event, | |
| take a look at https://gist.github.com/ronkorving/3755461 for a potential workaround. | |
| Usage: Pass TRUE as the final argument for setTimeout or setInterval. |
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) { | |
| // This library re-implements setTimeout, setInterval, clearTimeout, clearInterval for iOS6. | |
| // iOS6 suffers from a bug that kills timers that are created while a page is scrolling. | |
| // This library fixes that problem by recreating timers after scrolling finishes (with interval correction). | |
| // This code is free to use by anyone (MIT, blabla). | |
| // Original Author: rkorving@wizcorp.jp | |
| var timeouts = {}; | |
| var intervals = {}; | |
| var orgSetTimeout = window.setTimeout; | |
| var orgSetInterval = window.setInterval; |
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
| % ab -n 10 -c 10 -p json.file -T "application/json; charset=utf-8" http://localhost/ |
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
| Stability ratings: 0-5 | |
| 0 - Deprecated. This feature is known to be problematic, and changes are | |
| planned. Do not rely on it. Use of the feature may cause warnings. Backwards | |
| compatibility should not be expected. | |
| 1 - Experimental. This feature was introduced recently, and may change | |
| or be removed in future versions. Please try it out and provide feedback. | |
| If it addresses a use-case that is important to you, tell the node core team. |
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
| // common.js ====================================== | |
| (function(exports) { | |
| // Define all your functions on the exports object | |
| exports.foo = function() { | |
| return 'bar'; | |
| }; | |
| })((typeof process === 'undefined' || !process.versions) |
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, reuse but don't abuse! | |
| Author: Razvan Caliman (razvan.caliman@gmail.com) | |
| This is an example of a "Multiton" pattern; | |
| Create a fixed number of instances of a class. | |
| Use "lazy instantiation" to create objects only if needed. | |
| If the maximum number of instances has been reached, return a random one from the ones created. | |
| */ |
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
| // Load the TCP Library | |
| net = require('net'); | |
| // Keep track of the chat clients | |
| var clients = []; | |
| // Start a TCP Server | |
| net.createServer(function (socket) { | |
| // Identify this client |