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 $z='█';$x=' ';$r=10;$s=2.5;$d=10;$t=0.0;$_=pi();$w=exec('tput cols');$h=exec('tput lines'); | |
$c=[abs($w/2),abs($h/2)];function d(&$m,$a,$b,$c,$f){$n=$b[0]-$a[0];$e=$b[1]-$a[1];$s= | |
max(abs($n),abs($e));$n/=$s;$e/=$s;$x=$a[0];$y=$a[1];for($i=0;$i<=$s;$i++){$m[round($y)] | |
[round($x)]="\033[0;".($f+30).";40m$c\033[0;0m";$x+=$n;$y+=$e;}}while(true){$m=array_fill( | |
0,$h,array_fill(0,$w,$x));$j=$u=[cos($t)*$r+$c[0],sin($t)*$r/$s+$d/2+$c[1]];$k=$i=[cos( | |
$t+$_/2)*$r+$c[0],sin($t+$_/2)*$r/$s+$d/2+$c[1]];$l=$o=[cos($t+$_)*$r+$c[0],sin($t+$_)* | |
$r/$s+$d/2+$c[1]];$n=$p=[cos($t+3*$_/2)*$r+$c[0],sin($t+3*$_/2)*$r/$s+$d/2+$c[1]];$j[1]-= | |
$d;$k[1]-=$d;$l[1]-=$d;$n[1]-= $d;d($m,$u,$i,$z,1);d($m,$i,$o,$z,2);d($m,$o,$p,$z,3); | |
d($m,$p,$u,$z,4);d($m,$u,$j,$z,1);d($m,$i,$k,$z,2);d($m,$o,$l,$z,3);d($m,$p,$n,$z,4); | |
d($m,$j,$k,$z,1);d($m,$k,$l,$z,2);d($m,$l,$n,$z,3);d($m,$n,$j,$z,4);usleep(100000);$t+= |
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 declare(strict_types=1); | |
$routes = [ | |
['GET /(?<something_file>[a-z][a-z0-9]{8}\.[a-z0-9]{3,4})', '...meta...'], | |
['GET /(?<ok>what|na)', '...meta...'], | |
['POST /', '...meta...'], | |
]; | |
$regexp = implode('|', array_map( // could be cached | |
static function (int $index, array $values) { |
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 declare(strict_types=1); | |
if (PHP_VERSION_ID < 80000) { die('only php 8'); } | |
/** | |
* Single function dependency injection POC | |
*/ | |
interface Inter {} | |
class A { public function __construct(private int $id) {} } | |
class E { public function __construct(private int $id) {} } | |
class B { public function __construct(private A|E $a) {} } |
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 | |
/** | |
* Translates a number to a short alhanumeric version | |
* | |
* Translated any number up to 9007199254740992 | |
* to a shorter version in letters e.g.: | |
* 9007199254740989 --> PpQXn7COf | |
* | |
* specifiying the second argument true, it will | |
* translate back e.g.: |
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 | |
/** | |
* Lietuviškų vardų linksniai. | |
* | |
* @author Maug Lee <mauglee@gmail.com> | |
* @copyright Copyleft (ↄ) 2011, Maug Lee | |
* @version 0.3 | |
* @package Vardai | |
*/ |
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 | |
public static function slug($str, $replace = [], $delimiter = '-') | |
{ | |
if(count($replace)) { | |
$str = str_replace($replace, ' ', $str); | |
} | |
setlocale(LC_CTYPE, 'en_US.UTF8'); | |
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $str); | |
$clean = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $clean); | |
$clean = strtolower(trim($clean, '-')); |