Skip to content

Instantly share code, notes, and snippets.

View micc83's full-sized avatar

Alessandro Benoit micc83

View GitHub Profile
@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 / .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 / 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 / jquery.scrollto.js
Last active January 9, 2018 13:12
jQuery scrollTo implementation
$('html, body').animate({
scrollTop: $("#target-element").offset().top
}, 1000);
@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 / 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 / .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 / .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 / add_query_args.js
Created October 28, 2014 20:05
Add query args to url
/**
* Add query args
*/
function add_query_args(uri, params) {
var separator = uri.indexOf('?') !== -1 ? '&' : '?';
for (var key in params) {
if(params.hasOwnProperty(key)){
uri += separator + key + '=' + params[key];
separator = '&';
}
@micc83
micc83 / fb.css
Created October 9, 2014 08:44
Facebook fix for truncated share box clicking on like button
/* Facebook fix */
.fb-like span{overflow:visible !important; width:450px !important; margin-right:-375px;z-index: 999;}