Skip to content

Instantly share code, notes, and snippets.

Alessandro Benoit micc83

View GitHub Profile
micc83 /
Created Dec 20, 2018
Tail for commands on Mac
botch() {
while true; do
(echo -en '\033[H'
bash -c "$CMD" | while read LINE; do
echo -n "$LINE"
echo -e '\033[0K'
echo -en '\033[J') | tail -r | tail -r
sleep 2
micc83 / .zshrc
Created Nov 13, 2018
Laradock bash aliases
View .zshrc
alias ld-up="(cd laradock;docker-compose up -d apache2 mariadb)"
alias ld-down="(cd laradock;docker-compose down)"
alias ld-ssh="(cd laradock;docker-compose exec workspace bash)"
micc83 / .htaccess
Created Jan 30, 2018
Maintenance mode through .htaccess
View .htaccess
# Create file maintenance.html then
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
micc83 / mysqldump.php
Created Jun 5, 2017
Simple PHP script to dump a MySql database
View mysqldump.php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
$database = 'db';
$user = 'user';
$pass = 'pass';
$host = 'localhost';
micc83 / snapshot.php
Last active Jan 4, 2019
PHPUnit Assertion that asserts the response content match a previous taken snapshot
View snapshot.php
* Assert the response content match a previous taken snapshot.
* If the snapshot doesn't exists on the first run it gets
* created and the test is marked as incomplete.
private function seeSnapshot()
$testName = debug_backtrace()[1]['function'];
$filename = "snapshots/{$testName}.json";
micc83 /
Last active May 10, 2017
Find email address in a given file
grep -E -o "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}\b" file.txt
or even better:
grep -Eiorh '([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})' "$@" * | sort | uniq > emails.txt
all lowercase:
grep -Eiorh '([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})' "$@" * | tr "[:upper:]" "[:lower:]" | sort | uniq > emails.txt
micc83 / .htaccess
Created Oct 31, 2016
.htaccess for javascript app routing
View .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /conf/index.html [NC,L]
micc83 / wpcf7-mail-tags.php
Created Jun 23, 2016
Create custom tags for Wordpress Contact Form 7
View wpcf7-mail-tags.php
add_filter( 'wpcf7_special_mail_tags', function ( $output, $name, $html ) {
if ($name === 'current_url'){
return $output;
}, 10, 3 );
micc83 / jquery.scrollto.js
Last active Jan 9, 2018
jQuery scrollTo implementation
View jquery.scrollto.js
$('html, body').animate({
scrollTop: $("#target-element").offset().top
}, 1000);
View .vimrc
set nocompatible " Disable vi-compatibility
"------ Vundle BEGIN ------"
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"------ Plugins ------"
You can’t perform that action at this time.