Skip to content

Instantly share code, notes, and snippets.

View fabiolimace's full-sized avatar

Fabio Lima fabiolimace

View GitHub Profile
@fabiolimace
fabiolimace / ThreadLocalWeakRefTest.java
Created December 14, 2023 23:09 — forked from chrisvest/ThreadLocalWeakRefTest.java
ThreadLocals and weak references
import org.junit.Test;
import java.lang.ref.WeakReference;
import static org.junit.Assert.assertNull;
public class ThreadLocalWeakRefTest {
/**
* Many Java web servers and containers go out of their way to find and null
* out ThreadLocals that an application might have created. Question is, is
@fabiolimace
fabiolimace / list-mixed-tokens.awk
Created December 9, 2023 13:52
List fixed tokens of a file, those which are not alpnanumeric only
#!/usr/bin/gawk -f
NF {
for (i = 1; i <= NF; i++) {
if ( $i !~ /^[[:alnum:]]+$/ ) {
print $i;
}
}
}
@fabiolimace
fabiolimace / uuid.js
Last active December 8, 2023 00:23
No Dependency / Do It Yourself / You Know What You Are Doing UUID generator for Javascript
const v4 = () => {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.trunc(Math.random() * 16);
const v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
const v7 = () => {
return 'tttttttt-tttt-7xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
@fabiolimace
fabiolimace / markdown-flavors.md
Created November 25, 2023 23:29 — forked from vimtaai/markdown-flavors.md
Comparison of features in various Markdown flavors

Comparison of syntax extensions in Markdown flavors

I created a crude comparison of the syntax of the various common Markdown extensions to have a better view on what are the most common extensions and what is the most widely accepted syntax for them. The list of Markdown flavors that I looked at was based on the list found on CommonMark's GitHub Wiki.

Flavor Superscript Subscript Deletion*
Strikethrough
Insertion* Highlight* Footnote Task list Table Abbr Deflist Smart typo TOC Math Math Block Mermaid
GFM
@fabiolimace
fabiolimace / baixar_ebooks_comprados_amazon.json
Last active November 26, 2023 03:35
Robô que baixa todos os ebooks comprados na Amazon, usando a extensão do Firefox "UI.Vision RPA" v6.2.6. Foi usado para baixar 4010 livros da coleção pessoal, trabalho manual absurdamente inviável, em cerca de 10h, com apenas 3 erros (não localizou o botão de fechar o diálogo).
{
"Name": "Amazon",
"CreationDate": "2023-11-25",
"Commands": [
{
"Command": "comment",
"Target": "store // slow",
"Value": "!replayspeed",
"Description": "Não queremos ser rápidos (fast=0s, medium=0.3s, slow=2s)"
},
@fabiolimace
fabiolimace / iso8859-to-ascii.awk
Created November 19, 2023 17:07
ISO-8859-1 to ASCII using AWK
// {
# WINDOWS-1252 Charset
gsub(/\x80/,"EUR", $0);
gsub(/\x81/,"\x1A", $0);
gsub(/\x82/,"'", $0);
gsub(/\x83/,"f", $0);
gsub(/\x84/,"\"", $0);
gsub(/\x85/,"...", $0);
@fabiolimace
fabiolimace / number-regex.sh
Last active November 20, 2023 08:02
Expressões regulares para tokens formados por dígitos misturados com caracteres de pontuação
# ###
# Extrair todos tokens que contém dígitos e pontos
# ###
grep -E --color=auto -r -o --no-filename " ([[:punct:]]?[[:digit:]][[:punct:]]?)+ " */ | tee ~/digit-punct.txt
sort digit-punct.txt > digit-punct.sort
mv digit-punct.sort digit-punct.txt
# ###
# Remover tokens que contém pontuação nas extremidades
# ###
@fabiolimace
fabiolimace / pt_br.affix
Created November 14, 2023 19:20 — forked from CauanCabral/pt_br.affix
Dicionários Hunspell PT-BR preparados para busca textual (FTS) com Postgresql. Fonte: https://cgit.freedesktop.org/libreoffice/dictionaries/tree/pt_BR
This file has been truncated, but you can view the full file.
SET UTF-8
TRY áàãâéêíóõôúüçesianrtolcdugmphbyfvkwjqxz
# VERO - Verificador Ortográfico Livre - Versão 3.2
# Copyright (C) 2006 - 2013 por Raimundo Santos Moura
# <raimundo.smoura@gmail.com>
# Brasil - outubro 2013
# Este é um dicionário para correção ortográfica da língua Portuguesa
# para o Hunspell.
# Este programa é livre e pode ser redistribuído e/ou modificado nos
@fabiolimace
fabiolimace / README.md
Last active November 5, 2023 14:21
Caracteres especiais na composição de palavras

Caracteres especiais na composição de palavras

Este pequeno estudo foi feito para melhorar a tokenização de palavras de um programa que estou desenvolvendo.

O termo palavra aqui é amplo: um grupo de caracteres imprimíveis delimitados por espaços, à direita e à esquerda. O conjunto de caracters pode ser composto apenas por letras do alfabeto, apenas por números, ou por uma mistrura destes com caracteres especiais. Portanto, conceito empregado aqui está mais próximo do conceito de abstrato de token do que do conceito linguístico de palavra.

Sabemos que alguns caracteres, como o hífen, estão na composição de palavras do nosso idioma; assim como outros caracteres, também estão:

  • O ponto está presente em abreviações e siglas: Sr., P.M.F.;
@fabiolimace
fabiolimace / the-universal-argument-parser-whith-long-options.sh
Last active November 2, 2023 08:23
The Universal Argument Parser using Bash's builtin getops
#!/bin/bash
# [MODIFICATION 1]
args=$@ # use builtin string substitution to simulate long options
args=${args//--long-option-a/-a} # replace `--long-option-a` with `-a`
args=${args//--long-option-b/-b} # replace `--long-option-b` with `-b`
args=${args//--long-option-c/-c} # replace `--long-option-c` with `-c`
# [MODIFICATION 2]
# replace unknown long options as