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
// @private | |
var isObject = (value) => | |
value != null && typeof value === 'object'; | |
/** | |
* @private | |
* Restores the one-level-depth object to the original nested object. | |
* | |
* @param {Array} names: list of keys in the object | |
* @param {any} value: the value of the object to transform |
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 removeEmpty = (() => { | |
/** | |
* Determines if the entry parameter is not an object or array. | |
* | |
* @private | |
* @param {Any} v: the value to test | |
* @return {Boolean} | |
*/ | |
const isNotObject = v => v === null || typeof v !== 'object'; |
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
# Ask for the user password | |
# Script only works if sudo caches the password for a few minutes | |
sudo true | |
# Install kernel extra's to enable docker aufs support | |
# sudo apt-get -y install linux-image-extra-$(uname -r) | |
# Add Docker PPA and install latest version | |
# sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 | |
# sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" |
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 ($) { | |
// Reverses the array of matched elements | |
$.fn.reverse = Array.prototype.reverse; | |
/** | |
* Centers an element relative to another. | |
* @signature: $(selector).center(options) | |
* @param {Object} options: | |
* Defines the options with the following properties: |
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
/** | |
* Gets all event-handlers from a DOM element. | |
* Events with namespace are allowed. | |
* | |
* @param {Element} node: DOM element | |
* @param {String} eventns: (optional) name of the event/namespace | |
* @return {Object} | |
*/ | |
function getEventHandlers(element, eventns) { | |
const $ = window.jQuery; |
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
/** | |
* @author | |
* David Rivera (jherax) | |
* https://github.com/jherax | |
*/ | |
/* eslint-disable no-bitwise */ | |
/** @private */ | |
const toString = Object.prototype.toString; |
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
/* eslint-disable no-underscore-dangle */ | |
/** | |
* Supported types | |
*/ | |
const TYPES = { | |
_true: /^true$/i, | |
_false: /^false$/i, | |
_null: /^null$/i, | |
_number: /^[0-9]+$/, |
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
// Creates user-defined exceptions | |
var CustomError = (function() { | |
'use strict'; | |
//constructor | |
function CustomError() { | |
//enforces 'new' instance | |
if (!(this instanceof CustomError)) { | |
return new CustomError(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
//utility to create safe namespaces | |
function createNS (namespace) { | |
var nsparts = namespace.toString().split("."), | |
reName = (/^[A-Za-z_]\w+/), | |
cparent = window, | |
i, subns, nspartsLength; | |
// we want to be able to include or exclude the root namespace so we strip it if it's in the namespace | |
if (nsparts[0] === "window") nsparts = nsparts.slice(1); | |
// loop through the parts and create a nested namespace if necessary | |
for (i = 0, nspartsLength = nsparts.length; i < nspartsLength; i += 1) { |
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() { | |
//verificamos cual es el ámbito global | |
//(generalmente el objeto window) | |
console.log("Global scope", this); | |
var x = 42; //variable local | |
var point = { x: 10, y: 15 }; //objeto local | |
//si no se especifica el keyword "var", |