Created
February 8, 2015 01:59
-
-
Save schof/2cfc8989d2a37e9a34f1 to your computer and use it in GitHub Desktop.
Order Number Generator
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
# Current time in hex (saves a few chars) | |
n = Time.now.to_i.to_s(16) | |
# Add some more random digits and convert to base24 (more entropy w/minimal chars) | |
n += rand(9999).to_s(24) | |
# Make sure the whole thing is exactly 10 chars | |
n.ljust(10).gsub(" ", "0") | |
# Convert to upcase | |
n.upcase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍
Really liked the usage of hex and base64!