Skip to content

Instantly share code, notes, and snippets.

View andregumieri's full-sized avatar
🕸️
Making a web

André Gumieri andregumieri

🕸️
Making a web
View GitHub Profile
@andregumieri
andregumieri / cifra-email.php
Last active September 5, 2018 20:51
Cifra endereço de e-mail
<?php
function criptografarEmail($email) {
$parts = explode("@", $email);
// PRIMEIRA PARTE
// Quantidade de letrar para revelar
$first_last_reveal_count = 2;
if(strlen($parts[0]) < 8) {
$first_last_reveal_count = 1;
@andregumieri
andregumieri / .bash_profile
Last active October 15, 2018 23:51
Bash Profile
#source ~/.profile
export GOOGLE_APPLICATION_CREDENTIALS=/Users/andregumieri/dev/canopy/ceauth/functions/staging-service-account.json
# NVM
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
# Ajuste para usar o wp-cli com o MAMP
PHP_VERSION=$(ls /Applications/MAMP/bin/php/ | sort -n | tail -1)
export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:/Applications/MAMP/Library/bin:$PATH
@andregumieri
andregumieri / generate.sh
Created January 23, 2018 21:35
Self-signed certificate working with chrome
(cat /etc/ssl/openssl.cnf <(printf '[SAN]\nsubjectAltName=DNS:*.eu-sand.com.br')) > config.txt
openssl req -x509 -nodes -sha256 -days 3650 -newkey rsa:2048 -keyout host.key -out host.cert -subj "/CN=*.eu-sand.com.br" -reqexts SAN -extensions SAN -config <(cat config.txt)
@andregumieri
andregumieri / wp-behind-proxy-conf
Last active August 25, 2017 15:17
WordPress Behind a Reverse Proxy set on a Elastic Load Balance and Forcing HTTPS and WWW on the URL
ProxyPreserveHost Off
ProxyRequests Off
<Location /blog>
RewriteEngine On
# Forces HTTPS behind elastic load balance
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
@andregumieri
andregumieri / list-folders-s3.sh
Created July 6, 2017 22:05
Lista somente pastas de um bucket S3
aws s3 ls s3://domain.to.the.bucket.com/ | grep -E '\/$'
@andregumieri
andregumieri / mount-airport-hd.sh
Created July 1, 2017 04:36
Monta HD do AirPort no Linux
sudo apt-get install cifs-utils
sudo mount.cifs //192.168.1.202/Externo\ 3TB /mnt/airport-3tb -o password="MinhaSenha!",sec=ntlm,uid=USUARIO_LOCAL
@andregumieri
andregumieri / linux-to-pendrive.sh
Created July 1, 2017 03:20
Pendrive bootsvel com ISO do Linux feito no mac
sudo dd if=/path/to/file.iso of=/dev/rdisk3 bs=4m
# if - Arquivo de entrada
# of - device onde vai ser escrito. Ver discos com `diskutil list`. Se o disco for /dev/disk3, por exemplo, o of fica como /dev/rdisk3. É necessário adicionar o r antes do disk.
# bs - Precisa ser 4m
@andregumieri
andregumieri / sampling-slow-queries.php
Created March 30, 2017 17:03
Sampling Slow MySQL Queries
<?php
define('TEMPO_DE_SAMPLING', 3 * 60); // em segundos
define('TEMPO_DE_ESPERA', 3); // em segundos
define('SLOW_QUERY_TIME', 0); // em segundos (tempo considerado uma query lenta - acima de)
define('LOG_FILE', __DIR__.'/sample-slow-queries-log__' . date('Y-m-d_His') . '.log');
$START = time();
$link = mysqli_connect("localhost", "root" , "root", "database") or die (print("Erro na conexao"));
$processadas = array();
@andregumieri
andregumieri / manifest.json
Created June 17, 2016 16:58
Clipboard as Background Function
{
"name": "Content script using execCommand",
"version": "1",
"manifest_version": 2,
"description": "execCommand succeeds on background page, fails in content script. Open the console to check. http://crbug.com/395376",
"background": {
"scripts": ["readclipboard.js"]
},
"permissions": [
"clipboardRead",
@andregumieri
andregumieri / postToSlack.php
Created September 22, 2015 16:58
Function to post to slack
<?php
function postToSlack($url, $payload) {
$payload = json_encode($payload);
//set POST variables
// $url = 'https://hooks.slack.com/services/T00000000/B00000000/aKE6fvHgjTU7MvknZBlgvADF';
$fields = array(
'payload' => urlencode($payload)
);