Skip to content

Instantly share code, notes, and snippets.

@monostere0
monostere0 / GlobalEvents.js
Last active February 19, 2020 08:10
Fire events between different browser windows using localStorage.
(function(window){
var EVENT_EXISTS = 'GlobalEvents: Event already exists.';
var eventIsRunning,
_eventStack,
_findByName,
stackEvent,
removeEvent,
eventListener,
@LeCoupa
LeCoupa / nodejs-cheatsheet.js
Last active June 30, 2024 04:14
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@adrianseeley
adrianseeley / data.js
Created April 23, 2014 15:54
Lamb.JS Particle Swarm Classification
var xor = [
[[0, 0], [0]],
[[0, 1], [1]],
[[1, 0], [1]],
[[1, 1], [0]]
];
var iris = [
[[5.1, 3.5, 1.4, 0.2], [1]],
[[4.9, 3.0, 1.4, 0.2], [1]],
@neilk
neilk / nonBlockingForEach.js
Last active November 25, 2021 11:06
Works a little bit like `Array.prototype.forEach()`, but uses `process.nextTick` to allow other processes to execute. NOTE. This isn't meant to be practical; if you use this in production code you're probably doing it wrong.
/**
* Allow other processes to execute while iterating over
* an array. Useful for large arrays, or long-running processing
*
* @param {Function} fn iterator fed each element of the array.
* @param {Function} next executed when done
*/
Array.prototype.nonBlockingForEach = function(fn, next) {
var arr = this;
var i = 0;