Skip to content

Instantly share code, notes, and snippets.

View mrroot5's full-sized avatar
🏠
Working from home

Adrián mrroot5

🏠
Working from home
View GitHub Profile
@mrroot5
mrroot5 / url_to_array.js
Last active February 1, 2017 09:19
URL to array, convierte el query de una url a un array. Devuelve los parámetros de URL en un array. From http://stackoverflow.com/questions/4297765/make-a-javascript-array-from-url
function urlToArray(url = '') {
var request = {},
pairs,
i,
pair;
if (url === '') {
url = window.location;
}
@mrroot5
mrroot5 / array_to_url.js
Created May 22, 2015 11:53
Array to URL, convierte un array al query de una url . Devuelve los parámetros de URL en un string From http://stackoverflow.com/questions/4297765/make-a-javascript-array-from-url
function ArrayToURL(array) {
var pairs = [];
for (var key in array)
if (array.hasOwnProperty(key))
pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(array[key]));
return pairs.join('&');
}
// Return an array
function get_object_values(obj) {
'use strict';
return Object.keys(obj).map(function (k) {
return obj[k];
});
}
var object_values = get_object_values({key1: "value1", key2: "value2", key3: "value3"});
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
# Make sure that you're on your master branch:
window.console.time("answer time");
window.alert("Click to continue");
window.console.timeEnd("answer time");
@mrroot5
mrroot5 / mysql_match_against.sql
Last active November 17, 2015 09:18
MATCH AGAINST |FULLTEXT Index, buscar en mysql.
SELECT `campo1`,`campo2`, MATCH (`campo1`,`campo2`)
AGAINST ('"cadena a buscar*"' IN BOOLEAN MODE) AS Relevancia
FROM `tabla1`
WHERE MATCH (`campo1`,`campo2`)
AGAINST ('"cadena a buscar*"' IN BOOLEAN MODE)
HAVING Relevancia >= 0.5
ORDER BY Relevancia DESC
LIMIT 0 , 5
function htmlEncode(value){
//create a in-memory div, set it's inner text(which jQuery automatically encodes)
//then grab the encoded contents back out. The div never exists on the page.
return $('<div/>').text(value).html();
}
function htmlDecode(value){
return $('<div/>').html(value).text();
}
@mrroot5
mrroot5 / example
Last active August 29, 2015 14:22
Imprimimos código HTML visible desde la web, evitando que las entidades HTML actúen como tal.
http://jsfiddle.net/odxg8tfu/
@mrroot5
mrroot5 / example.txt
Last active November 13, 2015 16:56
Cambiar el punto de colapso (navbar breakpotin) de la barra de navegación de bootstrap
https://jsfiddle.net/erknrio/c4akywzk/
@mrroot5
mrroot5 / comandos_utiles.sh
Last active September 13, 2016 08:05
Comandos útiles bash
# Comandos vim
# https://gist.github.com/erknrio/0c7723562ec809f6e7310600470c5eea
# Comprobar tamaño completo de carpeta
du -h
# Comprobar el tamaño del disco
df -h
# Consultar la ayuda