Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
fabiolimace / uuid_insert_tests.sql
Last active August 10, 2023 18:12
UUID Insert Tests in PostgreSQL
-- READ (in Portuguese):
-- http://www.savepoint.blog.br/2018/02/17/chaves-artificiais-no-postgresql-desempenho/
-- https://gist.github.com/rponte/bf362945a1af948aa04b587f8ff332f8
----------------------------------------------------------------------------
-- PRE-TEST: create tables
----------------------------------------------------------------------------
-- Install UUID-OSSP extension
@fabiolimace
fabiolimace / CorretorCaracteresEspeciais.html
Last active May 10, 2025 12:45
Corretor de caracteres especiais - ISO-8859-1
<!DOCTYPE html>
<html>
<!-- Yes, I know the jokes about long if-else chains. I just don't feel like using a hash table here. -->
<head>
<title>Corretor de Caracteres Especiais - v20220721</title>
<meta charset="UTF-8">
<meta name="author" content="Fabio Lima">
<meta name="keywords" content="Codificação, Caracteres, ISO-8859-1, UTF-8, WINDOWS-1252">
<meta name="description" content="Sustitui caracteres invalidos por caracteres equivalentes">
<script>
@fabiolimace
fabiolimace / README.md
Last active January 15, 2022 20:33
Deduplicate Photos

Deduplicate Photos

About

The program deduplicate-photos.sh helps to deduplicate the family photos.

List of sub-parts:

  • deduplicate-photos-copy.sh
@fabiolimace
fabiolimace / chrono.sh
Created February 22, 2021 05:54
Cronometro simples feito para o bash
#!/bin/bash
# Cronometro simples feito em Shell.
# Script criado apenas para fins de estudo.
# Para parar, use um [ctrl] + C.
# Autor: Fabio Lima
# Data: 2009-02-14
# Inicializacao das variaveis
SS=0;
MM=0;
@fabiolimace
fabiolimace / battery.sh
Created February 22, 2021 05:57
Programa de medicao de capacidade da bateria para bash
#!/bin/sh
# Local: /usr/local/bin/
# Bateria: programa de medicao de capacidade da bateria
# Autor: Fabio Lima CE
# Data: 25-12-2009
echo ""
cat /proc/acpi/battery/BAT1/info \
| grep "last full capacity:" \
| cut -c26-29 \
@fabiolimace
fabiolimace / uuid7_generator.py
Last active March 17, 2021 03:33
UUIDv7 generator
#!/usr/bin/python3
#
# This is an proposed implementation for this PR: https://github.com/uuid6/uuid6-ietf-draft/pull/10
#
# @date: 2021-03-06
# @author: Fabio Lima
#
# Changelog:
# - 2021-03-16: add parameter `subsec_decimal_digits` to function `uuid7()`
# - 2021-03-08: use `time.time_ns()` instead of `time.time()` to fix nanosecond precision
@fabiolimace
fabiolimace / list_uuid_base_n_16_32_64.py
Last active April 28, 2021 00:01
Generate a list of UUIDs in base-16, base-32 or base-64
#!/bin/env python3
import string
from uuid import uuid4
alphabet_b16 = "0123456789abcdef" # base-16
alphabet_b32 = "abcdefghijklmnopqrstuvwxyz234567" # base-32
alphabet_b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" # base-64
@fabiolimace
fabiolimace / list_uuid_base_n_36_58_62.py
Last active April 27, 2021 23:55
Generate a list of UUIDs in base-36, base-58 or base-62
#!/bin/env python3
import string
from uuid import uuid4
alphabet_b36_lower = "0123456789abcdefghijklmnopqrstuvwxyz" # base-36
alphabet_b36_upper = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" # base-36
alphabet_b58_lower = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" # base-58
alphabet_b58_upper = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" # base-58 (used in BTC)
@fabiolimace
fabiolimace / CharacterRange.java
Last active May 2, 2021 10:18
Expand character ranges like 0-9, a-z, and A-Z
package your.package;
public class CharacterRange {
/**
* Expands character ranges similar to 0-9, a-z and A-Z.
*
* @param string a string to be expanded
* @return a string
*/
@fabiolimace
fabiolimace / compare_hashes.py
Last active September 21, 2021 11:17
Compare hashes in Python
#!/usr/bin/python3
import zlib
import base64
import random
import string
import hashlib
def crc32(text):
return zlib.crc32(text.encode())