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 / 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 / viewport-units-ios.scss
Last active January 25, 2025 17:53
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 / .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 / 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 / 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 / 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 <[email protected]>
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 / 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.