Skip to content

Instantly share code, notes, and snippets.

View websterl3o's full-sized avatar

Leonardo Webster. R. Silva websterl3o

View GitHub Profile
@websterl3o
websterl3o / LaravelHelpers.php
Last active May 25, 2023 17:35
LaravelHelpers
<?php
/**
* Return the SQL query with the bindings.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return string
*/
function getSql(Builder $query): string
{
@websterl3o
websterl3o / ConfigurandoAmbiente.md
Last active May 9, 2023 16:01
Configurando Ambiente Like a Boss
@websterl3o
websterl3o / Configurando chave SSH.md
Last active April 5, 2023 14:35
Configurando git

Configurando chave SSH

  • No terminal da maquina execute ssh-keygen -t rsa -b 4096 siga com enter para aceitar os valores padrões.

  • Acessar https://github.com/settings/ssh/new

  • Adicionar um titulo de identificação para a chave

  • Copiar a chave gerada no arquivo ~/.ssh/id_rsa.pub e colar no campo de texto

Terminal Bash, Zsh e Tinker

Otimização de tempo e produtividade


O que é Shell?

Shell é um programa que permite a comunicação entre o usuário e o computador.

{
"editor.fontSize": 18,
"workbench.editor.highlightModifiedTabs": true,
"files.trimFinalNewlines": true,
"editor.fontFamily": "Fira Code",
// "terminal.integrated.fontFamily": "FiraCode Nerd Font",
"terminal.integrated.fontFamily": "MesloLGS NF",
"editor.fontLigatures": true,
"editor.lineHeight": 30,
"workbench.iconTheme": "material-icon-theme",
@websterl3o
websterl3o / laravel_conditional_index_migration.php
Created October 13, 2022 12:34 — forked from Razoxane/laravel_conditional_index_migration.php
Laravel - Create Index If Not Exists / Drop Index If Exists
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class LaravelConditionalIndexMigration extends Migration
{
/**
* Run the migrations.
@websterl3o
websterl3o / Integração com ElasticEmail-Integration with ElasticEmail.php
Created September 29, 2022 11:47
Integração com ElasticEmail/Integration with ElasticEmail PT-BR Esse código é um teste de integração com o ElasticEmail, onde ele verifica o e-mail e retorna se ele é valido. EN This code is an integration test with ElasticEmail, where it checks the email and returns if it is valid.
<?php
use ElasticEmail\Api\VerificationsApi;
use ElasticEmail\Configuration;
// API com elastic email validation https://app.elasticemail.com
$client = new \GuzzleHttp\Client();
$apiKey = '5BD30809F3075185B5F57D0913273A4C65ACC112E0D9DCBBB7670E5F45567D7CBE05AC53B8D1B81F7B073CC5B71C133B';
@websterl3o
websterl3o / Integração com EmailListVerify-Integration with EmailListVerify.php
Created September 29, 2022 11:40
Integração com EmailListVerify/Integration with EmailListVerify - PT-BR Esse código é um teste de integração com o EmailListVerify, onde ele verifica o e-mail e retorna se ele é valido. - EN This code is an integration test with EmailListVerify, where it checks the email and returns if it is valid.
<?php
try {
$listResults = [
'ok', // All is OK. The server is saying that it is ready to receive a letter to,this address, and no tricks have been detected
'error', // The server is saying that delivery failed, but no information about,the email exists
'smtp_error', // The SMTP answer from the server is invalid or the destination server,reported an internal error to us
'smtp_protocol', // The destination server allowed us to connect but the SMTP,session was closed before the email was verified
'unknown_email', // The server said that the delivery failed and that the email address does,not exist
'attempt_rejected', // The delivery failed; the reason is similar to “rejected”
@websterl3o
websterl3o / composer-install-vcs.md
Last active September 28, 2022 19:17 — forked from yidas/composer-install-vcs.md
Instalando pacote do composer via VCS

Instalando pacote do composer via VCS

1. Criar composer.json:

{
    "repositories": [                                             
        {                                                         
            "type": "vcs",                                        
 "url": "https://github.com/name/lib-name"
@websterl3o
websterl3o / TestUnitario.md
Created September 26, 2022 17:41
Como fazer um teste unitário

Pensei muito na melhor forma de fazer um teste unitário de uma funcionalidade "maior" e cheguei a uma ideia de como montar.

Suponto que eu estou trabalhando um serviço de consolidação de comissão, nesse serviço decidimos manter a consolidação de comissão como uma função que faz parte do serviço de comissão, mas para automatizar essa consolidação criamos um comando que executara de tempo em tempo que criara um Job que sera realizado para consolidar a comissão. 

Nessa comissão temos algumas configurações "payment_method", "blocked", "paid_at", "expected_date", "released_at", para criar o Job temos algumas regras, buscamos as comissões pelo metodo de "payment_method", que não esteja "blocked", que esteja "paid_at", que não esteja "released_at" e que a data "expected_date" seja menor ou igual a atual.

Esse job para consolidar a comissão precisa verificar se a comissão está "blocked", pois existem outros eventos que podem ocorrer que deixem a comissão bloqueado e comparar o dia atual com a data de pagamentos pa