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
const isObject = (it) => it != null && typeof it === 'object'; | |
/** | |
* Encodes an object to be used as query-string. | |
* It uses 'encodeURIComponent' to set each value. | |
* | |
* @param {object} data an object with key-value pairs to create the query-string | |
* @returns {string} the query-string | |
*/ | |
function toUrlParams(data) { |
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
/** | |
* @summary | |
* High-order function that memoizes a function, by creating a scope | |
* to store the result of each function call, returning the cached | |
* result when the same inputs is given. | |
* | |
* @description | |
* Memoization is an optimization technique used primarily to speed up | |
* functions by storing the results of expensive function calls, and returning | |
* the cached result when the same inputs occur again. |
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
# in your .zshrc | |
function docker_clean() { | |
containers=$(docker ps -a -q -f status=exited) | |
# echo $containers | |
if [ "" != "$containers" ] ; then | |
docker rm -v $containers | |
fi | |
} |
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
pact install python-setuptools python-ming | |
pact install libxml2-devel libxslt-devel libyaml-devel | |
curl -skS https://bootstrap.pypa.io/get-pip.py | python | |
Optional/Not sure what these are for: | |
pip install virtualenv | |
curl -skS https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python |
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
/** | |
* Lightweight script to detect whether the browser is running in Private mode. | |
* @returns {Promise<boolean>} | |
* | |
* Live demo: | |
* @see https://output.jsbin.com/tazuwif | |
* | |
* This snippet uses Promises. If you want to run it in old browsers, polyfill it: | |
* @see https://cdn.jsdelivr.net/npm/es6-promise@4/dist/es6-promise.auto.min.js | |
* |
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
/** | |
* Adds or subtracts date portions to the given date and returns the new date. | |
* | |
* @param {Object} options: It contains the date parts to add or remove, and can have the following properties: | |
* - {Date} date: if provided, this date will be affected, otherwise the current date will be used. | |
* - {number} minutes: minutes to add/subtract | |
* - {Number} hours: hours to add/subtract | |
* - {Number} days: days to add/subtract | |
* - {Number} months: months to add/subtract | |
* - {Number} years: years to add/subtract |
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 glob = require('glob'); | |
module.exports = { | |
entry: toObject(glob.sync('assets/**/*.js*')), | |
output: { | |
filename: '[name].js' | |
}, | |
//... | |
}; |
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
/** | |
* Determines whether a text is a palindrome. | |
* Text is lowercased and non-alphabetic characters are removed. | |
* | |
* @param {string} text - the words to check | |
* @return {boolean} | |
*/ | |
function isPalindrome(text) { | |
if (!text || text.length < 2) return false; | |
text = text.replace(/[\s\W]/g, ''); |
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
// This is a reference to JSON.stringify and provides a polyfill for old browsers. | |
// stringify serializes an object, array or primitive value and return it as JSON. | |
var stringify = (function() { | |
var _PRIMITIVE, _OPEN, _CLOSE; | |
if (window.JSON && typeof JSON.stringify === "function") | |
return JSON.stringify; | |
_PRIMITIVE = /string|number|boolean|null/; | |
_OPEN = { |
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
/** | |
* Filters an array of objects using custom predicates. | |
* | |
* @param {Array} array: the array to filter | |
* @param {Object} filters: an object with the filter criteria | |
* @return {Array} | |
*/ | |
function filterArray(array, filters) { | |
const filterKeys = Object.keys(filters); | |
return array.filter(item => { |