Skip to content

Instantly share code, notes, and snippets.

AllenJB AllenJB

Block or report user

Report or block AllenJB

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:fd2fdea2ff3cbab7cbf74463f0650994
public function fatalMemory() : void
{
$a = '';
while (true) {
$a .= str_repeat("Hello", 1024 * 1024);
}
}
public function timeout() : void
@AllenJB
AllenJB / _wishlist.md
Last active Feb 15, 2020
PHP Wishlist
View _wishlist.md
@AllenJB
AllenJB / phpfpm-prometheus.php
Created Jul 12, 2019
PHP-FPM Pool Monitoring w/ Prometheus
View phpfpm-prometheus.php
<?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) {
@AllenJB
AllenJB / array_merge vs plus.php
Created Mar 25, 2019
PHP Canonical Answers & Stuff
View array_merge vs plus.php
<?php
// https://3v4l.org/e79nG
$arr1 = [1, 2, 3];
$arr2 = [2, 4, 1];
$arr1 += $arr2;
var_dump($arr1);
$arr1 = ["foo", "bar", "baz"];
@AllenJB
AllenJB / async-worker-cancel.php
Last active Jul 6, 2018
Bunny Async Worker w/ signal handler
View async-worker-cancel.php
<?php
use Bunny\Channel;
use Bunny\Async\Client;
use Bunny\Message;
use Bunny\Protocol\MethodBasicConsumeOkFrame;
use React\EventLoop\Factory;
require '../../vendor/autoload.php';
@AllenJB
AllenJB / gist:872553b5cb2086b0b8de9b0c50044ce5
Last active Jun 30, 2018
MySQL join same table on different fields
View gist:872553b5cb2086b0b8de9b0c50044ce5
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
@AllenJB
AllenJB / _solution notes
Last active Sep 12, 2016
Fun with perl system()
View _solution notes
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
View gist:db9bec56e685c0390115a6f38a518cf3
<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>
@AllenJB
AllenJB / notes.md
Last active Aug 26, 2016
RedditBooru install notes
View notes.md

Issues

  1. Missing files: /static/fonts/mission-gothic.css

  2. window.startUp doesn't exist if there are no images, causing a JS error

  3. crons contain redifinitions of config entries - should source config files instead

  4. What should OAuth2 client redirect_uri be?

@AllenJB
AllenJB / chart.time-preparse.js
Created May 13, 2016
Chart.js: Pre-parse time values into moment objects
View chart.time-preparse.js
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;
},
You can’t perform that action at this time.