Skip to content

Instantly share code, notes, and snippets.

@yakkomajuri
Created September 26, 2020 22:08
Show Gist options
  • Save yakkomajuri/622f80e143078ace6a45dceef9b88ebe to your computer and use it in GitHub Desktop.
Save yakkomajuri/622f80e143078ace6a45dceef9b88ebe to your computer and use it in GitHub Desktop.
# Property filtering logic omitted
# Rollout percentage logic:
__LONG_SCALE__ = float(0xFFFFFFFFFFFFFFF)
def _hash(self, key: str, distinct_id: str) -> float:
hash_key = "%s.%s" % (key, distinct_id)
hash_val = int(hashlib.sha1(hash_key.encode("utf-8")).hexdigest()[:15], 16)
return hash_val / __LONG_SCALE__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment