Last active
June 23, 2018 10:14
-
-
Save saifulbkhan/31e7c803e5f794d34bda3a385383429d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
from os.path import join, expanduser | |
from random import randint | |
import secrets | |
num_files = 10000 | |
file_size_min = 4 | |
file_size_max = 10 | |
home_path = expanduser('~') | |
junk_dir = 'random_junk' | |
if not os.path.exists(join(home_path, junk_dir)): | |
os.makedirs(join(home_path, junk_dir)) | |
for i in range(num_files): | |
# this gives us a random 32 char long string as filename | |
fname = secrets.token_hex(32) | |
with open(join(home_path, junk_dir, fname), 'w+') as f: | |
size = randint(file_size_min, file_size_max) | |
size_in_bytes = size * (1024 ** 2) | |
num_64b_strings_needed = size_in_bytes//64 | |
for i in range(num_64b_strings_needed): | |
f.write(secrets.token_hex(32)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment