[ Launch: Tributary inlet ] cc55b74fb37b73288f1a by rajeshpillai[ Launch: Tributary inlet ] 473f598a4bdc39ef7243 by rajeshpillai[ Launch: Tributary inlet ] 090d3b001b2281451f3e by rajeshpillai[ Launch: Tributary inlet ] 5dd2ddc926c0ec7e91b0 by rajeshpillai[ Launch: Tributary inlet ] 5e576bc50efd71a67236 by rajeshpillai
[ Launch: Tributary inlet ] 6882e74ed3e7211d0ca5 by rajeshpillai[ Launch: Tributary inlet ] cc55b74fb37b73288f1a by rajeshpillai[ Launch: Tributary inlet ] 473f598a4bdc39ef7243 by rajeshpillai[ Launch: Tributary inlet ] 090d3b001b2281451f3e by rajeshpillai[ Launch: Tributary inlet ] 5dd2ddc926c0ec7e91b0 by rajeshpillai[ Launch: Tributary inlet ] 5e576bc50efd71a67236 by rajeshpillai
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
| require "net/http" | |
| def start_server | |
| # Remove the X to enable the parameters for tuning. | |
| # These are the default values as of Ruby 2.2.0. | |
| @child = spawn(<<-EOC.split.join(" ")) | |
| XRUBY_GC_HEAP_FREE_SLOTS=4096 | |
| XRUBY_GC_HEAP_INIT_SLOTS=10000 | |
| XRUBY_GC_HEAP_GROWTH_FACTOR=1.8 | |
| XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta name="description" content="A better browser console log"> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <style id="jsbin-css"> | |
| .console-container { | |
| position: absolute; |
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> | |
| <meta name="description" content="A better browser console log"> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <style id="jsbin-css"> | |
| .console-container { | |
| position: absolute; |
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> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JavaScript Ninja: Promise Explained</title> | |
| </head> | |
| <body> | |
| <input type="button" id="btn" value="Click me!"/> | |
| </body> |
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 doLongRunningTask() { | |
| var promise = new MyPromise(); | |
| setTimeout(function () { | |
| promise.resolve("I am done."); | |
| }, 3000); | |
| return promise; | |
| } |
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 response = doLongRunningTask(); | |
| // We can subscribe as many times as required using the "then" method. | |
| response.then(function (result) { | |
| console.log("RECD: 1", result); | |
| }) | |
| .then(function (result) { | |
| console.log("RECD: 2", result); | |
| }) | |
| .catch(function (e) { |
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 btn = document.getElementById("btn"); | |
| btn.addEventListener("click", function (e) { | |
| response.then(function (msg) { | |
| console.log("RECD: FROM promise: ", msg); | |
| }); | |
| }); |
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
| // The constructor function | |
| var MyPromise = function () { | |
| this.callbacks = []; // All callbacks then() will be stored here | |
| this.resolved = false; // initially the resolved will be set to false. This will be set to true, once the promise is resolved | |
| this.data = null; // The data returned from the promise | |
| this.errorCallback = null; // Error callback function | |
| this.error = false; // If any error, this variable will be set to true | |
| } |