Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Rafa Rodríguez rafageist

🎯
Focusing
View GitHub Profile
View pairs-combinatorial.php
<?php
// Dada una lista de numeros que se pueden repetir en valor, crear las posibles combinaciones de pares A,B, pero
// no permitir un A,B y un C,A si B y C son iguales en valor, y tampoco permitir A,B y B,A en una misma solucion.
// El orden de las parejas no es relevante de manera que la solucion P1,P2,P3 es igual a P2,P1,P3.
$elements = [1,2,2];
$totalElements = count($elements);
$pairs = [];
$weight = 0;
@rafageist
rafageist / IpCheck.php
Last active Sep 20, 2019
Unique IP access checker with concurrency control
View IpCheck.php
<?php
/**
* Check if a IP exists in a storage with concurrency control for several HTTP requests
*
* Based in divengine\nodes::waitAndDo() queue algorithm
*
* @author rafageist
*/
function IpCheck($ip)
@rafageist
rafageist / Enum.php
Last active Jul 25, 2019
PHP Enum Solution
View Enum.php
<?php
/**
* This is a trick or solution for create enumerations in PHP using classes
* If you are curious you will realize that you can build a hierarchy of
* enumerations, even give other uses to those classes.
*
* @author rafageist
*/
@rafageist
rafageist / index.php
Created Jun 4, 2017
Hello World of Div PHP Template Engine
View index.php
<?php
include "div.php";
echo new div("index.tpl", ["world" => "Earth"]);