View Session.php
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 | |
/** | |
* Session.php | |
* | |
* @package Bolido | |
* @author Michael Pratt <pratt@hablarmierda.net> | |
* @link http://www.michael-pratt.com/ | |
* @license MIT | |
*/ |
View Random.php
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 <pratt@hablarmierda.net> | |
* @link http://www.michael-pratt.com/ | |
* @license MIT | |
* | |
*/ |
View Mailer.php
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 <pratt@hablarmierda.net> | |
* @link http://www.michael-pratt.com/ | |
* @license MIT | |
*/ | |
namespace Mailer; |
View Ejemplo1.php
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(); |
View AuthBcrypt.php
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 |
View decorator1.php
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; | |
} |
View dependency1.php
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; |
View anonima.php
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) */ |
View ImageManager.php
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 <pratt@hablarmierda.net> | |
* @version 1.0 | |
* @link http://www.michael-pratt.com/ | |
* @demo http://www.michael-pratt.com/Lab/imageManager/ |
View Teorema-del-Coseno.sql
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 |
NewerOlder