Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View file

@ -0,0 +1,8 @@
# s should be a bitstring.
# Right-pad s with 0s so that the length of the output string is a multiple of 8.
CREATE OR REPLACE FUNCTION print_bits(s) as (
format('{:0<{}}', s, (ceil(length(s) / 8) * 8)::INT)
);
# Example:
select print_bits('101'::BITSTRING);

View file

@ -0,0 +1,13 @@
# "Compress" a string by printing it as a bitstring without the left-most bit of each byte
CREATE OR REPLACE FUNCTION sevenbits(str) as (
select string_agg(format('{}', ascii(s)::BITSTRING)[-7:], '')
from (select unnest(regexp_extract_all(str, '.')) as s)
);
# Undo sevenbits()
CREATE OR REPLACE FUNCTION from_sevenbits(str) as (
select string_agg(chr(s::BIT::INT), '')
from (select unnest(regexp_extract_all(str, '.......')) as s)
);
select from_sevenbits(sevenbits('abracadabra'));