This document defines two unique identifiers:
- a custom UUID based on RFC 9562;
- a custom Tag URI based on RFC 4151.
SHA-256 UUIDv8
| function join_numbers( i, n, x) { | |
| while (match($0, /[ ][0-9,.()-]+[ ][0-9,.()-]+[ ]?/)) { | |
| i = RSTART; | |
| n = RLENGTH; | |
| x = substr($0, i, n); | |
| gsub(" ", "", x); | |
| $0 = substr($0, 0, i-1) " " x " " substr($0, i+n) | |
| } | |
| } |
| CREATE OR REPLACE FUNCTION uuid7_sql() RETURNS uuid AS $$ | |
| SELECT (FORMAT('%s-%s-%0s-%s-%s', | |
| lpad(to_hex(trunc(EXTRACT(EPOCH FROM statement_timestamp()) * 1000)::bigint >> 16), 8, '0'), | |
| lpad(to_hex(trunc(EXTRACT(EPOCH FROM statement_timestamp()) * 1000)::bigint & 65535), 4, '0'), | |
| lpad(to_hex((trunc(random() * 2^12) + 28672)::bigint), 4, '0'), -- 28672 = 0x7000 | |
| lpad(to_hex((trunc(random() * 2^14) + 32768)::bigint), 4, '0'), -- 32768 = 0x8000 | |
| lpad(to_hex(trunc(random() * 2^48)::bigint), 12, '0')))::uuid; | |
| $$ LANGUAGE SQL; | |
| select uuid7_sql() -- 019450fe-7b0f-7ccc-8564-ad3ccc8234e0 |
| -- install the extension | |
| CREATE EXTENSION pgcrypto; | |
| CREATE OR REPLACE FUNCTION secure_random_bigint() RETURNS bigint AS $$ | |
| DECLARE | |
| v_bytes bytea; | |
| v_value bigint := 0; | |
| v_length integer := 8; | |
| i integer := 0; | |
| BEGIN |
| FROM ubuntu:24.04 | |
| RUN apt update | |
| RUN apt upgrade -y | |
| RUN apt install tinyproxy -y | |
| RUN mkdir --parents /home/tinyproxy | |
| COPY template.conf /home/tinyproxy | |
| COPY entrypoint.sh /home/tinyproxy | |
| WORKDIR /home/tinyproxy |
| #!/usr/bin/mawk -f | |
| /^((([0][48]|[2468][048]|[13579][26])00)|([0-9][0-9]([0][48]|[2468][048]|[13579][26])))$/ { print $0; next; } | |
| { print $0 " INVALIDO" } | |
| #!/usr/bin/mawk -f | |
| # | |
| # Transforma um extrato exportado da Caixa no formato TXT para uma arquivo mais simples. | |
| # | |
| # O arquivo exportado eh na verdade um CSV com um ponto e vírgula separando colunas. | |
| # | |
| # O arquivo de saida gerado por este script eh um TSV com data e valor reformatados. | |
| # | |
| # Aceita entradas de extrato neste formato (4 colunas): |
| #!/bin/bash | |
| # Calculates hash uniqueness. | |
| # | |
| # Usage: | |
| # | |
| # hash-uniqueness.sh PROGRAM LENGTH WINDOW | |
| # | |
| # hash-uniqueness.sh md5sum | |
| # |
| package com.example; | |
| import java.nio.charset.StandardCharsets; | |
| // https://www.youtube.com/watch?v=siV5pr44FAI | |
| public final class NonCryptoHash { | |
| // http://www.mrob.com/pub/comp/crc-all.html (crc32-adler) | |
| private static final int[] crc32tab = { // | |
| 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, // |
| diff --git a/src/main/java/io/hypersistence/tsid/TSID.java b/src/main/java/io/hypersistence/tsid/TSID.java | |
| index 1ca20ca..665f081 100644 | |
| --- a/src/main/java/io/hypersistence/tsid/TSID.java | |
| +++ b/src/main/java/io/hypersistence/tsid/TSID.java | |
| @@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicInteger; | |
| import java.util.concurrent.locks.ReentrantLock; | |
| import java.util.function.IntFunction; | |
| import java.util.function.IntSupplier; | |
| +import java.util.function.Supplier; | |