Last active
December 25, 2022 03:48
-
-
Save cobyism/3746484 to your computer and use it in GitHub Desktop.
Generate a random emoji bomb via the command-line
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'open-uri' | |
# Run `emojibomb` to get three emoji. | |
# Run `emojibomb N`, where `N` is a positive integer to get N emoji. | |
response = open("http://www.emoji-cheat-sheet.com/") | |
html = response.read | |
emoji = html.scan(/:\S+:/) | |
count = [ARGV.first.to_i, 3].max | |
bomb = "" | |
count.times do | |
bomb << emoji.sample | |
end | |
puts bomb |
@shiftyp as I really enjoyed your idea, I wrote a quick crawler for https://unicode.org/emoji/charts/full-emoji-list.html and extracted this ranges that I like:
codes = [9193..9203,
9208..9210,
9917..9918,
9924..9925,
9928..9928,
9937..9937,
9939..9940,
9961..9962,
9968..9973,
9975..9978,
9981..9981,
9989..9989,
9992..9997,
10024..10024,
10062..10062,
11088..11088,
11093..11093,
127744..127777,
127780..127891,
127894..127895,
127897..127899,
127902..127984,
127987..127989,
127991..127994,
128000..128253,
128255..128317,
128329..128334,
128336..128359,
128367..128368,
128371..128378,
128400..128400,
128405..128406,
128506..128591,
128640..128709,
128715..128722,
128725..128727,
128755..128764,
129292..129338,
129340..129349,
129351..129535,
129680..129708]
You can print out all of them using:
codes.flat_map(&:to_a).map { |code| code.chr("UTF-8") }
=> ["⏩",
"⏪",
"⏫",
"⏬",
"⏭",
"⏮",
"⏯",
"⏰",
"⏱",
"⏲",
"⏳",
"⏸",
"⏹",
"⏺",
"⚽",
"⚾",
"⛄",
"⛅",
"⛈",
"⛑",
"⛓",
"⛔",
"⛩",
"⛪",
"⛰",
"⛱",
"⛲",
...
You can create a random emoji using this
codes.flat_map(&:to_a).sample.chr("UTF-8")
=> "✅"
https://github.com/github/gemoji
Emoji.all.sample
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found this looking for random emojis in ruby. Here's another way to generate random emojis (I'm unsure about the exact range, but the method is simple).