Skip to content

Instantly share code, notes, and snippets.

@kyktommy
Created April 6, 2013 10:04
Show Gist options
  • Save kyktommy/5325616 to your computer and use it in GitHub Desktop.
Save kyktommy/5325616 to your computer and use it in GitHub Desktop.
Randomly generate 64 characters from 'A' to 'H', then save it to "source_?.txt"
PREFIX = "source_"
POSTFIX = ".txt"
LENGTH = 64
RANGE = 'A'..'H'
SIZE = RANGE.to_a.size - 1
FILE_CODE = 'a'..'d'
def gen; 1.upto(LENGTH).map { RANGE.to_a[rand(SIZE)] }.join; end
# Save result to files
(FILE_CODE).to_a.each { |x| File.new("#{PREFIX}#{x}#{POSTFIX}", 'w').write gen }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment