Skip to content

Instantly share code, notes, and snippets.

View micc83's full-sized avatar

Alessandro Benoit micc83

View GitHub Profile
@micc83
micc83 / .htaccess
Created November 4, 2014 16:20
htaccess
# Apache Server Configs v2.11.0 | MIT License
# https://github.com/h5bp/server-configs-apache
# (!) Using `.htaccess` files slows down Apache, therefore, if you have
# access to the main server configuration file (which is usually called
# `httpd.conf`), you should add this logic there.
#
# https://httpd.apache.org/docs/current/howto/htaccess.html.
# ######################################################################
@micc83
micc83 / .htaccess
Created May 13, 2015 16:25
htaccess google speed
Header unset Pragma
FileETag None
Header unset ETag
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
@micc83
micc83 / resetdb.sh
Last active October 20, 2015 13:20
Cronjob to drop tables and import dump file to MySql database
#!/bin/bash
mysqldump -u[username] -p[password] \
--add-drop-table --no-data [database] | \
grep -e '^DROP \| FOREIGN_KEY_CHECKS' | \
mysql -u[username] -p[password] [database]
mysql -u[username] -p[password] [database] < [dump_file.sql]
@micc83
micc83 / .vimrc
Last active February 8, 2016 13:44
set nocompatible " Disable vi-compatibility
"------ Vundle BEGIN ------"
"https://github.com/VundleVim/Vundle.vim"
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"------ Plugins ------"
@micc83
micc83 / jquery.scrollto.js
Last active January 9, 2018 13:12
jQuery scrollTo implementation
$('html, body').animate({
scrollTop: $("#target-element").offset().top
}, 1000);
@micc83
micc83 / wpcf7-mail-tags.php
Created June 23, 2016 09:40
Create custom tags for Wordpress Contact Form 7
<?php
add_filter( 'wpcf7_special_mail_tags', function ( $output, $name, $html ) {
if ($name === 'current_url'){
return "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
}
return $output;
}, 10, 3 );
@micc83
micc83 / .htaccess
Created October 31, 2016 16:36
.htaccess for javascript app routing
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
micc83 / emails.sh
Last active May 10, 2017 10:06
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
micc83 / snapshot.php
Last active January 4, 2019 07:09
PHPUnit Assertion that asserts the response content match a previous taken 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
micc83 / mysqldump.php
Created June 5, 2017 13:17
Simple PHP script to dump a MySql database
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$database = 'db';
$user = 'user';
$pass = 'pass';
$host = 'localhost';