This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Tenso.php | |
* | |
* @author Michael Pratt <[email protected]> | |
* @version 1.0 | |
* @link http://www.michael-pratt.com/blog/9/Aprendiendo-con-Memes-Tenso/ | |
* @demo http://www.michael-pratt.com/Lab/tenso/ | |
* | |
* @License: MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT id, nombre, (6371 * ACOS( | |
SIN(RADIANS(lat)) * SIN(RADIANS(4.6665578)) | |
+ COS(RADIANS(lng - -74.0524521)) * COS(RADIANS(lat)) | |
* COS(RADIANS(4.6665578)) | |
) | |
) AS distance | |
FROM direcciones | |
HAVING distance < 1 /* 1 KM a la redonda */ | |
ORDER BY distance ASC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* ImageManager.php | |
* A wrapper around GD that does multiple operations like, resizing, rotating, | |
* cropping and stuff. | |
* | |
* @author Michael Pratt <[email protected]> | |
* @version 1.0 | |
* @link http://www.michael-pratt.com/ | |
* @demo http://www.michael-pratt.com/Lab/imageManager/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Tenemos un arreglo con números | |
$misNumeros = array('1', '2', '3', '4', '5', '6'); | |
/* Pero resulta que solo queremos los numeros impares, | |
así que usamos array_filter con una función anonima, | |
en vez de declarar la funcion antes. */ | |
print_r(array_filter($misNumeros, function($n) { return ($n%2 != 0); })); | |
/* Resulta en: Array([0] => 1, [2] => 3, [4] => 5) */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Logger | |
{ | |
protected $file; | |
public function __construct($file) { $this->file = $file; } | |
public function log($message) | |
{ | |
$message = date('H:i:s ') . $message . PHP_EOL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Damage | |
{ | |
protected $name; | |
protected $damagePoints = 10; | |
public function __construct($name) | |
{ | |
$this->name = $name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$nombre = $_POST['nombre']; | |
$password = $_POST['pass']; | |
// Validamos $nombre, bla bla bla.. | |
// Extraemos el hash de la base de datos | |
$db = new PDO(......); | |
$stmt = $db->prepare('SELECT pass | |
FROM usuarios |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Clase Partido | |
* En este caso este es nuestro sujeto | |
*/ | |
class Partido implements \SplSubject | |
{ | |
protected $teams = array(); | |
protected $observers = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Mailer.php | |
* | |
* @author Michael Pratt <[email protected]> | |
* @link http://www.michael-pratt.com/ | |
* @license MIT | |
*/ | |
namespace Mailer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Random.php | |
* | |
* @author Michael Pratt <[email protected]> | |
* @link http://www.michael-pratt.com/ | |
* @license MIT | |
* | |
*/ |
OlderNewer