Skip to content

Instantly share code, notes, and snippets.

View IsaacAndres's full-sized avatar

Isaac Calavera IsaacAndres

View GitHub Profile
@IsaacAndres
IsaacAndres / myisam-a-innodb.php
Last active February 12, 2020 15:02
Cambiar $table->Tables_in_dbname por $table->Tables_in_<nombre_de_tu_base_de_datos>
<?php
$dbhost = 'hostname';
$dbname = 'dbname';
$dbuser = 'dbuser';
$dbpass = 'dbpassword';
$dsn = 'mysql:dbname='.$dbname.';host='.$dbhost;
try {
$dbh = new PDO($dsn, $dbuser, $dbpass);
} catch (PDOException $e) {
@IsaacAndres
IsaacAndres / random_password.php
Created May 14, 2019 15:58
Genera password aleatoria
<?php
$password = substr( md5(microtime()), 1, 8);
@IsaacAndres
IsaacAndres / autover.php
Last active May 13, 2019 14:41
Devuelve la ruta de un JS o CSS con su versión (fecha de ultima modificación)
<?php
function autoVer($url)
{
$path = pathinfo($url);
$ver = '?v='.filemtime($_SERVER['DOCUMENT_ROOT'].$url);
return $path['dirname'].'/'.$path['basename'].$ver;
}
@IsaacAndres
IsaacAndres / curl.php
Created April 23, 2019 04:03
Petición POST usando cURL
<?php
// abrimos la sesión cURL
$ch = curl_init();
// definimos la URL a la que hacemos la petición
curl_setopt($ch, CURLOPT_URL,"http://www.aeurus.cl/api.php");
// indicamos el tipo de petición: POST
curl_setopt($ch, CURLOPT_POST, TRUE);
// definimos cada uno de los parámetros
curl_setopt($ch, CURLOPT_POSTFIELDS, "valor1=value1&valor2=value2&valor3=value3");