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
const fetchMachine = Machine({ | |
id: 'game', | |
initial: 'initialize', | |
context: { | |
currentActor: undefined, | |
enemy: undefined, | |
player: undefined | |
}, | |
states: { | |
initialize: { |
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
function bubbleSort (arr) { | |
var left, | |
right, | |
swapped; | |
do { | |
swapped = false; | |
for (var i = 0; i < arr.length - 1; i++) { | |
left = arr[i]; | |
right = arr[i + 1]; |
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
// | |
// raw whitepaper for functional interface/subset of JS that eliminates logical operations | |
// similar to IFTTT. Based off of this image/site: https://ifttt.com/products | |
// | |
function doIf(cond, cb){ | |
if(cond instanceof Array){ | |
doIfEach(cond, cb); | |
} else if(cond === true && typeof cb === 'function'){ | |
cb(); |
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
{ | |
// http://eslint.org/docs/rules/ | |
"env": { | |
"browser": true, // browser global variables. | |
"node": false, // Node.js global variables and Node.js-specific rules. | |
"worker": false, // web workers global variables. | |
"amd": false, // defines require() and define() as global variables as per the amd spec. | |
"mocha": false, // adds all of the Mocha testing global variables. | |
"jasmine": false, // adds all of the Jasmine testing global variables for version 1.3 and 2.0. |
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
➜ 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
➜ 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
// Setup | |
function onGet(){ /* .. */ } | |
function onDelete(){ /* .. */ } | |
function onPost(){ /* .. */ } | |
var onPut = onPost; // Sharing functionality. | |
// Bad | |
function processRequest(method){ | |
var requestMethod = method.toLowerCase(); |
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
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. |
NewerOlder