Skip to content

Instantly share code, notes, and snippets.

@AllenJB
AllenJB / _solution notes
Last active September 12, 2016 14:01
Fun with perl system()
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
<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 / chart.time-preparse.js
Created May 13, 2016 16:14
Chart.js: Pre-parse time values into moment objects
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;
},
<?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),
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;