Last active
January 22, 2025 07:09
-
-
Save motebaya/d9592cb3257e24417ac2756be35bf54f to your computer and use it in GitHub Desktop.
nee nee, my graden is gray de karappo njir...
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 | |
# do you wanna be a productive human? | |
# sugar grass with shining sunrise in your garden? | |
# @github.com/motebaya - 2024-06-16 23:16:23.729592300 +0700 | |
import calendar, subprocess, time, random, sys, string | |
from datetime import datetime | |
from concurrent.futures import ThreadPoolExecutor, as_completed | |
import threading | |
git_lock = threading.Lock() | |
def get_rand_hex(length: int) -> list[str]: | |
return list(dict.fromkeys(["0x{:x}".format( | |
random.randint(1, 1024 * length) | |
) for i in range(length * 2)])) | |
def get_rand_str(length: int) -> list[str]: | |
return [ | |
''.join(random.choice( | |
string.ascii_letters + string.digits | |
) for i in range(10)) for i in range(length) | |
] | |
def get31day(year) -> dict[int, str]: | |
return { i: calendar.month_name[i] for i in range(1, 13 | |
) if calendar.monthrange(year, i)[1] == 31} | |
def go_commit(files: list, year: str) -> None: | |
start = time.time() | |
rand_hex = get_rand_hex(len(files)) | |
month_31 = list(get31day(year)) | |
for t, fname in enumerate(files, 1): | |
commit_miaw = "miaw:{}:{}".format(str(t), rand_hex[t-1]) | |
with git_lock: | |
with open(fname, 'w', encoding='utf-8') as f: | |
f.write(rand_hex[t - 1]) | |
month = random.randint(1, 12) | |
days = random.randint(1, 31) | |
dates = "{}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}".format( | |
year, | |
month, | |
random.randint(1, 30) if days == 31 and month not in month_31 else days, | |
random.randint(1, 23), | |
random.randint(1, 59), | |
random.randint(1, 59) | |
) | |
subprocess.run(['git', 'add', fname]) | |
subprocess.run([ | |
'git', 'commit', '--date', dates, '-m', f'"{commit_miaw}"' | |
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) | |
# print(f"\r {git_commit}:{t}/{len(files)}:{commit_miaw} ", flush=True, end="") | |
# time.sleep(0.03) # duplicated | |
if t % 50 == 0: | |
subprocess.call(['clear']) | |
end_time = time.time() - start | |
return end_time | |
def format_time(seconds): | |
hours = int(seconds // 3600) | |
minutes = int((seconds % 3600) // 60) | |
remaining_seconds = seconds % 60 | |
result = [] | |
if hours > 0: | |
result.append(f"{hours} hour{'s' if hours > 1 else ''}") | |
if minutes > 0: | |
result.append(f"{minutes} minute{'s' if minutes > 1 else ''}") | |
if remaining_seconds > 0 or not result: | |
result.append(f"{remaining_seconds} second{'s' if remaining_seconds > 1 else ''}") | |
return ' '.join(result) | |
year = datetime.now().year | |
year = 2024 | |
files = [f".dummy-{i}" for i in range(50)] | |
total = 0 | |
with ThreadPoolExecutor(max_workers=15) as executor: | |
tasks = [] | |
for i in range(5000): | |
tasks.append(executor.submit( | |
go_commit, files, year | |
)) | |
for x, r in enumerate(as_completed(tasks), 1): | |
t = r.result() | |
print(f" -- {x}/{len(tasks)} Completed with: {t} Seconds.") | |
total += t | |
print(f" -- END total: {format_time(total)}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run it in google colab!!