Skip to content

Instantly share code, notes, and snippets.

View tanrax's full-sized avatar

Andros Fenollosa tanrax

View GitHub Profile
@tanrax
tanrax / gist:8694735
Created January 29, 2014 19:10
PHP: Enviar array con POST
<?php
$aPaises = array();
$aPaises[] = 'Chile';
$aPaises[] = 'Nigeria';
$aPaises[] = 'Ecuador';
?>
@tanrax
tanrax / gist:8734400
Created January 31, 2014 15:38
PHP: Autocargador de bibliotecas (librerias)
<?php
/** Autocargador de librerias **/
spl_autoload_register('autocargador');
function autocargador($insNom)
{
include $insNom . '.class.php';
}
@tanrax
tanrax / gist:8735408
Created January 31, 2014 16:20
PHP: Constante static (estatica)
<?php
public static $NOMBRE = 'Los manicos';
echo Panaderia::$NOMBRE;
?>
@tanrax
tanrax / gist:8735778
Created January 31, 2014 16:38
PHP: Variable salto de línea
PHP_EOL
@tanrax
tanrax / gist:8742855
Created January 31, 2014 20:50
PHP: Clase abstracta (sbstract)
<?php
/** Clase abstracta **/
abstract class Remolque
{
//Fuerza la extensión de clase para definir estos métodos
abstract public function enganchar();
abstract public function soltar();
@tanrax
tanrax / gist:8870919
Created February 7, 2014 20:18
JQuery: Plantilla (básico)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
<div id="miId">Lorem ipsum dolor sit amet.</div>
@tanrax
tanrax / gist:8931246
Created February 11, 2014 08:38
SQL: Consultas (SELECT)
<?php
/* Simple */
SELECT columnas FROM tablas WHERE filtro;
SELECT * FROM vecinos;
SELECT * FROM vecinos WHERE perro = '1';
/* Contar número de resultados */
SELECT count(*) FROM vecinos;
@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;
@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:8941612
Created February 11, 2014 18:59
JQuery: Comprobar imágenes cargadas
$('img').load(function() {
//se cargaron las imagenes completamente
});