Skip to content

Instantly share code, notes, and snippets.

View renatoassis01's full-sized avatar
🏠
Working from home 🇧🇷

Renato Assis renatoassis01

🏠
Working from home 🇧🇷
View GitHub Profile
@renatoassis01
renatoassis01 / date.ts
Last active March 23, 2022 02:55
seconds to time total moment
export function SecondsToTimeTotal(seconds: number): string {
const NINE_HOURS_IN_SECONDS = 32400;
const ms = seconds * 1000;
if (seconds < 3600) return moment.utc(ms).format('HH:mm');
const hours = Math.floor(moment.duration(ms).asHours());
if (seconds <= NINE_HOURS_IN_SECONDS)
return `0${hours}:${moment.utc(ms).format('mm')}`;
@renatoassis01
renatoassis01 / municipios.sh
Created January 22, 2022 17:02
json com todos os municípios brasileiros
#! /bin/bash
curl -s https://servicodados.ibge.gov.br/api/v1/localidades/municipios\?orderBy\=nome | jq '.[] | {id: .id, name: .nome, uf: .microrregiao.mesorregiao.UF.sigla}' | jq -s
#backup table
pg_dump -h hostname -d <database_name> -t <table_name> > file.sql
pg_dump --no-owner -d <database_name> -t <table_name> > file.sql
#backup table only data
pg_dump --data-only -h hostname -d <database_name> -t <table_name> > file.sql
#backup all data
pg_dump --dbname=authservice --data-only --file=/path/to/file.sql --username= --host= --port=5432
#! /bin/bash
set -euo pipefail
VERSION="1.16"
export GOROOT="$HOME/.go"
export GOPATH="$HOME/workspace/go"
ARCH="$(uname -m)"
#! /bin/bash
set -euo pipefail
echo -e "Downloading Nerd Fonts from https://github.com/ryanoasis/nerd-fonts"
mkdir -p $HOME/.local/share/fonts
TEMP_DIR_DOWNLOAD_FONTS=$(mktemp -d)
cd $TEMP_DIR_DOWNLOAD_FONTS
VERSION_RELEASE=v2.1.0
@renatoassis01
renatoassis01 / matrix.sh
Created April 9, 2021 23:07
matrix for bash
# Matrix of this post: https://twitter.com/climagic/status/1380542449861427202
#!/usr/bin/env bash
while :; do
LINES=$(tput lines) COLUMNS=$(tput cols)
echo $LINES $COLUMNS $[RANDOM%COLUMNS] $(printf "\U$[ RANDOM%500]")
sleep 0.05
done | gawk '{c=$4; l=$4;a[$3]=0;for (x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH\033[2;32m%s",o,x,l;printf "\033[%s;%sH\033[1;37m%s\033[0;0H",a[x],x,l;if(a[x]>=$1){a[x]=0;}}}'
@renatoassis01
renatoassis01 / gist:3d5bea6c17bda9d83aafb19339f93fbd
Created November 10, 2020 23:50
delete all tags remote and local
#Delete local tags.
git tag -d $(git tag -l)
#Fetch remote tags.
git fetch
#Delete remote tags.
git push origin --delete $(git tag -l) # Pushing once should be faster than multiple times
#Delete local tags.
git tag -d $(git tag -l)

rename extension in batch

for x in *.webp; do mv "$x" "${x%.webp}.png"; done
@renatoassis01
renatoassis01 / dicasgit.md
Last active January 24, 2022 14:43
dicas deu ruim e dicas gerais sobre o git

Renomeando o branch local

git branch -m novo_nome

Renomeando o branch remoto

    git push origin -u novo_nome
    git push origin --delete velho_nome
@renatoassis01
renatoassis01 / Update remote repo
Created June 8, 2020 19:07 — forked from mandiwise/Update remote repo
Transfer repo from Bitbucket to Github
// Reference: http://www.blackdogfoundry.com/blog/moving-repository-from-bitbucket-to-github/
// See also: http://www.paulund.co.uk/change-url-of-git-repository
$ cd $HOME/Code/repo-directory
$ git remote rename origin bitbucket
$ git remote add origin https://github.com/mandiwise/awesome-new-repo.git
$ git push origin master
$ git remote rm bitbucket