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
http://jsfiddle.net/odxg8tfu/ |
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 generateUUID() { | |
var d = new Date().getTime(); | |
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
var r = (d + Math.random()*16)%16 | 0; | |
d = Math.floor(d/16); | |
return (c=='x' ? r : (r&0x3|0x8)).toString(16); | |
}); | |
return uuid; | |
} |
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
<form id="my_form"> | |
<input type="file" id="img-input-file"> | |
<img id="#img-input-file-preview" src="#" alt="imagen" /> | |
</form> |
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
String.prototype.humanize = function (str) { | |
return str.replace(/\w\S*/g, function (txt) {return txt.charAt(0).toUpperCase() + txt.substr(1).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
<?php | |
function vimeoID($url) { | |
if (preg_match("/https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/", $url, $id)) { | |
return "<strong>".$id[3]."</strong>"; | |
} else { | |
return "<strong class='error'>error</strong>"; | |
} | |
} | |
$vimeo = array( |
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
$url_list = array("http://www.miwebchula.com,", | |
"http://blabla.miwebchula.com", | |
"http://blabla.miweb-chula.com", | |
"http://www.miwebchula.com/param1/param2", | |
"http://www.miwebchula.com/param1/param2/", | |
"http://www.miwebchula.com/?var1=value1", | |
"http://www.miwebchula.com/?var1=value1", | |
"http://www.miwebchula.com/param1/param2?var1=value1", | |
"http://www.miwebchula.com/param1/param2?var1=val1&var2=val2", | |
"http://www.miwebchula.com.es", |
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
// Random entre 1 y 10 | |
var randomString = ((Math.random() * 10) +1).toString(32); |
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 foo = 'foo', | |
bar = 'bar', | |
string = `Mi string \ | |
contiene multiples lineas '${foo}' \ | |
cada una de ellas: "${bar}" es importante`; | |
window.console.log(string); |
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 is_assoc($array = array()) | |
{ | |
if (!is_array($array) || empty($array)) { | |
return FALSE; | |
} else { | |
return (bool)count(array_filter(array_keys($array), 'is_string')); | |
} | |
} |
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
// pos: Inserta despues de esta posicion | |
// preserve: boolean, indica si quieres conservar las claves del array | |
function insertNewElement($array, $element, $pos, $preserve) { | |
try { | |
if (empty($array) || empty($element)) { | |
throw new Exception('Faltan Datos', 1); | |
} else { | |
$pos = (isset($pos)) ? $pos : 1; | |
$preserve = (empty($preserve)) ? FALSE : $preserve; |