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
@ainsofs
ainsofs / gist:2b80771a5582b7528d9e
Created April 16, 2015 01:50
Clear .gitignore cache
# remove specific file from git cache
git rm --cached filename
# remove all files from git cache
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
@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
@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);
  } 
@drewjoh
drewjoh / custom.js
Created January 27, 2012 13:55
Dynamic (AJAX) loaded Bootstrap Modal (Bootstrap 2.1)
$(document).ready(function() {
// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
if (url.indexOf('#') == 0) {
$(url).modal('open');
} else {
@marcelod
marcelod / RemoveBranchsLocais.md
Last active August 29, 2022 20:55
Remove branchs locais que já foram enviadas para master (main)
@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!

@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
<!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>
<!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">
@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,