Skip to content

Instantly share code, notes, and snippets.

View tanrax's full-sized avatar

Andros Fenollosa tanrax

View GitHub Profile
@tanrax
tanrax / gist:9279571
Created February 28, 2014 20:47
JS: Canvas image (imagen)
var c = document.getElementById("lienzo");
var ctx = c.getContext("2d");
var imageObj = new Image();
imageObj.src = 'img_the_scream.jpg';
imageObj.onload = function() {
ctx.drawImage(imageObj, 69, 50);
};
@tanrax
tanrax / gist:9141515
Created February 21, 2014 19:25
CSS: Tabulación
.tabulacion:first-letter {
margin-left: 15px;
}
@tanrax
tanrax / gist:8973112
Created February 13, 2014 10:51
PHP: Convertir valor en variable (texto en variable)
<?php
$sHola = 'texto';
$sVariable = 'sHola';
echo $$sVariable;
?>
@tanrax
tanrax / gist:8972076
Created February 13, 2014 09:10
PHP: Consulta MySQL (SQL)
<?php
/* Conexion */
$conexion = mysql_connect('localhost', 'root', '');
mysql_select_db('nombreBBDD', $conexion);
/* Consulta */
$sSQL = "SELECT * FROM";
$resultados = mysql_query($sSQL, $conexion) or die(mysql_error());
@tanrax
tanrax / gist:8941648
Created February 11, 2014 19:00
JQuery: Deshabilitar campos de entrada (formularios)
// para deshabilitar un campo, en este caso un botón para enviar
$('input[type="submit"]').attr("disabled", true);
// para volver a habilitar el botón
$('input[type="submit"]').removeAttr('disabled');
@tanrax
tanrax / gist:8941631
Created February 11, 2014 19:00
JQuery: Intercambiar clases efecto hover
$('.btn').hover(function(){
$(this).addClass('hover');
}, function(){
$(this).removeClass('hover');
});
@tanrax
tanrax / gist:8941620
Created February 11, 2014 18:59
JQuery: Arreglar imágenes sin terminar de cargar
$('img').error(function(){
$(this).attr('src', 'img/broken.png');
});
@tanrax
tanrax / gist:8941612
Created February 11, 2014 18:59
JQuery: Comprobar imágenes cargadas
$('img').load(function() {
//se cargaron las imagenes completamente
});
@tanrax
tanrax / gist:8941598
Created February 11, 2014 18:58
JQuery: Volver arriba (ir)
$('a.top').click(function(){
$('html, body').animate({scrollTop : 0},800);
return false;
});
//HTML
<a class="top" href="#">Arriba</a>
@tanrax
tanrax / gist:8931278
Created February 11, 2014 08:41
SQL: Insert, Update, Delete, Create table, drop. (Insertar, actualizar, borrar, crear tabla, borrar)
<?php
/* Insertar */
INSERT INTO usuarios VALUES ('', 'Lisa');
INSERT INTO usuarios (nombre, id) VALUES
('Flanders', NULL);
/* Consulta */
SELECT * FROM usuarios;
SELECT nombre FROM usuarios;