Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Adrián G mrroot5

🏠
Working from home
Block or report user

Report or block mrroot5

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View youtubeVideoID.js
var url = "https://www.youtube.com/watch?v=zKx2B8WCQuw";
var videoid = url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
if(videoid != null) {
console.log("video id = ",videoid[1]);
} else {
console.log("The youtube url is not valid.");
}
View get_enum_values.php
function get_enum_values( $table, $field )
{
$type = $this->db->query( "SHOW COLUMNS FROM {$table} WHERE Field = '{$field}'" )->row( 0 )->Type;
preg_match("/^enum\(\'(.*)\'\)$/", $type, $matches);
$enum = explode("','", $matches[1]);
return $enum;
}
View getVimeoId.js
vimeo_Reg = /(?:https?:\/\/)?(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/;
function vimeoID(url) {
var match = url.match(vimeo_Reg);
if (match){
return "<span>"+match[3]+"</span>";
}else{
return "<span class='error'>error</span>";
}
View capitalize.js
// Opcion 1: Modificando el objeto String
String.prototype.capitalize = function(){
return this.toLowerCase().replace( /\b\w/g, function (m) {
return m.toUpperCase();
});
};
String.prototype.capitalizeFirstWord = function(){
return text.charAt(0).toUpperCase() + text.slice(1);
};
@mrroot5
mrroot5 / get_file_extension.php
Last active Aug 29, 2015
Snippets subida ficheros. Obtener extensión fichero y cambiar nombre fichero
View get_file_extension.php
<?php
function get_file_extension($file_name = '') {
$file_name = (empty($file_name)) ? 'bla.bla..pdf' : $file_name;
preg_match('/[^\.]+$/i', $file_name, $ext);
return $ext[0];
}
?>
View get_protocol.php
$protocol = (stripos($_SERVER['SERVER_PROTOCOL'],'https') === true) ? 'https://' : 'http://';
@mrroot5
mrroot5 / windows_installation_date.bat
Created May 17, 2015
Fecha instalación Windows: año/mes/día/hora/minutos/segundos/zonagmt
View windows_installation_date.bat
cmd /k wmic os get installdate
@mrroot5
mrroot5 / mysql_update_field_by_date.sql
Last active Nov 17, 2015
Actualizar un campo en base a una fecha.
View mysql_update_field_by_date.sql
UPDATE `tabla` SET `campo_actualizar` = 0 WHERE `campo_fecha` < NOW() AND `campo_fecha` != '0000-00-00 00:00:00' AND `campo_fecha` IS NOT NULL
View mysql_filter_field_by_words.sql
SELECT SUBSTRING_INDEX(description," ",3) FROM table [WHERE condition];
View mysql_check_if_field_exists.sql
function existe_campo ($db_conn, $tabla, $campo) {
if ($resultado = $db_conn->query('SHOW COLUMNS FROM '.$tabla.' LIKE "'.$campo.'"')) {
if($resultado->num_rows() === 1) {
return TRUE;
} else {
return FALSE;
}
}
}
You can’t perform that action at this time.