Skip to content

Instantly share code, notes, and snippets.

View xthiago's full-sized avatar

Thiago Rodrigues (xthiago) xthiago

View GitHub Profile
git branch -r --merged | egrep -v '(master|main|release|development)' | sed 's/origin\///' | xargs -n 1 git push --delete origin
sudo apt install gedit
cd /tmp/
wget https://download.jetbrains.com/webide/PhpStorm-2021.2.3.tar.gz
tar -zxvf PhpStorm-2021.2.3.tar.gz
mkdir ~/Apps
mv PhpStorm-212.5457.49/ ~/Apps/
ln -s ~/Apps/PhpStorm-212.5457.49 ~/Apps/phpstorm
# shortcut
vim jetbrains-phpstorm.desktop
@xthiago
xthiago / estados-brasileiros.php
Last active June 18, 2021 05:16
Array PHP com estados brasileiros
<?
$estados = array(
array("sigla" => "AC", "nome" => "Acre"),
array("sigla" => "AL", "nome" => "Alagoas"),
array("sigla" => "AM", "nome" => "Amazonas"),
array("sigla" => "AP", "nome" => "Amapá"),
array("sigla" => "BA", "nome" => "Bahia"),
array("sigla" => "CE", "nome" => "Ceará"),
array("sigla" => "DF", "nome" => "Distrito Federal"),
array("sigla" => "ES", "nome" => "Espírito Santo"),
@xthiago
xthiago / SymfonyKernel.php
Created April 13, 2021 16:55 — forked from jakzal/SymfonyKernel.php
Replacement for Symfony's KernelTestCase
<?php
declare(strict_types=1);
namespace Zalas\PHPUnit\Injector\Symfony\TestCase;
use Symfony\Component\DependencyInjection\ResettableContainerInterface;
use Symfony\Component\HttpKernel\KernelInterface;
/**
* Mimics the behaviour of Symfony's KernelTestCase.
@xthiago
xthiago / testes-com-id.md
Last active December 29, 2020 18:17
Testes com ID

Tem uns testes aqui que acredito que a legibilidade seria muito melhor se tivéssemos uma comparação de strings entre a resposta esperada e a efetiva:

// [..] setup dos dados
$firstPage = actionToFetchFirstPage();
$expectedFirstPage = <<<EOL
{
    "data":[
        {
            "name":"xthiago",
@xthiago
xthiago / Approach 01 - rely on a third-party service.md
Last active July 16, 2019 19:37
Alternatives to test classes that rely on system time.

Value object that depends on system time:

<?php

declare(strict_types=1);

namespace Xthiago;

final class BirthDate
@xthiago
xthiago / global-gitignore.md
Created February 13, 2018 01:02 — forked from subfuzion/global-gitignore.md
Global gitignore

There are certain files created by particular editors, IDEs, operating systems, etc., that do not belong in a repository. But adding system-specific files to the repo's .gitignore is considered a poor practice. This file should only exclude files and directories that are a part of the package that should not be versioned (such as the node_modules directory) as well as files that are generated (and regenerated) as artifacts of a build process.

All other files should be in your own global gitignore file. Create a file called .gitignore in your home directory and add anything you want to ignore. You then need to tell git where your global gitignore file is.

Mac

git config --global core.excludesfile ~/.gitignore

Windows

git config --global core.excludesfile %USERPROFILE%\.gitignore
@xthiago
xthiago / move-git-repository-to-a-new-remote-repository.md
Created February 12, 2018 23:08
Moving git repository and all its branches, tags to a new remote repository keeping commits history

Moving git repository and all its branches, tags to a new remote repository keeping commits history

git clone --mirror ORIGINAL-REPOSITORY-URL DIRECTORY-NAME
cd DIRECTORY-NAME
git remote add NEW-REMOTE NEW-REPOSITORY-URL
git push  NEW-REMOTE --mirror
@xthiago
xthiago / PhoneConstraintValidator.php
Last active December 5, 2017 18:55
Integrating Value Object validation with custom Constraint of Symfony Validator
<?php
declare(strict_types = 1);
namespace Xthiago\Infrastructure\Validation\SymfonyValidator\Constraints;
use Xthiago\Domain\Model\PhoneNumber\PhoneNumber;
use Xthiago\Domain\Model\PhoneNumber\InvalidPhoneNumberException;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
@xthiago
xthiago / git-tag-delete-local-and-remote.sh
Created December 5, 2017 15:00 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName