Skip to content

Instantly share code, notes, and snippets.

@dbreunig
Last active July 3, 2024 22:55
Show Gist options
  • Save dbreunig/2f9c57c729530eb514676c3e5e4e7d96 to your computer and use it in GitHub Desktop.
Save dbreunig/2f9c57c729530eb514676c3e5e4e7d96 to your computer and use it in GitHub Desktop.
A Ruby function that returns a random emoji. Useful for seeding and more.
EMOJI_CODEPOINTS = [
*0x1F600..0x1F64F, # Emoticons
*0x1F300..0x1F5FF, # Misc Symbols and Pictographs
*0x1F680..0x1F6FF, # Transport and Map Symbols
*0x2600..0x26FF, # Misc symbols
*0x2700..0x27BF, # Dingbats
*0x1F900..0x1F9FF, # Supplemental Symbols and Pictographs
*0x1FA70..0x1FAFF # Symbols and Pictographs Extended-A
]
def random_emoji = EMOJI_CODEPOINTS.sample.chr(Encoding::UTF_8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment