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
<?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);
@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',
@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);
<?php
$items = [];
foreach ($products as $value) {
$items[] = [
'product_id' => $value->id,
'name' => $value->name,
];
}
return collect($items)->all();
@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,
<!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>
@millermedeiros
millermedeiros / .htaccess
Created June 11, 2012 13:34
basic htaccess for perf
DirectoryIndex index.html index.htm index.php
ErrorDocument 404 /404
# Block directory listing
Options -Indexes
# === URL Rewrite === #
# Map all URIs except those corresponding to existing files/folders to the handler
RewriteEngine on
@kelvinst
kelvinst / git-sweep.md
Last active February 22, 2022 01:02
Limpando os branches que você já fez merge

Limpando os branches que você já fez merge

Olá!

Bem, muitas vezes no dia-a-dia com o git, você abre um branch para a feature, termina, faz merge na master e pronto! Está entregue. O problema é que com isso, seu git fica cheio de branches que são, digamos: INÚTEIS. E claro que com o tempo esses branches se reproduzem como coelhos.

Como fazer para apagar todos esses branches? Você deve ter percebido que apenas um git branch -D meu-branch só apaga o branch no seu computador, e em nenhum remote.

Fácil, é só fazer o código git push origin :meu-branch, que além de ser nem um pouco claro (WTF?), te obriga a fazer isso um a um. Se forem muitos branches, babau!

@marcelod
marcelod / RemoveBranchsLocais.md
Last active August 29, 2022 20:55
Remove branchs locais que já foram enviadas para master (main)