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 / BazilMajorTimezone.php
Created November 9, 2020 08:02
What time is it in (the majority of) Brazil?
<?php
/**
* NOTICE: Consider the current version of the laguage (currently 7.4.12) when executing,
* since it may give you a wrong offset when uding older versions.
*/
$now = new DateTime();
$now->setTimezone(new DateTimeZone('America/Sao_Paulo'));
echo $now->format('Y-m-d H:i');
@galvao
galvao / clear-doctrine-cache.sh
Created October 28, 2020 14:12
Clears Doctrine's DDL Cache and rebuilds the schema
# Limpar o cache de DDL do Doctrine
php ./vendor/doctrine/doctrine-module/bin/doctrine-module orm:clear-cache:metadata
php ./vendor/doctrine/doctrine-module/bin/doctrine-module orm:schema-tool:update --force
@galvao
galvao / init.vim
Created October 6, 2020 10:29
tmp init.vim
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" .vimrc - Vim/GVim Configuration File
"
" Er Galvão Abbott - https://github.com/galvao/dotfiles
"
" Official docs @ http://vimdoc.sourceforge.net/htmldoc/usr_toc.html
"
" Many thanks to Matthew Weier O'Phinney for his articles about it:
" - https://mwop.net/blog/249-vim-toolbox-2010-edition.html
@galvao
galvao / countdown.php
Created June 10, 2020 21:46
Shows how many days are left to a date
<?php
$now = new DateTime();
$then = new DateTime($_SERVER['argv'][1]);
$interval = $now->diff($then);
echo $interval->format('%a');
@galvao
galvao / parOuImpar.js
Created April 25, 2020 20:32
Exemplo JS - Par ou ímpar (Aula 9, TargetTrust)
botoes = document.querySelectorAll('button');
elementoJj = document.querySelector('#jj');
elementoJc = document.querySelector('#jc');
elementoS = document.querySelector('#s');
elementoR = document.querySelector('#r');
botoes.forEach(function (botaoAtual) {
botaoAtual.addEventListener('click', function () {
jogador = parseInt(this.innerHTML);
@galvao
galvao / soCalledConstants.js
Created April 13, 2020 05:50
JavaScript's isue with "constants"(sic)
const FOO = 2;
const BAR = {"c": 42};
const BAZ = [12, 14];
BAR.e = 43;
console.log(BAR);
BAZ.push(16);
console.log(BAZ);
/**
@galvao
galvao / correcao.php
Created September 26, 2019 13:37
Correção: ProdutoController
public function cadastrarAction()
{
$requisicao = $this->getRequest();
if ($requisicao->isPost()) {
$dados = $requisicao->getPost();
$model = new Produto();
$model->exchangeArray($dados);
@galvao
galvao / PG_fetchEntities.sql
Created August 21, 2019 07:03
Fetch PostgreSQL entities with column information
SELECT
ordinal_position,
table_name,
column_name,
data_type,
character_maximum_length,
numeric_precision,
numeric_precision_radix,
numeric_scale
FROM
@galvao
galvao / transition0.css
Created August 17, 2019 10:13
Simples CSS Transition example
span {
border: 1px solid #000;
padding: 0;
background-color: #fff;
color: #000;
transition-property: padding, color, background-color;
transition-duration: 1s;
}
span:hover {
@galvao
galvao / palindrome.php
Last active February 3, 2020 01:43
isPalindromic - A function to determine if a string is or isn't a palindrome.
<?php declare(strict_types = 1);
/**
* isPalindromic - A function to determine if a string is or isn't a palindrome.
* Made for the AT sitepointdotcom challenge on Twitter .
*
* This function purposefully ignores the fact that PHP has a function that
* reverses a string, therefore making it trivial to solve the issue by
* just using $str === strrev($str).
*