Skip to content

Instantly share code, notes, and snippets.

View juliobitencourt's full-sized avatar

Julio Bitencourt juliobitencourt

View GitHub Profile
@barryvdh
barryvdh / HttpClientEventsMiddleware.php
Created September 7, 2021 12:52
Middleware to log Guzzle requests with Telescope
<?php
namespace App\Http\Client;
use GuzzleHttp\Promise;
use Illuminate\Http\Client\Events\ConnectionFailed;
use Illuminate\Http\Client\Events\RequestSending;
use Illuminate\Http\Client\Events\ResponseReceived;
use Illuminate\Http\Client\Request;
use Illuminate\Http\Client\Response;
@alexandreservian
alexandreservian / regex.md
Last active March 25, 2024 15:48
Metacaracteres Regex

Representantes

Meta Nome Função
. ponto um caractere qualquer
[] conjunto conjunto de caracteres permitidos
[^] conjunto negado conjunto de caracteres proibidos

Quantificadores

@davidalves1
davidalves1 / formatar_cnpj_cpf.md
Last active January 24, 2024 21:06
Função para formatar CNPJ e CPF, disponível em PHP e JS

PHP

function formatCnpjCpf($value)
{
  $CPF_LENGTH = 11;
  $cnpj_cpf = preg_replace("/\D/", '', $value);
  
  if (strlen($cnpj_cpf) === $CPF_LENGTH) {
    return preg_replace("/(\d{3})(\d{3})(\d{3})(\d{2})/", "\$1.\$2.\$3-\$4", $cnpj_cpf);
  } 
@martinbean
martinbean / pre-commit
Last active December 19, 2023 22:14
Pre-commit hook to detect if any .php files contain dd()
#!/usr/bin/php
<?php
$files = shell_exec('git diff-index --name-only --cached --diff-filter=ACMR HEAD | grep "\.php$"');
$files = explode("\n", trim($files));
$exitCode = 0;
foreach ($files as $file) {
if (empty($file)) {
@wowo
wowo / pre-commit
Last active August 29, 2015 14:24
Basic pre-commit git hook
#!/bin/bash
exec < /dev/tty
phpunit
rc=$?
if [[ $rc != 0 ]] ; then
echo -n "It looks like some of your tests failed. "
exit $rc;
fi
@butlerblog
butlerblog / wp_config.php
Last active February 1, 2024 09:00
Configure WordPress #wp_mail function to send through #SMTP server https://b.utler.co/Y3
<?php
/*
* Set the following constants in wp-config.php.
* These should be added somewhere BEFORE the constant ABSPATH is defined.
*
* Author: Chad Butler
* Author URI: https://butlerblog.com
*
* For more information and instructions, see: https://b.utler.co/Y3
@andreoav
andreoav / Contributing.md
Last active August 29, 2015 14:16
Contributing.md

Sobre

Somos uma comunidade brasileira que tem como objetivo principal promover o desenvolvimento de pacotes PHP, inicialmente voltados para o framework Laravel, que sigam diretrizes sólidas de desenvolvimento, resultando em pacotes confiáveis, padronizados e totalmente testados.


Guia de Desenvolvimento

@erikhenrique
erikhenrique / bin-cc.md
Last active February 5, 2024 16:06
Bin de cartões de crédito para validação

Validação para cartão de crédito.

Bin e padrões para validação de cartão de crédito.

Bandeira Começa com Máximo de número Máximo de número cvc
Visa 4 13,16 3
Mastercard 5 16 3
@rmurphey
rmurphey / pubsub-demo.js
Created October 26, 2010 04:59
JS for pubsub screencast
/* traditional way */
(function($) {
$(document).ready(function() {
$('#searchForm').submit(function(e) {
var term = $.trim($(this).find('input[name="q"]').val());
if (!term) { return; }
$.getJSON(