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 / coding-standard.md
Last active December 11, 2015 23:28
Coding standard draft for the Doctrine project
  • Code must follow PSR-2.
  • Classes must have a docblock documentation describing their purpose.
  • Class methods must have a docblock documentation, in this order:
    • A mandatory one-line short description.
    • An optional multi-line long description.
    • A mandatory @param annotation for each parameter: @param [type] [name] [description]
      • [type] is the type of the variable, primitive or class.
      • [name] is the name of the parameter, including the leading $.
      • [description] is a short description of the parameter. If the description spans multiple lines, all lines must be indented by the same number of spaces as the first line.
  • The indentation must be such as types, names and descriptions for all parameters of a single method start on the same column.
@BenMorel
BenMorel / dbt2.patch
Last active November 17, 2023 22:00
Downloads and runs the DBT2 benchmark for MySQL.
From 664f364c5c08a4bcb51d8ebdda2f72b9e8f8d491 Mon Sep 17 00:00:00 2001
From: Benjamin Morel <benjamin.morel@gmail.com>
Date: Sun, 17 Sep 2023 14:50:28 +0200
Subject: [PATCH] Patch
---
scripts/mysql/mysql_load_db.sh | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/scripts/mysql/mysql_load_db.sh b/scripts/mysql/mysql_load_db.sh
@BenMorel
BenMorel / webuseradd.sh
Last active December 20, 2015 12:59
Creates a user account with correct permissions to host a website with Apache.
#!/bin/sh
if [ -z $1 ]; then
echo "Usage: $(basename $0) [name]"
exit 1
fi
message() {
printf '%-60s' "$*"
}
@BenMorel
BenMorel / short-array-syntax-converter.php
Last active February 15, 2021 21:53
Replaces traditional array() syntax with the short syntax []
#!/usr/bin/env php
<?php
/**
* Converts all PHP files in a directory to short array syntax.
* Note that this will overwrite all converted PHP files.
* Be sure to have a backup just in case.
*/
if ($argc !== 2) {
@BenMorel
BenMorel / .travis.install-mysql-5.7.sh
Last active December 6, 2019 06:24
Install MySQL 5.7 on Travis-CI
sudo apt-get remove --purge "^mysql.*"
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql
sudo rm -rf /var/log/mysql
echo mysql-apt-config mysql-apt-config/enable-repo select mysql-5.7-dmr | sudo debconf-set-selections
wget http://dev.mysql.com/get/mysql-apt-config_0.2.1-1ubuntu12.04_all.deb
sudo dpkg --install mysql-apt-config_0.2.1-1ubuntu12.04_all.deb
sudo apt-get update -q
sudo apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" mysql-server
@BenMorel
BenMorel / viewport-units-ios.scss
Last active March 11, 2022 13:15
SCSS mixin to support vh and vw units on all iOS Safari versions. Based on an idea by Patrick Burtchaell's: https://gist.github.com/pburtchaell/e702f441ba9b3f76f587
/**
* Fix for vw, vh, vmin, vmax on iOS 7.
* http://caniuse.com/#feat=viewport-units
*
* This fix works by replacing viewport units with px values on known screen sizes.
*
* iPhone 6 and 6 Plus cannot run iOS 7, so are not targeted by this fix.
* Target devices running iOS 8+ will incidentally execute the media query,
* but this will still produce the expected result; so this is not a problem.
@BenMorel
BenMorel / variadics-benchmark.php
Last active April 10, 2016 15:46
Benchmarks the impact of type-hinting on PHP variadic functions
<?php
$variadics = 1000; // number of objects passed to each variadic function
$iterations = 1000; // number of calls of each function
class Foo {
}
function withoutTypeHinting(...$foos) {
}
@BenMorel
BenMorel / TextHtmlConverter.php
Created January 11, 2017 00:00
Converts plain text to HTML
<?php
/**
* Converts a text message to HTML.
*
* The following transformations are applied:
* - Special characters are encoded to HTML entities,
* - Lines of text separated by an emtpy line are converted to paragraphs,
* - Newline characters are converted to `<br>`,
* - Links and e-mail addresses are converted to HTML links,
@BenMorel
BenMorel / convert-utf8mb4.php
Created May 31, 2017 16:12
Generates SQL to convert a MySQL database from utf8 to utf8mb4
<?php
/* Replace with your connection parameters & database name */
$hostname = 'localhost';
$username = 'root';
$password = '';
$database = 'test';
$pdo = new PDO("mysql:host=$hostname", $username, $password);
@BenMorel
BenMorel / setup-el7.sh
Last active September 6, 2017 15:50
Quick setup of extra software on EL7 for a test environment. Note that this disables the MySQL root password, so this is *not* secure.
set -e
sudo yum update -y
sudo yum install -y yum-utils wget
# EPEL repo
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum-config-manager --enable epel
# Remi repo