Skip to content

Instantly share code, notes, and snippets.

View hotfix31's full-sized avatar

Frédéric Fayard-Le Barzic hotfix31

View GitHub Profile
@hotfix31
hotfix31 / ConsoleStopwatchSubscriber.php
Last active January 27, 2021 14:24
EventSubscriber for profiling command console Symfony with Stopwatch component
<?php
namespace App\EventSubscriber;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Event\ConsoleErrorEvent;
use Symfony\Component\Console\Event\ConsoleEvent;
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@hotfix31
hotfix31 / sphp.sh
Created January 26, 2020 19:08 — forked from rhukster/sphp.sh
Easy Brew PHP version switching
#!/bin/bash
# Creator: Phil Cook
# Modified: Andy Miller
osx_major_version=$(sw_vers -productVersion | cut -d. -f1)
osx_minor_version=$(sw_vers -productVersion | cut -d. -f2)
osx_patch_version=$(sw_vers -productVersion | cut -d. -f3)
osx_patch_version=${osx_patch_version:-0}
osx_version=$((${osx_major_version} * 10000 + ${osx_minor_version} * 100 + ${osx_patch_version}))
brew_prefix=$(brew --prefix | sed 's#/#\\\/#g')
@hotfix31
hotfix31 / .htaccess
Created August 29, 2018 14:54
htaccess for wordpress
# BEGIN fred config
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# remove www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# redirect to https
@hotfix31
hotfix31 / symfony3-rest-api.md
Created November 20, 2017 23:02 — forked from diegonobre/symfony3-rest-api.md
Basic RESTful API with Symfony 3 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 3 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authenticationu
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 3 framework. The following SF2 bundles are used :

@hotfix31
hotfix31 / update-iptables.sh
Last active September 5, 2017 15:30
Pour se protéger des VPN (openvpn) pro qui autorisent le client-to-client.
#!/bin/bash
[ "$script_type" ] || exit 0
[ "$dev" ] || exit 0
case "$script_type" in
up)
iptables -A OUTPUT -i $dev -j ACCEPT
iptables -A INPUT -i $dev -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i $dev -j DROP

Keybase proof

I hereby claim:

  • I am hotfix31 on github.
  • I am flebarzic (https://keybase.io/flebarzic) on keybase.
  • I have a public key ASCJZrE-F-ca1719dPkNgxBhXBuAXBUYzLYrDboN72ezcwo

To claim this, I am signing this object:

@hotfix31
hotfix31 / munin.conf
Last active January 28, 2016 10:06
munin-plesk
[apache_*]
env.url http://127.0.0.1:%d/server-status?auto
env.ports 7080
@hotfix31
hotfix31 / GeoIP_update.sh
Created March 30, 2015 13:55
Auto update GeoIP
#!/bin/bash
# Script to update Maxmind's GeoIP files
# Author: Richard Leszczynski
# Contact: contact NOSPAM @makerdyne.com
# Created: 18 November 2011
# Last Modified: 21 November 2011
# --------------------------------------------------------------------
# Purpose:
# --------------------------------------------------------------------
#!/bin/bash
echo "### Post-install"
cd /
N=`date +%F`
H=`hostname -s`
I=`hostname -i`
F=`hostname -f`
<?php
function cleanup_email($email){
$check_domains = array_merge(
array_fill_keys(array('gmol.com', 'gmail.fr', 'gmail.ca', 'gmal.com', 'gmazil.com', 'gmail.como', 'gail.com', 'gamil.com', 'gemail.com'), 'gmail.com'),
array_fill_keys(array('orangr.fr', 'ornage.fr', 'prange.fr', 'roange.fr'), 'orange.fr'),
array_fill_keys(array('wanado.fr', 'xanadoo.fr', 'wandoo.fr', 'wanadoio.fr', 'wanadoo.gr'), 'wanadoo.fr'),
array_fill_keys(array('hotmail.col', 'homail.com', 'hotmai.com'), 'hotmail.com'),
array_fill_keys(array('holmail.fr', 'hotlmail.fr', 'hotaiml.fr', 'hotamil.fr', 'totmail.fr', 'htmail.fr', 'hotail.fr', 'hotmil.fr', 'hotmaial.fr'), 'hotmail.fr'),
array_fill_keys(array('otlook.fr', 'outlock.fr', 'ootlook.fr'), 'outlook.fr'),