Skip to content

Instantly share code, notes, and snippets.

View fabiolimace's full-sized avatar

Fabio Lima fabiolimace

View GitHub Profile
@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-planilha.sh
Created May 9, 2024 20:10
Converter planilha para CSV usando o libreoffice
#!/usr/bin/bash
#
# Converts a spredsheet to a CSV file.
#
# Usage:
#
# converter-planilha.sh FILE.ods [csv]
#
# Install the dependencies:
#
@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/'
@fabiolimace
fabiolimace / record-system-output-audio.sh
Last active April 20, 2024 08:06
Record system output audio with FFMPEG on Ubuntu Linux
#!/usr/bin/bash
#
# Records the oudio from your browser and other applications.
#
# USAGE:
#
# record-system-output-audio.sh DURATION
#
# Where DURATION is [<HH>:]<MM>:<SS> or <SS>[s] (read ffmpeg-utils manual)
#
@fabiolimace
fabiolimace / snowflake-id.sql
Created April 18, 2024 20:13 — forked from beginor/snowflake-id.sql
Twitter Snowflake ID for PostgreSQL
CREATE SEQUENCE public.global_id_seq;
ALTER SEQUENCE public.global_id_seq OWNER TO postgres;
CREATE OR REPLACE FUNCTION public.id_generator()
RETURNS bigint
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
@fabiolimace
fabiolimace / block-site-add.sh
Last active April 11, 2024 01:38
Block sites in /etc/hosts
#!/usr/bin/bash
#
# Removes a block to /etc/hosts.
#
# USAGE:
#
# $ block-site-add.sh EXAMPLE.COM
# 0.0.0.0 example.com
# 0.0.0.0 www.example.com
#
@fabiolimace
fabiolimace / Entity.java
Last active April 3, 2024 20:36 — forked from rajivrnair/Entity.java
Custom Hibernate UUID Generator
// Before
@Id
@Column(name = "entity_id")
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
private String entityId;
// After
@Id
@Column(name = "entity_id")
@fabiolimace
fabiolimace / Id.java
Last active March 2, 2024 02:45
Strongly Typed Identifier using ULID Creator
package com.example.idapi;
import java.util.Objects;
import com.github.f4b6a3.ulid.Ulid;
import com.github.f4b6a3.ulid.UlidCreator;
public abstract class Id<T extends Id<T>> implements Comparable<T> {
protected final Ulid value;