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 getParameters(func) { | |
var funcString = func.toString(); | |
var indexStart = funcString.indexOf('(') + 1; | |
var indexEnd = funcString.indexOf(')'); | |
return funcString | |
.substring(indexStart, indexEnd) | |
.trim() | |
.split(/\s*,\s*/); | |
} |
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(w){ | |
var oldST = w.setTimeout; | |
var oldSI = w.setInterval; | |
var oldCI = w.clearInterval; | |
var timers = []; | |
w.timers = timers; | |
w.setTimeout = function(fn, delay){ | |
var id = oldST(function(){ | |
fn && fn(); | |
removeTimer(id); |
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
// deburglar.getDupes(); | |
var deburglar = (function () { | |
var dict = {}; | |
var maybeTheOriginalOpen = XMLHttpRequest.prototype.open; | |
XMLHttpRequest.prototype.open = function (method, url) { | |
if (!dict[url]) | |
dict[url] = 0; | |
dict[url]++; | |
return maybeTheOriginalOpen.apply(this, arguments); | |
}; |
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
waterfall(['a', 'bbbb', 'cc'], function(item){ | |
return function(resolve){ | |
setTimeout(function(){ | |
console.log(item); | |
resolve(); | |
}, item.length * 1000); | |
}; | |
}); |
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 getHashCode(obj) { | |
var hashCode = 0; | |
if (typeof obj === 'object') | |
for (var prop in obj) { | |
var code = getHashCode(prop) + getHashCode(obj[prop]); | |
hashCode += code * code; | |
} | |
else | |
for(var str = "" + obj, i = str.length; i--;) | |
hashCode += 100 / (i + str.charCodeAt(i)); |
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 que = (function (q) { | |
/** | |
* Pause & queue a set of dynamically added async requests until the `resume` promise is resolved. | |
* | |
* @method que | |
* @param {Function} pause A function that returns a boolean which results the que instance to pause. Will be executed with every add() or resolved promise. | |
* @param {Function} resume A function that returns a promise which tells the que instance to resume when it resolves. It does nothing when the promise is rejected. | |
* @return {Object} que instance | |
*/ | |
function que(pause, resume) { |
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 createObservedArray | |
* @params function observer A callback function returning the name of the used Array function. | |
* @returns Array The observed array | |
* @note This is just a simple way to observe an array, do not use in production ;) | |
*/ | |
function createObservedArray(observer) { | |
var array = [], | |
methods = ['pop', 'push', 'shift', 'unshift', 'slice', 'splice', 'reduce']; | |
for (var i = methods.length; i--;) { |
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 htmlDecode(s) { | |
var el = document.createElement("div"); | |
el.innerHTML = s; | |
return el.textContent; | |
} | |
function htmlEncode(s) { | |
var el = document.createElement("div"); | |
el.textContent = s; | |
return el.innerHTML; |
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
/* | |
Copyright (C) 2021 Pascal de Vink (Tweakers.net) | |
This library is free software; you can redistribute it and/or | |
modify it under the terms of the GNU Lesser General Public | |
License as published by the Free Software Foundation; either | |
version 2.1 of the License, or (at your option) any later version. | |
This library is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
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
#me { | |
-webkit-animation: rotation 2s infinite linear; | |
-moz-animation: rotation 2s infinite linear; | |
-o-animation: rotation 2s infinite linear; | |
animation: rotation 2s infinite linear; | |
} | |
@-webkit-keyframes rotation { | |
from {-webkit-transform: rotatex(0deg);} | |
to {-webkit-transform: rotatex(359deg);} |