Today, I switched the last of my Windows machines to Linux: my gaming PC. I’ve been using Linux on servers for many years but was a bit apprehensive for gaming.

Turns out it just… works. Just installed steam and turned proton on, have zero performance or other issues. I’m using Ubuntu 25.04 for the 6.14 kernels NT emulation performance tweaks. Aside from there not being a catalyst driver for it and so I can’t undervolt my card everything is great.

  • squaresinger@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    8 hours ago
    import sys
    import random
    
    inFilePath = sys.argv[1]
    outFilePath = sys.argv[2]
    damagePercentage = float(sys.argv[3])
    
    with open(inFilePath, "rb") as f:
        d = f.read()
    
    damageTotalCount = int(len(d) * damagePercentage / 100)
    
    print("Damaging "+str(damageTotalCount)+" bytes.")
    
    dList = [ x.to_bytes(1) for x in d ]
    
    for i in range(damageTotalCount):
        pos = random.randint(2000,len(d)-2)
        dList[pos] = random.randint(0,255).to_bytes(1)
        if (i%1000 == 0):
            print(str(i)+"/"+str(damageTotalCount))
    
    d = b"".join(dList)
    
    with open(outFilePath, "wb") as f:
        f.write(d)
    

    If you run it, the first argument is the input file, the second one is the output file and the third is the percentage of corrupted bytes to inject.

    I did spare the first 2000 bytes in the file to get clear of the file header (corruption on a BMP file header can still cause the whole image to be illegible, and this demonstration was about uncompressed vs compressed data, not about resilience of file headers).

    I also just noticed when pasting the script that I don’t check for double-corrupting the same bytes. At lower damage rates that’s not an issue, but for the 95% example, it’s actually 61.3% actual corruption.