Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created April 23, 2009 15:52
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 jerodsanto/100568 to your computer and use it in GitHub Desktop.
Save jerodsanto/100568 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
print 'Enter file size (MB): '
the_size = gets.chomp
unless the_size =~ /^\d+$/
puts "Error: bad file size"
exit
end
puts the_size + 'MB file coming right up!'
# Generate the file
file_size = 0
string = "abcdefghijklmnopqrstuvwxyz123456"
f = File.new(the_size + 'MB', 'w')
while file_size < the_size.to_i * 1048576 # bytes in 1MB
f.print string
file_size += string.size
end
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment