Ask HN: What's the worst piece of code you've ever seen? - dluan
======
joshschreuder
I found a couple of amusing subreddits that covers this yesterday:
[https://www.reddit.com/r/badcode](https://www.reddit.com/r/badcode)
[https://www.reddit.com/r/programminghorror](https://www.reddit.com/r/programminghorror)

One of the top posts, the so-called Bogosort, made me laugh pretty hard, even
though it's probably intentionally bad:
[https://imgur.com/kUizTX1](https://imgur.com/kUizTX1)

------
Gibbon1
This gem from today is pretty icky

    
    
      TEST_PACKET_T *xmt_buffer = (TEST_PACKET_T *) radio_drv_cntl->xmt_buffer;
    
      ...
      ...
      uint8_t msg_len = xmt_buffer->len;
      // Fill the payload with 'data'
      for(uint8_t indx=offsetof(TEST_PACKET_T, data); indx<msg_len-2; indx++)
        xmt_buffer->data[indx] = indx;

------
earthshout
Not code so it doesn't count but a command.

Dos: "attrib," Will strip all attributes from all files in a directory. Very
easy to run accidentally.

Has a partner though "dir," Show all files even hidden. Very berry handy.

