Skip to content

Instantly share code, notes, and snippets.

View marcelod's full-sized avatar
🎯
Focusing

Marcelo Diniz marcelod

🎯
Focusing
  • São Paulo - Brasil
View GitHub Profile
@marcelod
marcelod / RemoveBranchsLocais.md
Last active August 29, 2022 20:55
Remove branchs locais que já foram enviadas para master (main)
<?php
$items = [];
foreach ($products as $value) {
$items[] = [
'product_id' => $value->id,
'name' => $value->name,
];
}
return collect($items)->all();
<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>jsPDF</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cidade por Estado</title>
</head>
<body>
<select name="estados" id="estados"></select>
@programadorabordo
programadorabordo / reduce-everywhere.js
Created July 30, 2020 15:33
Todo código gerado na aula ao vivo do quadro JS Day https://youtu.be/BBFvqb6Y43s
const numeros = [5, 12, 30, 10, 99, 4];
/*
Soma total
*/
const valorSomaTotal = numeros.reduce(function (acumulador, valorAtual) {
return acumulador + valorAtual;
}, 0);
console.log('valorSomaTotal', valorSomaTotal);
@comficker
comficker / HEX2RGB.js
Created June 6, 2018 01:16
Bellow are javascript code can convert hex to rgb color. Demo: http://aiconverter.com/color/hex-to-rgb
function HEX2RGB (hex) {
"use strict";
if (hex.charAt(0) === '#') {
hex = hex.substr(1);
}
if ((hex.length < 2) || (hex.length > 6)) {
return false;
}
var values = hex.split(''),
r,
@grimzy
grimzy / git-pull-all
Created September 15, 2017 02:15
Git pull all remote branches
#!/usr/bin/env bash
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
<?php
/**
* @param string $string
* @param array $avoid (['de', 'da', 'a', 'e', 'o'])
* @return string
*/
function initials(string $string, array $avoid = null): string
{
$words = preg_split("/\s+/", $string);
@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);
  } 
@henriquemoody
henriquemoody / br-cities.php
Last active June 1, 2020 12:50
Lista de cidades brasileiras com base nos dados o IBGE
<?php
return [
// http://www.cidades.ibge.gov.br/download/mapa_e_municipios.php?uf=ac (Thu May 14 16:30:15 BRT 2015)
'AC' => [
1200013 => 'Acrelândia',
1200054 => 'Assis Brasil',
1200104 => 'Brasiléia',
1200138 => 'Bujari',
1200179 => 'Capixaba',