Skip to content

Instantly share code, notes, and snippets.

View trepichio's full-sized avatar
🧠
Talk is cheap. Show me the code!

João Trepichio trepichio

🧠
Talk is cheap. Show me the code!
View GitHub Profile
@trepichio
trepichio / GitApplyOnlyFileFromStash.md
Last active January 9, 2021 20:00
Apply only a file from a stash

Apply only one file from Git Stash

  git checkout 'stash@{ID}' -- path/to/filename.js

ID is the number of desired stash

@trepichio
trepichio / pushBranchToNewRepo.md
Last active January 21, 2022 03:40
Pushes a branch to its own GitHub repository

Push a Git Branch to a NEW repository

cd to the old repo directory and then

$ git push https://github.com/trepichio/<newRepository>.git +theBranchIwant:master
@trepichio
trepichio / howToChangeGitMessages.md
Last active January 9, 2021 21:10
How to change your commit messages in Git?

How to change your commit messages in Git?

At some point you’ll find yourself in a situation where you need edit a commit message. That commit might already be pushed or not, be the most recent or burried below 10 other commits, but fear not, git has your back 🙂.

Not pushed + most recent commit:

$ git commit --amend

This will open your $EDITOR and let you change the message. Continue with your usual git push origin master.

@trepichio
trepichio / gitDeleteBranches.md
Last active January 9, 2021 21:18
Delete local and remote branches

GIT

Delete local branch

$ git branch -D <branch-name>

Delete remote branch

$ git push origin :<bad-branch-name>
@trepichio
trepichio / mysql-create.md
Last active January 9, 2021 21:19
Create MySQL command
$   mysql -uroot -p

$   CREATE DATABASE nomeapp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

$   CREATE USER 'admin-nomeapp'@'localhost' identified by 'admin-nomeapp';

$   use nomeapp

$ GRANT ALL on nomeapp.* to 'admin-nomeapp'@'localhost';
@trepichio
trepichio / laravel-cors.md
Last active January 9, 2021 21:09
Laravel CORS

Enable CORS so you can access your API (Laravel) from the frontend application:

Install this package:

$ composer require barryvdh/laravel-cors`

Then, add these middlewares:

app/Http/Kernel.php
@trepichio
trepichio / phpunit.txt
Last active March 26, 2020 03:47
Setup TDD LARAVEL PHPUnit
=== TERMINAL ===== ATALHOS PARA RODAR TESTES:
alias pu = 'clear && vendor\bin\phpunit'
alias pf = 'clear && vendor\bin\phpunit --filter'
EM UMA FEATURE TEST, para evitar que o PHP encapsule as exceções ADICIONAR:
$this->withoutExceptionHandling();
@trepichio
trepichio / .gitconfig
Created March 29, 2020 05:45
VSCODE DIFF TOOL COMPARE
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
[merge]
tool = vscode
[mergetool "vscode"]
cmd = code --wait $MERGED
@trepichio
trepichio / soa_repositories_and_services.md
Last active January 9, 2021 20:34
SOA Repositories and Services

Entities: The standard models in Laravel, containing just configuration variables and methods to be used by Eloquent. Relationships, accessors and mutators belong here.

Repositories: Using Entities to get your data, they contain functions to gather specific sets of data in specific formats for your app. Though the logic in them might change, the returned data should always be exactly the same.

Services: The home of global logic, containing functions that are used throughout your app. It calls your Repositories but also validates, creates sessions and contains your logic. These all help to keep your controllers thin!

  1. Create and follow this structure:
@trepichio
trepichio / multiple_remote_git.md
Last active January 9, 2021 21:20
GIT: Sync multiple remote

Add remote 1: e.g. GitHub.

$ git remote add origin git@github.com:trepichio/algo.git

Add remote 2: e.g. BitBucket.

$ git remote add upstream git@bitbucket.org:trepichio/algo.git