❤️🔥
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
/** | |
* [ description] | |
* @param {string} tpl the template | |
* @param {literal|function} obj a literal for substitution or a function that will | |
* return the substitution given as parameter a string | |
* @param {string} start optional- the opening placeholder delimitator (%) | |
* @param {string} end optional- the closing placeholder delimitator (%) | |
* @param {string} fb optional- a fallback value in case an element is not found | |
* @return {string} the resulting string with replaced values | |
*/ |
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 (ns){ | |
// this is due, to test all implications see | |
// http://www.jmvc.org/test_strict | |
"use strict"; | |
var debugActive = false; | |
/** | |
* Creates a namespace | |
* @param {String} str dot or slash separated path for the namespace |
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 searchHash = (function () { | |
// some utility func | |
function jCompare(obj1, obj2) { | |
return !isNode(obj1) | |
&& typeof JSON !== 'undefined' ? | |
JSON.stringify(obj1) === JSON.stringify(obj2) | |
: | |
obj1 == obj2; | |
} |
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 (idsEls) { | |
var ids = idsEls.map(e => e.id).sort(), | |
uniq = [], | |
dups = {}; | |
ids.forEach(id => { | |
if (uniq.indexOf(id) === -1) { | |
uniq.push(id); | |
} else { | |
dups[id] = id in dups ? ++dups[id] : 2; | |
} |
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
console.log("javascript:void "+encodeURIComponent(`function _(){var code=prompt('Paste here Your code'),bm="javascript:void(function(){"+encodeURIComponent(code+'')+"}())";if(code){if(bm.length>2e3){alert('The resulting code looks quite long to be printed in a prompt, the output will be written in the console, please copy it from there');console.log(bm)}else{prompt("Here's the bookmarklet code",bm)}}else{alert('No code given')}}()`)) | |
// which gives | |
/** | |
javascript:void function%20_()%7Bvar%20code%3Dprompt('Paste%20here%20Your%20code')%2Cbm%3D%22javascript%3Avoid(function()%7B%22%2BencodeURIComponent(code%2B'')%2B%22%7D())%22%3Bif%20(code)%7Bif%20(bm.length%20%3E%202e3)%20%7Balert('The%20resulting%20code%20looks%20quite%20long%20to%20be%20printed%20in%20a%20prompt%2C%20the%20output%20will%20be%20written%20in%20the%20console%2C%20please%20copy%20it%20from%20there')%3Bconsole.log(bm)%7Delse%7Bprompt(%22Here's%20the%20bookmarklet%20code%22%2Cbm)%7D%7Delse%7Balert('No%20code%20given')%7D%7D() | |
**/ | |
// save a bookmar |
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 uniqueID = new function () { | |
var count = 0, | |
self = this; | |
this.prefix = 'NS_'; | |
this.toString = function () { | |
count += 1; | |
return self.prefix + count; | |
}; | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title></title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style> | |
html { | |
overflow-y: scroll; |
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
/** | |
// HOW TO USE IT | |
const test = require('./wherever/it/is/test') | |
function myFunc1 (a,b) { ... } | |
function myFunc2 (a,b) { ... } | |
const benchs = [{ | |
in: [[1,2,3.4], 'test'], | |
out: true | |
}, ...] | |
test( |
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
/** | |
* Implements in place binary search. O(log n) | |
* optional comparator can be passed | |
*/ | |
function findInsertIndex(a, item, smaller) { | |
var l = 0, | |
len = a.length, | |
r = len - 1, | |
m; | |
smaller = smaller || function(a, b, strict){ |
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 testone = require('@fedeghe/testone'), | |
benchs = [ | |
{ | |
in: ['"', ',', `a,,"a;.b,c",1.4.3.2,3,r,"c.,d r;t",s`], | |
out: [ | |
'a', '', '"a;.b,c"', '1.4.3.2', '3', 'r', '"c.,d r;t"', 's' | |
] | |
},{ | |
in: ["'", ';', `a;;'a,b;c';r;'c.,d r;t';s`], | |
out: [ 'a', '', "'a,b;c'", 'r', "'c.,d r;t'", 's' ] |
OlderNewer