Skip to content

Instantly share code, notes, and snippets.

@daniellockyer
daniellockyer / sqldiff-watch.sh
Created January 8, 2021 21:35
sqldiff-watch.sh
#!/bin/bash
DB_FILE=$1
DB_FILE_COPY=$2
while [ 1 ]; do
if [[ -f "$DB_FILE_COPY" ]]; then
sqldiff $DB_FILE_COPY $DB_FILE
fi
@daniellockyer
daniellockyer / hist.php
Created November 23, 2018 03:59
PHP response time histograms
<?php
require_once(__DIR__.'/vendor/autoload.php');
function remove_outliers($dataset, $magnitude = 1) {
$count = count($dataset);
$mean = array_sum($dataset) / $count;
$deviation = sqrt(array_sum(array_map("sd_square", $dataset, array_fill(0, $count, $mean))) / $count) * $magnitude;
return array_filter($dataset, function($x) use ($mean, $deviation) { return ($x <= $mean + $deviation && $x >= $mean - $deviation); });
}
<!DOCTYPE html>
<html>
<head>
<title>XDebug Flame Graph</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2" />
<style>
label {cursor: pointer;}
svg{width:100%;}
</style>
@daniellockyer
daniellockyer / ocp.php
Last active June 22, 2018 08:22 — forked from ck-on/ocp.php
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)#ocp #php #opcache #opcode #cache #zend #optimizerplus #optimizer+
<?php
/*
OCP - Opcache Control Panel (aka Zend Optimizer+ Control Panel for PHP)
Author: _ck_ (with contributions by GK, stasilok)
Version: 0.1.7
Free for any kind of use or modification, I am not responsible for anything, please share your improvements
* revision history
0.1.7 2015-09-01 regex fix for PHP7 phpinfo
0.1.6 2013-04-12 moved meta to footer so graphs can be higher and reduce clutter