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
Promise.series = promises => promises | |
.reduce( | |
(promise, current) => promise.then(current), | |
Promise.resolve() | |
) |
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(oldForEach) { | |
Array.prototype.forEach = function() { | |
oldForEach.apply(this, arguments); | |
return this; | |
}; | |
}(Array.prototype.forEach)); | |
[1, 2, 3] | |
.forEach(item => console.log(1, item)) | |
.forEach(item => console.log(2, item)) |
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 generateLolilolPassword = (chars, length) => Array | |
.apply(null, { length }) | |
.map(() => chars[ (Math.random() * chars.length) >> 0 ]) | |
.join('') | |
generateLolilolPassword('azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN1234567890', 10) // cw49XRZWF0 |
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 keys = []; | |
document.onkeyup = function(e) { | |
keys.unshift(e.keyCode); | |
keys = keys.slice(0, 10); | |
if (keys.join(';') === [65, 66, 39, 37, 39, 37, 40, 38, 40, 38].join(';')) { | |
alert('konami!'); | |
} | |
} |
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
define(function () { | |
return { | |
factor: 100, | |
pixi: function (value, y) { | |
return value * this.factor * (y ? -1: 1); | |
}, | |
p2: function (value) { |
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 slices = [ | |
{value: 100, color: "red"}, | |
{value: 33, color: "green"}, | |
{value: 41, color: "blue"}, | |
{value: 103, color: "yellow"}, | |
{value: 145, color: "orange"}, | |
]; | |
var origin = {x: 200, y: 200}, | |
radius = 100, |
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.prototype.bind = Function.prototype.bind || function (oThis) { | |
if (typeof this !== "function") { | |
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); | |
} | |
var aArgs = Array.prototype.slice.call(arguments, 1), | |
fToBind = this, | |
fNOP = function () {}, | |
fBound = function () { | |
return fToBind.apply( | |
this instanceof fNOP && oThis |
NewerOlder