This file contains 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
<div id="consolelog" style="font-family: 'Courier New', Courier, monospace; font-size: 12px; margin: 40px 30px 0px; background-color: white; border: 2px solid black; padding: 10px;"></div> | |
<input type="text" id="consoleinput" style="margin: 0px 30px; width: 400px;" onkeypress="return evalConsoleInput(event, this.value);" /> | |
<script type="text/javascript"> | |
var appendConsole = function(message, type) { | |
var color = "black"; | |
if (type === "error") { | |
color = "red"; | |
} else if (type === "debug") { |
This file contains 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
String.prototype.indexOfAll = function(s){ | |
// Make sure it's 1 char, use first char of string. | |
s = s[0]; | |
var results = [], | |
result = null, | |
i = 0, | |
offset = 0, // Incremented by previous index |
This file contains 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
/* | |
Usage | |
// You have an array | |
var myArr = ["a", 'b', "c"]; | |
// You want to enumerate through it w/ specified index. If you enumerate | |
// through an array by default index cannot be "guaranteed" as per MSDN: | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in | |
// for..in should not be used to iterate over an Array where index order is important. Array indexes are just enumerable properties with integer names and are otherwise identical to general Object properties. There is no guarantee that for...in will return the indexes in any particular order and it will return all enumerable properties, including those with non–integer names and those that are inherited. |
This file contains 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
// An Example of Why Promises and Generators are Important | |
// Based on this awesome video: https://www.youtube.com/watch?v=hf1T_AONQJU | |
// You can just copy and paste this code into your console to see it in action | |
var App = function App(){ | |
// Named anonymous functions for clear picture | |
// of the call stack in the error stack trace | |
this.asyncError = function myAsynchronousError(){ | |
throw new Error('Asynchronous error'); |
This file contains 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
document.addEventListener("DOMContentLoaded", function(event) { | |
/* | |
Later you can easily change this to any other PubSub library you like. | |
var _pubSub = PubSub; | |
or you can even wrap it to define your own API. This way, later on | |
you can still continue to use _ps.sub and _ps.pub even if you change | |
out the library defining that behaviour. Let's go with the latter. |
This file contains 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
// Note: this function is evil, and probably should never be used. | |
// It may be useful for when you are working in the console/debugger | |
// and need to analyze some large object. Not for production. | |
// http://jsperf.com/check-if-deep-property-exists-with-willnotthrow | |
function propDeepExists(target, propPath){ | |
try { | |
var result = eval("target." + propPath); | |
} catch(e){ | |
return false; | |
} |
This file contains 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
➜ Desktop node test2.js | |
================================== | |
Empty Node Module Memory Usage | |
================================== | |
RSS: 11.828 MB and Heap: 2.116 MB of 3.894 MB total | |
RSS: 11.867 MB and Heap: 2.141 MB of 3.894 MB total | |
RSS: 11.875 MB and Heap: 2.147 MB of 3.894 MB total | |
RSS: 11.879 MB and Heap: 2.151 MB of 3.894 MB total | |
RSS: 11.883 MB and Heap: 2.155 MB of 3.894 MB total | |
RSS: 11.887 MB and Heap: 2.158 MB of 3.894 MB total |
This file contains 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
➜ Desktop node test2.js | |
================================== | |
Empty Node Module Memory Usage | |
================================== | |
RSS: 16.273 MB and Heap: 3.466 MB of 6.191 MB total | |
RSS: 16.316 MB and Heap: 3.505 MB of 6.191 MB total | |
RSS: 16.316 MB and Heap: 3.512 MB of 6.191 MB total | |
RSS: 16.316 MB and Heap: 3.516 MB of 6.191 MB total | |
RSS: 16.316 MB and Heap: 3.520 MB of 6.191 MB total | |
RSS: 16.316 MB and Heap: 3.524 MB of 6.191 MB total |
This file contains 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
#!/bin/sh | |
# RESOURCES: | |
# Blog - http://www.gnuplotting.org/ | |
# Blog - http://gnuplot-surprising.blogspot.com/ | |
# Colors, Line Types - http://kunak.phsx.ku.edu/~sergei/Gnuplot/line_point_types.html | |
# Linespoints - http://www.gnuplotting.org/tag/linespoints/ | |
# Gnuplot and ab - http://www.bradlanders.com/2013/04/15/apache-bench-and-gnuplot-youre-probably-doing-it-wrong/ | |
gnuplot << EOF | |
reset |
This file contains 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 Property = function(vari){ | |
console.log("Creating a public accessor..."); | |
this.vari = vari; | |
return function(){ | |
if(arguments.length > 0){ | |
console.log("Setting the variable to " + arguments[0] + "..."); | |
vari = arguments[0]; | |
return; | |
} | |
console.log("Getting the variable..."); |
OlderNewer