This file contains hidden or 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
<?hh // strict | |
namespace Polyfill; | |
use type ReflectionMethod; | |
use type ReflectionFunction; | |
function call_user_func(mixed $callable, mixed ...$args): mixed { | |
return call_user_func_array($callable, $args); | |
} |
This file contains hidden or 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
<?hh // strict | |
use namespace HH\Asio; | |
/** | |
* Hate both the player, and the game. | |
*/ | |
<<__EntryPoint>> | |
async function main(): Awaitable<void> { |
This file contains hidden or 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); | |
// based on SO answer by Galvic | |
// https://stackoverflow.com/a/18602474/7427482 | |
function timeago(DateTime $ago, bool $full = false): string { | |
$now = new DateTime(); | |
$diff = $now->diff($ago); | |
$values = [ |
This file contains hidden or 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 | |
/*ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
β @author Saif Eddin Gmati <[email protected]> | |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ*/ | |
declare(strict_types=1); | |
namespace Polar\Session; | |
use DateTime; | |
use Dflydev\FigCookies\FigResponseCookies; |
This file contains hidden or 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 | |
$array = ['a' => 1 , 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5, 'f' => 6]; | |
// get the βrest of the valuesβ from an array, when doing destructuring assignment, as a new array. | |
[$a, $b, ...$others] = $array; | |
var_dump($a) // int(1) | |
var_dump($b) // int(2) |
This file contains hidden or 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); | |
/** | |
* Calculate factorial using recursive function call | |
* | |
* @see https://3v4l.org/oeZp9 | |
* | |
* @param int $n | |
* | |
* @throws InvalidArguemntException |
This file contains hidden or 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
class Storage { | |
static get(key) { | |
let value = localStorage.getItem(key); | |
return value === null ? null : JSON.parse(value); | |
} | |
static set(key,value) { | |
return localStorage.setItem(key,JSON.stringify(value)); | |
} |
NewerOlder