In this forum thread a few years back, I posted a postgres function to generate snowflake ids etc.
The thread is about using the Triplex multi-tenancy library. As part of that discussion, I posted a snowflake id solution for a multi-tenancy. You might find some of that of interest.