Skip to content

Instantly share code, notes, and snippets.

View jherax's full-sized avatar
👾
Performance focused

David Rivera jherax

👾
Performance focused
View GitHub Profile
@jherax
jherax / falsy-values.txt
Last active April 13, 2016 18:06
JavaScript coercion
VALOR COERCIÓN
------- ---------
false false
0 false
“” false
NaN false
null false
undefined false
@jherax
jherax / $.center.js
Last active October 17, 2016 05:07
jQuery: center an element relative to another
(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:
@jherax
jherax / subl
Created March 14, 2018 15:33 — forked from cmalard/subl
Cygwin + Sublime Text 3 : works with files and Git
#!/bin/bash
# To create in [.babun/]cygwin/usr/local/bin/subl with chmod +x
ARGS=""
while test $# -gt 0
do
ARGS="$ARGS ${1#/cygdrive/[a-zA-Z]}"; # Remove /cygdrive and disk letter from the path
shift
done
@jherax
jherax / js-1-inheritance.js
Last active September 24, 2018 18:09
JavaScript OOP: Herencia y Prototipos
//definimos el constructor del objeto base y
//establecemos las propiedades por instancia
function Person (name, age) {
"use strict";
this.name = name || "unnamed";
this.age = +age || 0;
}
//definimos el prototipo del objeto base
//estableciendo las propiedades compartidas
@jherax
jherax / sortBy-old.js
Last active November 8, 2018 04:01
Sorting Arrays
/*
* Important!
* This snippet is deprecated, a best implementation of sortBy can be found here:
* https://github.com/jherax/array-sort-by
*/
var sortBy = (function () {
var toString = Object.prototype.toString,
// default parser function
parse = function (x) { return x; },
@jherax
jherax / index.html
Created January 8, 2019 23:16
Disable auto-zoom in input elements - For Safari, iPhone
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no" />
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
@jherax
jherax / isPalindrome.js
Last active January 5, 2020 13:29
Determines whether a string is a palindrome
/**
* 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, '');
@jherax
jherax / docker-clean.sh
Last active May 30, 2020 15:36
Load docker and put it in the shell
# in your .zshrc
function docker_clean() {
containers=$(docker ps -a -q -f status=exited)
# echo $containers
if [ "" != "$containers" ] ; then
docker rm -v $containers
fi
}
@jherax
jherax / alterDate.js
Last active May 30, 2020 15:37
Adds or subtracts date portions to the given date.
/**
* 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