Skip to content

Instantly share code, notes, and snippets.

@sunaot
Created March 11, 2021 14:48
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 sunaot/260897d63baea3d2c07e06f0e6af7cd8 to your computer and use it in GitHub Desktop.
Save sunaot/260897d63baea3d2c07e06f0e6af7cd8 to your computer and use it in GitHub Desktop.
excalidraw の部屋の URL をつくるときの支援スクリプト
require 'digest/sha1'
def room_id(name)
digest = Digest::SHA1.new
digest.update(name)
digest.hexdigest.slice(0,20)
end
def encryption_key(seed)
alphabets = ('a'..'z')
capital_alphabets = ('A'..'Z')
numbers = 0..9
marks = %w( _ - )
(alphabets.to_a + capital_alphabets.to_a + numbers.to_a + marks).shuffle(random: Random.new(seed)).slice(0, 22).join
end
name = ARGV.shift
pass_number = ARGV.shift.to_i
puts "https://excalidraw.com/#room=#{room_id(name)},#{encryption_key(pass_number)}"
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment