This file contains hidden or 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 tapStream = Rx.Observable.fromEvent(element, 'click'); | |
// multi-tap logic | |
var multiTapStream = tapStream | |
.buffer(function() { return tapStream.debounce(250); }) | |
.map(function(list) { return list.length; }) | |
.filter(function(x) { return x >= 2; }); | |
// Same as above, but detects single taps | |
var singleTapStream = tapStream |
This file contains hidden or 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 insertBetweenElements(arr, value) { | |
// Get first element in array | |
var first = arr.shift(); | |
// if array is empty return array | |
if (!first) return arr; | |
// insert the value | |
return arr.reduce(function(valeurPrecedente, valeurCourante, index, array){ | |
return valeurPrecedente.concat(value,valeurCourante); | |
},(Array.isArray(first) ? first : [first])); | |
}; |
This file contains hidden or 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
.sr_only { | |
position: absolute !important; | |
height: 1px; | |
width: 1px; | |
overflow: hidden; | |
clip: rect(1px 1px 1px 1px); /* IE6, IE7 */ | |
clip: rect(1px, 1px, 1px, 1px); | |
} |
This file contains hidden or 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
// Utils | |
function isFnCall(key){ | |
if (typeof key !== 'string') return false; | |
return key.slice(-2) === "()"; | |
} | |
/* | |
* @param {key} string concatenation of nested keys in this form: 'foo.bar.toto'. | |
* You can even call a function if the last key ends with '()'. | |
* @param {obj} the object we are accessing | |
* @return a nested value OR the result of a nested function OR undefined |
This file contains hidden or 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
<script src="mymodule.js"></script> | |
<script> | |
alert(mymodule.test()); | |
</script> |
This file contains hidden or 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
“scripts”: { | |
“update:packages”: “node wipe-dependencies.js && | |
rm -rf node_modules && npm update --save-dev | |
&& npm update --save” | |
}, |
This file contains hidden or 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 myExport(exported, isDefault, name) { | |
if (!name) throw "myExport function: <name> mustn't be undefined"; | |
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { | |
if (isDefault) { | |
module.exports = exported; | |
} else { | |
module.exports[name] = exported; | |
} | |
} | |
else { |
This file contains hidden or 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
/* | |
* Insert insertedEl or the result of insertedEl (if it is a function) between the elements of arr. | |
* Attention: nothing is inserted before the first element or after the last element of arr. | |
* If the predicate function is defined, the function will instert the value only if the predicate is verified (returns a truthy value). | |
* | |
* insertedEl and predicate function are both called with these arguments: prev, curr, tIdx and tArr. | |
* predicate has one more argument as last which is called value. | |
* where prev = the accumulator array wich contains the current partial value of the final array or [] | |
* curr = the current element that will be pushed in the prev array | |
* tIdx = index of curr in the original array |
This file contains hidden or 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> | |
<meta charset="utf-8"> | |
<title>title</title> | |
<link rel="stylesheet" href="style.css"> | |
<script src="script.js"></script> | |
</head> | |
<body> | |
<!-- page content --> |
This file contains hidden or 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
/* | |
* @param property string, number or function. This is the crieteria of the grouping function | |
*/ | |
function groupBy(arr, property) { | |
return arr.reduce( (memo, el, i) => { | |
let grpProperty = (() => { | |
if (typeof property === 'string' || typeof property === 'number') { | |
return el[property]; | |
} else if (typeof property === 'function') { | |
return property(el, i, arr); |
OlderNewer