- Decimal type / Decimal math by default (as opposed to floats)
- Related internals threads:
- Null-safe cast operations
- Generics
- "Interface" for callables / closures
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
function bytes_to_human($bytes) { | |
$human = NULL; | |
if ($bytes < 1024) { | |
$human = number_format ($bytes, 0) .' bytes'; | |
} else if ($bytes < 1024*1024) { | |
$human = number_format (($bytes / 1024), 1) . ' KB'; | |
} else { | |
$human = number_format (($bytes / (1024*1024)), 1) . ' MB'; | |
} | |
return $human; |
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 | |
$type = error_reporting(); | |
$levels = array ( | |
'E_ERROR' => (($type & E_ERROR) == E_ERROR), | |
'E_WARNING' => (($type & E_WARNING) == E_WARNING), | |
'E_PARSE' => (($type & E_PARSE) == E_PARSE), | |
'E_NOTICE' => (($type & E_NOTICE) == E_NOTICE), | |
'E_CORE_ERROR' => (($type & E_CORE_ERROR) == E_CORE_ERROR), | |
'E_CORE_WARNING' => (($type & E_CORE_WARNING) == E_CORE_WARNING), |
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
var preparsePlugin = Chart.PluginBase.extend({ | |
beforeInit: function(chartCtrlr) { | |
var chart = chartCtrlr.chart; | |
var labels = chartCtrlr.data.labels; | |
var momentLabels = []; | |
labels.forEach(function(v) { | |
momentLabels.push(moment(v, moment.ISO_8601)); | |
}); | |
chartCtrlr.data.labels = momentLabels; | |
}, |
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
<FilesMatch "^php-fpm-ping|php-fpm-status$"> | |
SetHandler "proxy:unix:/var/run/php-fpm/dcr_v4.sock|fcgi://localhost/" | |
deny from all | |
allow from localhost | |
</FilesMatch> |
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
https://bugzilla.yoctoproject.org/show_bug.cgi?id=9131 | |
Run: LD_USE_LOAD_BIAS=0 perl -e 'print fork' | |
Temporarily disables prelink | |
Permanent solution: unprelink all the things! | |
See also: | |
https://bugs.gentoo.org/show_bug.cgi?id=579374 |
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
SELECT table1.employee_id_1, table1.employee_id_2, e1.first_name AS e1_first_name, e2.first_name AS e2_first_name | |
FROM table1 | |
LEFT JOIN employee_tbl AS e1 ON table1.employee_id_1 = e1.employee_id | |
LEFT JOIN employee_tbl AS e2 ON table2.employee_id_2 = e2.employee_id |
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 | |
use Bunny\Channel; | |
use Bunny\Async\Client; | |
use Bunny\Message; | |
use Bunny\Protocol\MethodBasicConsumeOkFrame; | |
use React\EventLoop\Factory; | |
require '../../vendor/autoload.php'; |
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 | |
// https://3v4l.org/e79nG | |
$arr1 = [1, 2, 3]; | |
$arr2 = [2, 4, 1]; | |
$arr1 += $arr2; | |
var_dump($arr1); | |
$arr1 = ["foo", "bar", "baz"]; |
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); | |
// Prometheus metrics exporter for PHP-FPM | |
header("Content-Type: text/plain; version=0.0.4"); | |
$stats = null; | |
$protocol = ((!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off") ? "https" : "http"); | |
$result = file_get_contents($protocol ."://" . $_SERVER["SERVER_NAME"] . "/php-fpm-status?json&full"); | |
if ($result !== false) { |
OlderNewer