Skip to content

Instantly share code, notes, and snippets.

View sjimenez77's full-sized avatar
:octocat:
Hi there!

Santos Jiménez Linares sjimenez77

:octocat:
Hi there!
View GitHub Profile
@sjimenez77
sjimenez77 / cloudSettings
Last active December 22, 2017 07:59
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-12-22T07:59:52.885Z","extensionVersion":"v2.8.7"}
@sjimenez77
sjimenez77 / cloudSettings
Last active April 5, 2017 11:30
Visual Studio Code Sync Settings Gist
{"lastUpload":"2017-04-05T11:30:00.158Z","extensionVersion":"v2.6.2"}
@sjimenez77
sjimenez77 / clone.js
Last active August 29, 2015 14:03
Helper function to clone a given object instance
/**
* Helper function to clone a given object instance
* @param {Object} obj Object that is going to be cloned
* @return {Object} Object cloned
*/
function clone (obj)
{
// Handle the 3 simple types, and null or undefined
if (null === obj || "object" != typeof obj) return obj;
@sjimenez77
sjimenez77 / gist:6019305
Last active December 19, 2015 21:19
Javascript: Función de ordenación de un array por campos para aplicarla con el método sort. Se incluyen campos de ejemplo numéricos, texto y fechas.
// FIXERR1002: Función de ordenación para las columnas de las vistas
function sortByKey(array, key, asc) {
return array.sort(function(a, b) {
if (key == "id" ||
key == "cid" ||
key == "eid" ||
key == "nexp" ||
key == "dni" ||
key == "poblacion" ||
key == "provincia" ||
@sjimenez77
sjimenez77 / gist:4757482
Last active December 12, 2015 10:09
Symfony2 / Silex: Configuración Apache: Configurando proyecto Silex (o Symfony) mediante archivo .htaccess en una subcarpeta del hosting.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
# Ruta al inicio de la aplicación: /web/index.php
RewriteRule ^(.*)$ /web/index.php [QSA,L]
# Redirección de carpetas de imágenes, estilos y js para las plantillas TWIG
Redirect /img /web/img
Redirect /css /web/css
Redirect /js /web/js
</IfModule>
@sjimenez77
sjimenez77 / base.rss.twig
Created January 8, 2013 22:48
TWIG: Symfony2: Plantilla base para RSS
<?xml version="1.0"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{% block title %}{% endblock %}</title>
<link>{% block url %}{% endblock %}</link>
<description>{% block descripcion %}{% endblock %}</description>
<language>{% block idioma %}
{{ app.request.locale }}
{% endblock %}</language>
@sjimenez77
sjimenez77 / gist:4485483
Last active December 10, 2015 19:59
PHP: Symfony2: Validación campo de formulario DNI
public function esDniValido(ExecutionContext $context)
{
$dni = $this->getDni();
// Comprobar que el formato sea correcto
if (0 === preg_match("/\d{1,8}[a-z]/i", $dni)) {
$context->addViolationAtSubPath('dni', 'El DNI introducido no tiene el formato correcto (entre 1 y 8 números seguidos de una letra, sin guiones y sin dejar ningún espacio en blanco)', array(), null);
return;
}
@sjimenez77
sjimenez77 / is_valid_email.php
Created January 2, 2013 10:27
PHP: comprobar sintaxis email
function is_valid_email($email)
{
$result = TRUE;
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {
$result = FALSE;
}
return $result;
}
@sjimenez77
sjimenez77 / gist:4419432
Last active December 10, 2015 10:08
jQuery: jQuery Mobile: Valiadación y llamada AJAX para enviar un correo
/* Validación y llamada AJAX para enviar el correo */
$("#submit").click(function() {
var nombre = $("#nombre").val();
email = $.trim($("#email").val());
validacion_email = /^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/;
asunto = $("#asunto").val();
mensaje = $("#mensaje").val();
if ((nombre == "") || (nombre == $("#nombre").attr('placeholder'))){
@sjimenez77
sjimenez77 / gist:4419426
Last active August 10, 2017 04:50
jQuery Mobile: Página con formulario de contacto
<div data-role="page" id="contacto">
<div data-role="header" data-theme="a" data-position="fixed">
<div class="ui-grid-b">
<div class="ui-block-a" style="width:25%"><a href="#home" data-role="button" data-icon="home" data-iconpos="notext" data-direction="reverse">Inicio</a></div>
<div class="ui-block-b" style="width:50%"><center><img src="imgs/santosdesign_peq.fw.png" width="160" height="50"></center></div>
<div class="ui-block-c" style="width:25%">&nbsp;</div>
</div><!-- /grid-b -->
</div><!-- /header -->
<div data-role="content" data-theme="a">
<h1><img src="imgs/contacto.fw.png" width="40" height="40" alt="Inicio">&nbsp;&iquest;Hablamos?</h1>