Skip to content

Instantly share code, notes, and snippets.

View rafageist's full-sized avatar
🎯
Focusing

Rafa Rodríguez rafageist

🎯
Focusing
View GitHub Profile
@rafageist
rafageist / pairs-combinatorial.php
Created November 18, 2019 01:07
Combinatorial of pairs
<?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 September 20, 2019 15:04
Unique IP access checker with concurrency control
<?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 July 25, 2019 03:09
PHP Enum Solution
<?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 June 4, 2017 21:23
Hello World of Div PHP Template Engine
<?php
include "div.php";
echo new div("index.tpl", ["world" => "Earth"]);