Skip to content

Instantly share code, notes, and snippets.

View fabiolimace's full-sized avatar

Fabio Lima fabiolimace

View GitHub Profile
@fabiolimace
fabiolimace / uuid_colorizer.awk
Last active June 11, 2024 18:38
UUID colorizer on Linux terminal
#!/usr/bin/awk -f
# Usage:
#
# while true; do echo -e $(uuidgen --time | awk -f uuid_colorizer.awk); sleep 0.1; done;
#
BEGIN {
FS=""
@fabiolimace
fabiolimace / github-stars-job.sh
Last active June 1, 2024 11:03
Github Stars Job
#!/bin/bash
#
# Job que atualiza diariamente series temporais de estrelas de repositorios do Github.
#
# Resumo do que este programa faz:
# 1. Os historicos das estrelas sao guardado nos arquivos *.log. Nunca os apague, pois assim perderá o histórico para sempre.
# 2. As estatisticas sao calculadas a partir dos historicos e guardadas nos arquivos *.tsv.
# 3. Os graficos gerados a partir das estatisticas sao guardadas nos arquivos *.png.
# 4. O email eh gerado e enviado com os arquivos *.log, *.tsv e *.png anexados.
#
@fabiolimace
fabiolimace / compose-email.sh
Last active June 1, 2024 05:29
Email composer for Linux command line
#!/bin/bash
#
# Email composer.
#
# Parameters:
# $1: headers in a text file
# $2: body in a text or html file
# $3-$n: optional attachments
#
# Usage:
@fabiolimace
fabiolimace / find-home-directory.sh
Last active May 31, 2024 04:46
Find home directory
#!/usr/bin/bash
#
# Find the home directory for a user name.
#
# If the current user is root, home direcory is /root, else /home/user.
#
# This is useful for cron jobs when you dont have access to ENV variables such as $HOME.
#
# declaring the variable `$home`
@fabiolimace
fabiolimace / github-stars.sh
Last active May 31, 2024 07:29
Wget Github stars of a repository
#!/usr/bin/bash
#
# Get the stars count of a Github repository
#
# Usage:
#
# github-stars https://github.com/user/repo
#
function github_stars {
@fabiolimace
fabiolimace / s3fs.service
Created May 17, 2024 09:33 — forked from klutchell/s3fs.service
systemd unit file for s3fs fuse auto-mount
Description=S3FS FUSE mount
Documentation=https://github.com/s3fs-fuse/s3fs-fuse
Wants=network-online.target
After=network-online.target
AssertPathIsDirectory=/mnt/s3fs
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/s3fs mybucket:/bucketdir /mnt/s3fs -o url=https://nyc3.digitaloceanspaces.com -o use_cache=/tmp -o allow_other -o use_path_request_style -o uid=1000 -o gid=1000
@fabiolimace
fabiolimace / converter-para-csv.sh
Last active June 7, 2024 14:26
Converter planilha para CSV usando o libreoffice
#!/usr/bin/bash
#
# Converte um ou mais arquivos denominados INPUT_FILE para CSV.
#
# O primeiro arquivo informado na linha de comando eh o OUTPUT_FILE; todos os outros sao INPUT_FILE.
#
# Os arquivos INPUT_FILE devem estar num destes formatos: ODS, XLS ou XSLX.
#
# Se houver mais de um arquivo INPUT_FILE, estes serao combinados para formar um unico arquivo OUTPUT_FILE.
#
@fabiolimace
fabiolimace / N-gramas com acentuação.md
Created May 8, 2024 04:16
N-gramas do português brasileiro com acentuação

N-gramas com acentuação

cat /usr/share/dict/brazilian | sort | uniq | sed -E 's/^/_/;s/$/_/' | grep -E --only-matching '[a-z_][àáâãéêíóôõúüç]|[àáâãéêíóôõúüç][a-z_]' | sort | uniq -c | sort -h | wc -l
291
cat /usr/share/dict/brazilian | sort | uniq | sed -E 's/^/_/;s/$/_/' | grep -E --only-matching '[a-z_][àáâãéêíóôõúüç][a-z_]' | sort | uniq -c | sort -h | wc -l
@fabiolimace
fabiolimace / install-scripts.sh
Last active May 6, 2024 14:46
Install scripts in `/usr/local/bin`
#!/usr/bin/bash
#
# Install script files located in /usr/local/bin/scripts into /usr/local/bin
#
# First, put the scripts you want to install inside /usr/local/bin/scripts; then run this script.
#
# The script will look for files with these extensions: awk, py, sh.
#
bin=/usr/local/bin;
@fabiolimace
fabiolimace / temperature.sh
Created April 28, 2024 23:22
Get current temperature
# https://askubuntu.com/questions/15832/how-do-i-get-the-cpu-temperature
paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) \
| column -s $'\t' -t \
| sed 's/\(.\)..$/.\1°C/'