Skip to content

Instantly share code, notes, and snippets.

@ramnes
Last active January 6, 2023 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramnes/624f0113746617afe8d3de4a15ba33bb to your computer and use it in GitHub Desktop.
Save ramnes/624f0113746617afe8d3de4a15ba33bb to your computer and use it in GitHub Desktop.
Create an id such as the ones Meteor creates... in Python!
import random
UNMISTAKABLE_CHARS = '23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz'
def meteor_id(chars_count=17, prefix=""):
"""Create an id such as the ones Meteor creates
Reference implementation: https://github.com/meteor/meteor/blob/3a2867fc15/packages/random/AbstractRandomGenerator.js
"""
chars = [random.choice(UNMISTAKABLE_CHARS) for _ in range(0, chars_count)]
return prefix + "".join(chars)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment