Skip to content

Instantly share code, notes, and snippets.

@sbarrat
sbarrat / generoPersona.php
Last active September 12, 2022 17:04
Detección de genero de Persona España
function generoPersona($nombre, $provider = 'genderAPI')
{
$providers = array(
'genderAPI' => array(
'url' => 'https://gender-api.com/get?name=',
'pais' => '&country=ES'
),
'genderize' => array(
'url' => 'https://api.genderize.io/?name=',
'pais' => '&country_id=es'
@sbarrat
sbarrat / ExtractURLVarValues.sql
Last active August 29, 2015 14:24
Extract the values of the vars in a url
/**
Si le pasamos una cadena como:
'index.php?var=17&otravar=12&masvar=33&muchovar=21'
nos devuelve una tabla con los valores de las variables
*/
DROP PROCEDURE IF EXISTS extractVars;
CREATE PROCEDURE extractVars(url VARCHAR(255))
BEGIN
DECLARE posicion INT;
DECLARE fin INT;
@sbarrat
sbarrat / quitaEspacios.php
Last active August 29, 2015 13:58
Función para quitar espacios en blanco extras dentro de los textos
<?php
function quitaEspacios($texto)
{
$partes = explode(' ', $texto);
$textoLimpio = "";
foreach ($partes as $parte) {
if (strlen($parte) > 0 || $parte != "") {
$nombreLimpio .= $parte." ";
}
}
@sbarrat
sbarrat / Preferences.sublime-settings
Created February 16, 2014 18:56
Sublime Text 3 User Preferences Settings
{
"auto_complete": true,
"auto_complete_commit_on_tab": true,
"auto_complete_with_fields": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/User/base16-ocean.light (SL).tmTheme",
"detect_indentation": true,
"fade_fold_buttons": false,
"folder_exclude_patterns":
@sbarrat
sbarrat / vbaColorToWeb.php
Last active December 19, 2015 05:59
Function to change vba color to hex or rgb
/**
* vbaColorToWeb.php Class to convert VBA color to web Color
*
*
* PHP Version 5.3
*
* @author Ruben Lacasa Mas <ruben@rubenlacasa.es>
* @copyright 2013 Ruben Lacasa Mas http://rubenlacasa.es
* @license http://creativecommons.org/licenses/by-nc-nd/3.0
* CC-BY-NC-ND-3.0
@sbarrat
sbarrat / .htaccess
Created June 16, 2013 19:19
Acceso restringido de usuarios con Apache
AuthType Basic
AuthName "Mi Sitio Seguro"
AuthBasicProvider file
AuthUserFile /ruta/completa/ficheroUsuarios
Require valid-user
@sbarrat
sbarrat / datosEntreFechas.sql
Created June 12, 2013 07:58
Seleccionar datos entre dos fechas
SELECT data FROM tbl WHERE date BETWEEN date1 AND date2
<!--
Demo de datepicker inline en castellano
Autor: Ruben Lacasa Mas <http://rubenlacasa.es>
-->
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="author" content="Ruben Lacasa Mas - rubenlacasa.es">
@sbarrat
sbarrat / SumaTiempos.php
Last active December 17, 2015 16:59
Clase PHP para sumar tiempos / PHP Class to add times
<?php
/**
* SumaTiempos.php Clase para sumar tiempos
*
* Esta clase sirve para teniendo un tiempo inicial y un Array con tiempos
* los suma y nos devuelve el tiempo final
*
* PHP Version 5.3
*
* @author Ruben Lacasa Mas <ruben@rubenlacasa.es>
@sbarrat
sbarrat / datepickerEs.js
Created July 20, 2012 16:03
Datepicker jQuery en castellano
$('.datepicker').datepicker({
dateFormat: "dd-mm-yy",
firstDay: 1,
dayNamesMin: ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa"],
dayNamesShort: ["Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab"],
monthNames:
["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio",
"Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
monthNamesShort:
["Ene", "Feb", "Mar", "Abr", "May", "Jun",