Last active
August 25, 2017 09:13
-
-
Save SomeHats/676e0857e91693a691fbe3245c376aca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with x as ( | |
select clock_timestamp() as t, | |
gen_random_bytes(3) as r, | |
1503576000 as offset | |
), | |
id as ( | |
select | |
(((extract(epoch from t) - offset) * 1000)::int8 << 24) | | |
(get_byte(r, 0) | (get_byte(r, 1) << 8) | (get_byte(r, 2) << 16)) as id | |
from x | |
) | |
select id, encode(int8send(id), 'base64') | |
from id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment