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
/** | |
* Changes the format of a string-date. | |
* | |
* @param {Object | String} options: it can be a String with the date, or an Object with the following properties: | |
* - {String} date: the entry date to change the format | |
* - {String} inputFormat: the format of the entry date | |
* - {String} outputFormat: the format of the output date | |
* @return {String} | |
*/ | |
const formatDate = (() => { |
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
type FilterOperator = 'AND' | 'OR'; | |
type FiltersBy<T> = { | |
[K in keyof T]?: (value: T[K]) => boolean; | |
}; | |
/** | |
* Factory function that creates a specialized function to filter | |
* arrays, by validating all filters (AND operator), | |
* or validating just one of the filters (OR operator). | |
* @param operator Method to validate all filters: AND, OR |
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
/** | |
* 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) return false; | |
text = text.replace(/[\W_]+/g, '').toLowerCase(); |
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
/** | |
* 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
/** | |
* 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
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
# 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
/** | |
* 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. | |
* |