Skip to content

Instantly share code, notes, and snippets.

View MarcioGomes78's full-sized avatar
💻
Focusing

Marcio Gomes MarcioGomes78

💻
Focusing
View GitHub Profile
@adrianoluis
adrianoluis / git-refresh.sh
Last active June 13, 2024 01:51
Update master in all git repo under the provided directory or if missing uses running directory.
#!/bin/sh
GITROOT="${1:-.}"
find $GITROOT -name .git -type d | cat -n | while read n f
do
cd "$(dirname "$f")"
GITDEFBR="$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')"
GITPROJ="$(pwd -P)"
echo "\033[32m>>> \033[1m$GITPROJ\033[0m"
GITBRANCH=$(git rev-parse --abbrev-ref HEAD)
git add .
@adrianoluis
adrianoluis / DocumentUtil.java
Last active May 4, 2024 16:12
Utility class to validate CPF and CNPJ document types. For CPF use isValidSsn and for CNPJ use isValidTfn. Added to repo https://github.com/adrianoluis/misc-tools
public class DocumentUtil {
// CPF
private static final int[] WEIGHT_SSN = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
// CNPJ
private static final int[] WEIGHT_TFN = {6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2};
private static int sum(int[] weight, char[] numbers, int length) {
if (length <= 0) return 0;