Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjamin Morel BenMorel

View GitHub Profile
@BenMorel
BenMorel / benchmark.csv
Created Sep 21, 2020
[medium] innodb_io_capacity benchmark
View benchmark.csv
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 / benchmark.md
Created Sep 17, 2020
[medium] Filesystem benchmark
View benchmark.md
Filesystem default (128M) 10G 20G
ext4 39952 71552 70907
XFS 40311 69782 70147
@BenMorel
BenMorel / DoctrineCompilerPass.php
Created Jan 28, 2020
A Symfony compiler pass to set the default transaction isolation level on Doctrine\DBAL\Connection
View DoctrineCompilerPass.php
<?php
declare(strict_types=1);
namespace App;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\TransactionIsolationLevel;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@BenMorel
BenMorel / JsonCanonicalizer.php
Created Jan 27, 2020
Simple canonicalization of a JSON string.
View JsonCanonicalizer.php
<?php
/**
* Simple canonicalization of a JSON string.
*
* - removes formatting
* - sorts object properties
*/
class JsonCanonicalizer
{
@BenMorel
BenMorel / iptables-config-script
Created Oct 17, 2019 — forked from LouWii/iptables-config-script
Bash script to configure iptables for a web server. Some rules can be removed depending on used services.
View iptables-config-script
#!/bin/sh
# Empty all rules
sudo iptables -t filter -F
sudo iptables -t filter -X
# Set up default rules
sudo iptables -t filter -P INPUT DROP
sudo iptables -t filter -P FORWARD DROP
sudo iptables -t filter -P OUTPUT ACCEPT
@BenMorel
BenMorel / increase_memory_limit.php
Last active Oct 15, 2019
Increase memory limit in PHP
View increase_memory_limit.php
<?php
function _parse_memory_limit(string $value): int
{
if (preg_match('/^([0-9]+)([KMG]?)$/', strtoupper($value), $matches) !== 1) {
throw new RuntimeException('Invalid value for memory_limit: ' . $value);
}
[, $number, $multiplier] = $matches;
@BenMorel
BenMorel / reset-rds-mysql-replication.txt
Last active Oct 5, 2019
Reset RDS MySQL replication
View reset-rds-mysql-replication.txt
# On slave
# ========
mysql> CALL mysql.rds_stop_replication;
mysql> CALL mysql.rds_reset_external_master;
# Drop & recreate replicated databases
mysql > DROP DATABASE <xxx>;
mysql > CREATE DATABASE <xxx>;
@BenMorel
BenMorel / 1-letsencrypt-setup.sh
Last active Feb 12, 2020
Set up letsencrypt certificate with Apache and renew automatically
View 1-letsencrypt-setup.sh
# Note: this must be executed on the server hosting the domain name!
# Install required packages on RHEL / CentOS:
sudo yum install -y certbot python2-certbot-apache
# On Fedora:
sudo yum install -y certbot python3-certbot-apache
# Set up letsencrypt: validates the domain, generates a certificate, and updates Apache config
# Replace example.tld with your domain name
@BenMorel
BenMorel / packages.txt
Created Sep 23, 2019
Composer packages survey - true as a type (union types RFC)
View packages.txt
drupal/console
drupal/core
google/auth
johnpbloch/wordpress-core
khanamiryan/qrcode-detector-decoder
magento/zendframework1
pear/archive_tar
phing/phing
php-di/php-di
php-http/message
@BenMorel
BenMorel / SearchMySQL.php
Created Jan 24, 2019
(StackOverflow) Update MediaWiki's SearchMySQL to handle accents (needs the searchindex table to be converted to utf8)
View SearchMySQL.php
<?php
/**
* MySQL search engine
*
* Copyright (C) 2004 Brion Vibber <brion@pobox.com>
* https://www.mediawiki.org/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
You can’t perform that action at this time.