Skip to content

Instantly share code, notes, and snippets.

@zhuochun
Created July 13, 2016 04:50
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 zhuochun/2635899056e03caf4cd2bd54ad54ad4e to your computer and use it in GitHub Desktop.
Save zhuochun/2635899056e03caf4cd2bd54ad54ad4e to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'net/http'
require 'json'
begin
uri = URI('https://cdn.rawgit.com/github/gemoji/master/db/emoji.json')
resp = Net::HTTP.get_response(uri)
emoji = JSON.parse(resp.body)
num = [ARGV.first.to_i, 1].max
$stdout << emoji.map { |i| i['emoji'] }.sample(num).join(',') << "\n"
rescue Exception => e
$stdout << "ERROR: #{e}\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment