Skip to content

Instantly share code, notes, and snippets.

@daicham
Last active October 1, 2015 17:58
Show Gist options
  • Save daicham/2034347 to your computer and use it in GitHub Desktop.
Save daicham/2034347 to your computer and use it in GitHub Desktop.
Generate random strings and copy to clipboard by ruby on batch file
@echo off
ruby -S -x %0 %*
goto end
#! ruby
require 'win32/clipboard' # before install "win32-clipboard" gem
pattern = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
puts "Random String => " + Array.new(8){pattern[rand(pattern.size)]}.join
Win32::Clipboard.set_data(value, Win32::Clipboard::UNICODETEXT)
puts "Stored to clipboard"
__END__
:end
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment