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 / ignoreChmod.sh
Created March 3, 2021 11:26
Git|: Ignoring chmod-changes on files
# Add the -c flag and set the core.fileMode option to false, e.g.:
git -c core.fileMode=false status
@galvao
galvao / datetimeimmutable.php
Created December 11, 2020 12:56
DateTimeImmutable example
<?php
$now = new DateTime();
$freeze = new DateTimeImmutable();
$now->setTimeZone(new DateTimeZone('UTC'));
$freeze->setTimeZone(new DateTimeZone('UTC'));
echo $now->format('Y-m-d H:i:s P');
// 2020-12-11 12:50:48 +00:00
$freeze->format('Y-m-d H:i:s P');
// 2020-12-11 09:50:51 -03:00
@galvao
galvao / promise.js
Created November 11, 2020 23:31
A simple example of Promises in JavaScript
console.clear();
function oddOrEven(n)
{
return new Promise((resolve, reject) => {
if (typeof(n) != 'number') {
reject(new TypeError('n must be a number'));
}
if ((n % 2) == 0) {
@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);