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 | |
use \Zend\Dom\Query; | |
use \Zend\Debug\Debug; | |
/** | |
* Fetch the page source and cache it, ensuring it's saved as UTF-8 | |
* | |
* @param string $url | |
* @return string |
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 | |
/** | |
* Combine two urls. | |
* | |
* The urls can be either a string or url parts that consist of: | |
* | |
* scheme, host, port, user, pass, path, query, fragment | |
* | |
* If passed in as parts in an array, the query parameter can be either |
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 | |
// Return greatest common divider of two numbers | |
function gcd($a, $b) { | |
return $b ? gcd($b, $a % $b) : $a; | |
} | |
// Returns the least common multiple of two or more numbers. | |
function lcm(...$numbers): int | |
{ |
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 | |
/** | |
* Filter an array of objects. | |
* | |
* You can pass in one or more properties on which to filter. | |
* | |
* If the key of an array is an array, then it will filtered down to that | |
* level of node. | |
* |
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
const hasAllProps = function(list, within) { | |
list.forEach(function(e) { | |
if (!within.hasOwnProperty(e) || within[e] == "") { | |
return false; | |
} | |
}); | |
return true; | |
}; | |
const hasAnyProps = function(list, within) { |
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 | |
/** | |
* Sort an array of objects. | |
* | |
* Requires PHP 5.3+ to be installed. | |
* | |
* Will use the Intl extension to normalize characters if it's | |
* available. | |
* |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" | |
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
<script | |
src="https://code.jquery.com/jquery-3.4.1.slim.min.js" |
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 | |
use Roave\BetterReflection\BetterReflection; | |
use Roave\BetterReflection\Reflector\ClassReflector; | |
use Roave\BetterReflection\SourceLocator\Type\DirectoriesSourceLocator; | |
require __DIR__ . '/vendor/autoload.php'; | |
$refSubscriptions = []; |
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 | |
foreach (range(1, 12) as $m) { | |
$elStart = new \DateTimeImmutable("2019-{$m}-10 23:50:00", new \DateTimeZone('Europe/London')); | |
$elEnd = $elStart->add(new \DateInterval('PT5H')); | |
$utcStart = $elStart->setTimezone(new \DateTimeZone('UTC')); | |
$utcEnd = $elEnd->setTimezone(new \DateTimeZone('UTC')); | |
printf("E/L: %s / %s, UTC: %s / %s\n", | |
$elStart->format(DATE_RFC822), | |
$elEnd->format(DATE_RFC822), |
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 | |
/** | |
* Utility class to enable very simplistic timing. | |
* | |
* Usage example: | |
* | |
* $t = new Timer(); | |
* // do something here | |
* echo $t; |