Skip to content

Instantly share code, notes, and snippets.

View galvao's full-sized avatar
😎
Rocking to the rythm of the sure shot beat

Er Galvão Abbott galvao

😎
Rocking to the rythm of the sure shot beat
View GitHub Profile
@galvao
galvao / setup_sodium.sh
Last active February 19, 2018 23:03
Fixing F27 to install php-sodium
sudo dnf config-manager --add-repo /etc/yum.repos.d/remi.repo && \
sudo dnf config-manager --set-enabled remi &&\
sudo dnf -y install php-sodium
@galvao
galvao / magrathea-update.sh
Created January 28, 2018 19:07
Automatically updates my dev notebook
#! /usr/bin/bash
magrathea-offline &&\
sudo dnf -y update &&\
composer self-update &&\
composer global update &&\
cd ~/.vim/bundle &&\
for v in `ls`; do
cd "$v"
git pull
@galvao
galvao / dump_nodata.sh
Created November 13, 2017 23:25
mysql_dump - structure only
mysqldump --no-data --host=your_host --user=your_user --password=your_pass --result-file=dump_file.sql --routines your_db
throw new Error('Por favor poste o seu código em uma ferramenta apropriada para isso, como Gist ou Pastebin');
@galvao
galvao / grepSec.sh
Created September 4, 2017 21:21
Searches PHP files (excluding the data and vendor subfolders) for external data related superglobals
grep -EnoHR --exclude-dir={data,vendor} "_GET|_POST|_REQUEST|_SESSION|_COOKIE" *.php|more
@galvao
galvao / dom_onchange.js
Created August 19, 2017 10:07
DOM filtering a combobox/adding an onchange event
document.querySelector('select').addEventListener('change', function () {
// In this example, calling a custom AJAX function I was testing
r = makeRequest('get', 'foo.php', true);
});
@galvao
galvao / void.php
Created July 3, 2017 14:56
For my post on PHP 7.1 and 7.2
<?php
declare(strict_types = 1);
function foo():void
{
}
@galvao
galvao / NULLable.php
Created July 3, 2017 14:44
Gist for my post about PHP 7.1 and 7.2
<?php
declare(strict_types = 1);
function foo(?string $bar, int $baz = NULL)
{
}
@galvao
galvao / User.php
Last active June 12, 2017 06:10
Setter for a user role (example for my Medium article about sessions and security)
<?php
declare(strict_types = 1);
class User
{
private $roleID; // since uninitialized it's value remains NULL
// Rest of the class
// Session object is injected for the purposes of this example
@galvao
galvao / guzzle_moip.php
Created May 7, 2017 19:43
Conectando e criando um pedido com boleto no MOIP com PHP + Guzzle
<?php
require_once '../vendor/autoload.php';
use GuzzleHttp\Client;
define('MOIP_TOKEN', 'SEUTOKENDEACESSO');
define('MOIP_AUTH_KEY', 'SUACHAVEDEACESSO');
// Específico do MOIP
define('AUTH_STR', MOIP_TOKEN . ':' . MOIP_AUTH_KEY);
// Específico do MOIP