Skip to content

Instantly share code, notes, and snippets.

View patrickmaciel's full-sized avatar
🙏
Jesus is coming!

Patrick Maciel patrickmaciel

🙏
Jesus is coming!
View GitHub Profile
@patrickmaciel
patrickmaciel / post-commit
Last active December 20, 2018 11:36 — forked from LordGaav/post-commit
Git hook that determines the author based on the email address in a SSH key. Doesn't work because Git doesn't check the config between pre-commit and commit. #git #hook
#!/bin/sh
# Retrieve author information as Git sees it while commiting
AUTHORINFO=$(git var GIT_AUTHOR_IDENT) || exit 1
NAME=$(printf '%s\n' "${AUTHORINFO}" | sed -n 's/^\(.*\) <.*$/\1/p')
EMAIL=$(printf '%s\n' "${AUTHORINFO}" | sed -n 's/^.* <\(.*\)> .*$/\1/p')
printf "AUTHORINFO: %s\n" "${AUTHORINFO}"
printf "NAME: %s\n" "${NAME}"
printf "EMAIL: %s\n" "${EMAIL}"
@patrickmaciel
patrickmaciel / git.sh
Last active December 20, 2018 11:37
Alterar nome e senha de todos commits de um e-mail específico #git
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Seu nome"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
@patrickmaciel
patrickmaciel / checked.js
Created April 12, 2016 17:31
Get checked inputs and then checked the new inputs
HTML.query('input[checked=checked]').each(function(el, li, all) {
console.log(el.value);
});
var itens = [1, 270, 327, 112, 111, 107, 293, 328, 110, 326, 175, 174, 289, 286, 291, 288, 285, 290, 170, 294, 312, 173, 261, 318, 325, 80, 85, 83, 79, 81, 311, 82, 296, 224, 220, 225, 223, 219, 231, 227, 232, 230, 226, 228, 229, 221, 222, 238, 234, 239, 237, 233, 245, 241, 246, 244, 240, 242, 243, 297, 235, 236, 252, 248, 253, 251, 247, 298, 259, 255, 260, 258, 254, 256, 257, 249, 250, 303, 299, 302, 304, 306, 300, 305, 307, 309, 301, 308, 310, 292, 262, 295, 316, 315];
$.each(itens, function(index, value) {
$('input[value=' + value +']').attr('checked', 'checked');
});
@patrickmaciel
patrickmaciel / post-update
Created April 11, 2016 12:01
Git hook SSH another EC2 server
#!/bin/sh
unset $(git rev-parse --local-env-vars)
echo ''
echo '[SSH] Connecting in site.iab.hml...'
ssh -i /home/ubuntu/.ssh/ANOTHER_SERVER_PEM.pem ubuntu@IP_FROM_ANOTHER_SERVER <<'ENDSSH'
echo '[IN] Connected!'
echo '[IN] Listing directories...'
to
ls -liah
@patrickmaciel
patrickmaciel / server_block_wordpress_nginx.conf
Created April 7, 2016 20:10
Configuração do Nginx para um site Wordpress - utilizando um cache violento
# fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:25m inactive=1440m;
# fastcgi_cache_key "$scheme$request_method$host$request_uri";
# fastcgi_cache_use_stale error timeout invalid_header http_500;
# fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
listen 80;
root /var/www/html/pasta_do_wordpress;
index index.php index.html index.htm;
server_name dominiodosite.com.br;
{
// Example for:
// - Windows 7
// - With phpcs and php-cs-fixer support
// We want debugging on
"show_debug": true,
// Only execute the plugin for php files
"extensions_to_execute": ["php"],
@patrickmaciel
patrickmaciel / gist:f88f52e43e14adc8654a
Created March 9, 2016 19:49 — forked from jrmadsen67/gist:bd0f9ad0ef1ed6bb594e
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the
@patrickmaciel
patrickmaciel / Preferences.sublime-settings
Created January 28, 2016 13:46
sublime text settings - ubuntu
{
"auto_complete_commit_on_tab": true,
"auto_complete_selector": "source, text",
"auto_complete_with_fields": true,
"caret_style": "phase",
"close_windows_when_empty": false,
"default_line_ending": "unix",
"dpi_scale": 2.0,
"draw_minimap_border": true,
"ensure_newline_at_eof_on_save": true,
@patrickmaciel
patrickmaciel / student.json
Created January 20, 2016 20:37
Sample Student
{
aluno: "Andryan Charllys Cardoso Da Silva Dos Santos "
aluno_id: "2607"
cidade: "Jequiá da Praia"
escola: "Escola Municipal de Educação Básica José Calazans de Medeiros"
escola_id: "379"
estado: "AL"
mundos: Object
mundo1: Object
habilidades: Object
@patrickmaciel
patrickmaciel / build-emacs.sh
Created January 14, 2016 13:37 — forked from favadi/build-emacs.sh
Compile latest emacs version (24.5) in Ubuntu 14.04
#!/bin/bash
# Build latest version of Emacs, version management with stow
# OS: Ubuntu 14.04 LTS
# version: 24.5
# Toolkit: lucid
# Warning, use updated version of this script in: https://github.com/favadi/build-emacs
set -e