Skip to content

Instantly share code, notes, and snippets.

@csalgueiro
csalgueiro / generarMatricula.php
Created January 10, 2014 13:14
Funcion para generar aleatoriamente matriculas europeas
function generateMatricula() {
$numbers = '0123456789';
$characters = 'BCDFGHIJKLMNPQRSTVWXYZ';
$randomString = '';
for ($i = 0; $i < 4; $i++) {
$randomString .= $numbers[rand(0, strlen($numbers) - 1)];
}
for ($i = 0; $i < 3; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
@csalgueiro
csalgueiro / selectinsert.sql
Created November 29, 2013 15:43
SelectInsert sencillo
INSERT INTO tabla ( id, nombre, activo, fecha ) SELECT $id, $nombre, $activo, now() WHERE NOT EXISTS ( SELECT id FROM tabla WHERE nombre = $nombre AND activo = $activo )
@csalgueiro
csalgueiro / .htaccess
Created November 15, 2013 09:31
cambiar encoding por htaccess
AddDefaultCharset UTF-8
#Por defecto para todos
AddCharset ISO-8850-1 .js
#Cambiarlo para un conjunto de archivos
@csalgueiro
csalgueiro / insertorreplace.mysql
Created October 30, 2013 11:17
insertar o actualizar valores multiples
INSERT INTO contents_languages (
id_content,
id_language,
friendly,
title,
abstract,
text,
place
)
VALUES
@csalgueiro
csalgueiro / capitalize.sql
Created October 16, 2013 15:33
Capitaliza palabras en SQL
CREATE FUNCTION CAP_FIRST (input VARCHAR(255))
RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE len INT;
DECLARE i INT;
@csalgueiro
csalgueiro / animation.css
Created October 8, 2013 12:17
CrossBrowser easy CSS3 animation
.objeto_animado{
-webkit-animation-name: escala;
-webkit-animation-duration: 0.6s;
-webkit-animation-iteration-count:1;
-ms-animation-name: escala;
-ms-animation-duration: 0.6s;
-ms-animation-iteration-count:1;
-moz-animation-name: escala;
-moz-animation-duration: 0.6s;
-moz-animation-iteration-count:1;
@csalgueiro
csalgueiro / custom_validate.js
Created October 8, 2013 11:35
Add Custom Validation
$("#"+formid).find("input[name^='losqempiecenpor']").each(function () {
var $element = $(this);
$element.rules('add', { required: true, maxlength:30 });
});
@csalgueiro
csalgueiro / datatablesfootercallback.js
Created October 8, 2013 06:49
Sumar Totales de un Datable (siempre y cuando haya texto en el th equivalente de la anterior fila)
"fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) {
var total = [];
if(aaData.length>0){
for ( var i=0 ; i<aaData.length ; i++ ){
for ( var j=1 ; j<aaData[i].length; j++ ){
if(aaData[i][j]!="undefined" && aaData[i][j]!=null){
total[j] = (parseFloat(total[j]) || 0) + parseFloat(aaData[i][j]);
}
}
}
@csalgueiro
csalgueiro / addons.css
Created October 4, 2013 10:45
Elipsis de textos
.text_ellipsis{
white-space: nowrap;
text-overflow: ellipsis;
overflow-x: hidden;
display: block;
}
@csalgueiro
csalgueiro / nuevo_xml.php
Created October 4, 2013 10:38
XML via DomDocument
$dom = new DOMDocument("1.0","utf-8");
$elemento = $dom->createElement("elemento");
$dom->appendChild($elemento);
$xml = $dom->saveXML();