Skip to content

Instantly share code, notes, and snippets.

View BenMorel's full-sized avatar
🤝
Open to work. Drop me an email!

Benjamin Morel BenMorel

🤝
Open to work. Drop me an email!
View GitHub Profile
@BenMorel
BenMorel / benchmark.md
Created September 17, 2020 12:25
[medium] Filesystem benchmark
Filesystem default (128M) 10G 20G
ext4 39952 71552 70907
XFS 40311 69782 70147
@BenMorel
BenMorel / benchmark.csv
Created September 21, 2020 08:06
[medium] innodb_io_capacity benchmark
innodb_io_capacity innodb_io_capacity_max NOTPM
200 200 88208
200 300 88857
200 400 88547
200 500 88671
200 750 88850
200 1000 88433
200 1500 89293
200 2000 89644
200 3000 92469
@BenMorel
BenMorel / generate-wildcard-certificate.sh
Created October 13, 2020 16:40 — forked from PowerKiKi/generate-wildcard-certificate.sh
Generate self-signed wildcard SSL certificate for development environment
#!/usr/bin/env bash
# print usage
DOMAIN=$1
if [ -z "$1" ]; then
echo "USAGE: $0 domain.lan"
echo ""
echo "This will generate a non-secure self-signed wildcard certificate for given domain."
echo "This should only be used in a development environment."
@BenMorel
BenMorel / pecl-versions.php
Last active October 25, 2020 15:28
Adds "PECL <package name>" in front of versions in php.net docs changelogs.
<?php
/**
* Adds "PECL <package name>" in front of versions in php.net docs changelogs.
* Used for https://github.com/php/doc-en/pull/162
*/
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/reference'));
foreach ($files as $file) {
<?php
/**
* This script downloads the list of releases of a project via the GitHub API,
* and generates a changelog out of it.
*
* Example, to generate a changelog for brick/math:
*
* php changelog-from-github-api.php brick/math > CHANGELOG.md
*/
@BenMorel
BenMorel / dump.php
Created November 23, 2020 13:24
Example of using the benmorel/smartdump PHP API instead of the CLI
<?php
/**
* Example valid with benmorel/smartdump~0.2.0
*
* https://github.com/BenMorel/smartdump
*/
use BenMorel\SmartDump\Configuration\DumpConfiguration;
use BenMorel\SmartDump\Configuration\TargetTable;
@BenMorel
BenMorel / bootstrap.php
Last active May 3, 2023 21:36
The first lines of any decent PHP quick script
<?php
declare(strict_types=1);
error_reporting(E_ALL);
set_error_handler(function ($severity, $message, $file, $line) {
if ((error_reporting() & $severity) === 0) {
return false;
}
@BenMorel
BenMorel / ca.crt
Created November 27, 2020 09:40
My public dev certificate
-----BEGIN CERTIFICATE-----
MIIDdTCCAl2gAwIBAgIUN09wV0sbUhrzQ9WonV0xOabJqJ8wDQYJKoZIhvcNAQEL
BQAwSjELMAkGA1UEBhMCVVMxGDAWBgNVBAoMD19EZXZlbG9wbWVudCBDQTEhMB8G
A1UEAwwYRGV2ZWxvcG1lbnQgY2VydGlmaWNhdGVzMB4XDTIwMTAxNDE2MTA0NFoX
DTMwMTAxMjE2MTA0NFowSjELMAkGA1UEBhMCVVMxGDAWBgNVBAoMD19EZXZlbG9w
bWVudCBDQTEhMB8GA1UEAwwYRGV2ZWxvcG1lbnQgY2VydGlmaWNhdGVzMIIBIjAN
BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzpZt/KQzyM+eJW336oeZFb+wqrBQ
gcTPttoRIbaVKvxsGUiXcf1RaYrn9KLfNn3J6HGv6s1gO/sPooNch53dq8pkqPtZ
VQUn66A/0FIMvkBd0Y/zTb5n4eTFwJcrn1xhYiBEODkkr+4c6YAAzDGg2ngY6gay
0womr6C72NDOFQCXVewr+KkXi6DWqIF1cE4hBZ0i97ASMCkWGL/3+cotzmbdBkE1
@BenMorel
BenMorel / errorLevelToConstants.php
Last active March 25, 2022 09:45
Returns constants matching an error level
<?php
/**
* Examples:
*
* errorLevelToConstants(E_WARNING) => ['E_WARNING', 'E_ALL']
* errorLevelToConstants(3) => ['E_ERROR', 'E_WARNING', 'E_ALL']
*
* @return string[]
*/
@BenMorel
BenMorel / getDominantColor.php
Last active December 3, 2020 14:48
Get dominant color from an Imagick image
<?php
/**
* Two methods to get the dominant color from an image.
* Useful to create placeholders while loading an image.
*
* Method 1 yields more bright colors than method 2.
*/
/**