1. Лучший говнокод

    В номинации:
    За время:
  2. JavaScript / Говнокод #3459

    +184

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    function reverse_string(str, len) {
    	if (len == 1) {
    		return str.charAt(0);
    	}
    	if (len == 2) {
    		return str.charAt(1) + str.charAt(0);
    	}
    	if (len == 3) {
    		return str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 4) {
    		return str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 5) {
    		return str.charAt(4) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 6) {
    		return str.charAt(5) + str.charAt(5) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 7) {
    		return str.charAt(6) + str.charAt(5) + str.charAt(4) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 8) {
    		return str.charAt(7) + str.charAt(6) + str.charAt(5) + str.charAt(4) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 9) {
    		return str.charAt(8) + str.charAt(7) + str.charAt(6) + str.charAt(5) + str.charAt(4) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    	if (len == 10) {
    		return str.charAt(9) + str.charAt(8) + str.charAt(7) + str.charAt(6) + str.charAt(5) + str.charAt(4) + str.charAt(3) + str.charAt(2) + str.charAt(1) + str.charAt(0);
    	}
    };

    Переворачивание строки при помощи новейших технологий. Также ожидается движок (по содержанию конечно кусок говна, но по размерам похож), который позволит переворачивать строки любой длины (таким же методом). В-общем, прогноз неутешительный.

    eval, 11 Июня 2010

    Комментарии (98)
  3. Куча / Говнокод #2942

    +51.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    .....
    <table width=100% border=1>
    <colgroup .....>
    .....
    <tr>
      <td colspan=2>(тут шапка)</td>
    </tr>
    <tr>
      <td width=60% colspan>(слева)</td>
      <td width=40% colspan>(справа)</td>
    </tr>
    .....
    </table> 
    .....

    Нету раздела html, поэтому решил наговнокодить тут :) Будет ли это говнокодом если верстать сайты так? Вообщем за и против div'ой и табличной верстки.. примеры данного куска с оптимальным содержанием..

    antigovnokoder, 06 Апреля 2010

    Комментарии (98)
  4. PHP / Говнокод #27891

    −9

    1. 1
    2. 2
    Is there PHP mysql_real_escape_string for postgresql?
    pg_escape_string

    https://www.php.net/manual/en/function.pg-escape-string.php

    real_escape_string, 23 Декабря 2021

    Комментарии (97)
  5. Си / Говнокод #27807

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    // https://github.com/j123123/sexpr_parse/blob/584fc23de71bebe02545214f819e16b720a2c1e2/my_struct_utils.c#L119
    
    blob *
    blob_scan_fromstream
    (
      FILE *stream
    )
    {
      size_t st_len = 0;
      size_t st_alloc;
      uint8_t *st = NULL;
    
      while(true)
      {
        const int fg = getc(stream);
        if(fg == EOF)
        {
          PRV_ERR_MACRO();
        }
        uint8_t c = fg;
        if(!isprint(fg))
        {
          PRV_ERR_MACRO();
        }
        switch(c)
        {
          case '\\':
            {
              int c2 = getc(stream);
              switch(c2)
              {
                case 'x':
                  {
                    int c3[2] =
                    {
                      getc(stream),
                      getc(stream)
                    };
                    uint8_t tmp[2];
    
                    for(size_t i = 0; i < 2; ++i)
                    {
                      switch(c3[i])
                      {
                        case '0' ... '9':
                          tmp[i] = c3[i]-'0';
                          break;
                        case 'a' ... 'f':
                          tmp[i] = c3[i]+10-'a';
                          break;
                        case 'A' ... 'F':
                          tmp[i] = c3[i]+10-'A';
                          break;
                        default:
                          PRV_ERR_MACRO();
                      }
                    }
                    M_PUSH(tmp[1] | tmp[0] << 4);
                  }
                  break;
                case '\\':
                  M_PUSH('\\');
                  break;
                case 't':
                  M_PUSH('\t');
                  break;
                case 'n':
                  M_PUSH('\n');
                  break;
                case '"':
                  M_PUSH('"');
                  break;
                default:
                  PRV_ERR_MACRO();
              }
            }
            break;
    //      case '\t':
    //      case '\n':
    //        PRV_ERR_MACRO();
    //        break;
          case '"':
            goto end;
          default:
            M_PUSH(c);
        }
      }
    
    end:
      ;
      blob *tmp = blob_init(st_len, st);
      PRV_FREE(st);
      return tmp;
    }

    Эта вот хрень вычитывает из "FILE *" одно "слово".

    j123123, 09 Ноября 2021

    Комментарии (97)
  6. Си / Говнокод #27525

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    #include <stdio.h>
    #include <stdlib.h>
    #include <inttypes.h>
    
    typedef struct list list;
    
    struct list
    {
      list* next;
      uint32_t data;
    };
    
    #define ADD_LIST(ptr, val) \
    do { \
      (ptr)->next = (list *)alloca(sizeof(list)); \
      (ptr)->next->data = val; \
      (ptr)->next->next = NULL;\
    } while (0)
    
    // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
    #define INIT_LIST(val) \
    ({ \
      list *INIT_LIST = (list *)alloca(sizeof(list)); \
      INIT_LIST->data = val; \
      INIT_LIST->next = NULL; \
      INIT_LIST; \
    })
    
    
    int main(void)
    {
      list *a = INIT_LIST(5);
      ADD_LIST(a,10);
      ADD_LIST(a->next,15);
      ADD_LIST(a->next->next,20);
      ADD_LIST(a->next->next->next,25);
      ADD_LIST(a->next->next->next->next,30);
    
      for(list *ptr = a; ptr != NULL; ptr = ptr->next)
      {
        printf("%d ", ptr->data);
      }
    
      return EXIT_SUCCESS;
    }

    А можно ли в крестоговне так сделать без Сишного Препроцессора?

    j123123, 19 Июля 2021

    Комментарии (97)
  7. Python / Говнокод #27244

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    import datetime, random, time, os, vk_api
    import sqlite3 as sl
    from vk_api.exceptions import Captcha
    from vk_api.longpoll import VkEventType, VkLongPoll
    from functions import *
    from settings import *
    vk_session = vk_api.VkApi(token=token, api_version=5.126)
    longpoll = VkLongPoll(vk_session)
    vk = vk_session.get_api()
    now = datetime.datetime.now()
    
    for event in longpoll.listen():
        try:
            def send_msg(msg='', chat=False, prefix=True, attach=''):
                if chat:
                    vk.messages.send(chat_id=event.chat_id,message=msg,attachment=attach)
                else:
                    vk.messages.send(user_id=event.user_id,message=msg,attachment=attach)
        except Captcha:
            time.sleep(1)
            send_msg('Ошибка. Слишком частые запросы.')
        except Exception as e:
            time.sleep(1)
            send_msg(f'Неизвестная ошибка при отправке сообщения.\n{e}')
        try:
            if event.type == VkEventType.MESSAGE_NEW and event.to_me:
                user_get = vk.users.get(user_ids=event.user_id)
                first_name = user_get[0]['first_name']
                last_name = user_get[0]['last_name']
                if event.from_chat and event.chat_id and (event.message == '!meme' or event.message == '!мем'):
                    meme_create()
                    upload = vk_api.VkUpload(vk_session)
                    try:
                        a = upload.photo_messages(photos=os.path.dirname(__file__) + '/random_meme.jpg', peer_id=event.user_id)
                        send_msg(attach=f'photo{a[0]["owner_id"]}_{a[0]["id"]}',chat=True, prefix=False)
                    except:
                        send_msg("Ошибка. Попробуйте снова.")
                elif event.from_chat and event.chat_id and (event.message == '!info' or event.message == '!инфо'):
                    response = requests.get(f'https://vk.com/foaf.php?id={event.user_id}')
                    soup = BeautifulSoup(response.text, 'lxml')
                    created = soup.find('ya:created').get('dc:date')
                    created1 = datetime.datetime.strptime(created, '%Y-%m-%dT%H:%M:%S%z').replace(tzinfo=None)
                    diff = datetime.datetime.now()-created1
                    modified = soup.find('ya:modified').get('dc:date')
                    modified1 = datetime.datetime.strptime(modified, '%Y-%m-%dT%H:%M:%S%z').replace(tzinfo=None)
                    send_msg(f'''https://vk.com/id{event.user_id}\nИмя пользователя: {first_name} {last_name}\nАккаунт существует {diff.days} дней.\nДата регистрации: {created1.month} {months[created1.month-1]} {created1.year} в {created1.time()}\nПоследнее обновление информации: {modified1.month} {months[modified1.month-1]} {modified1.year} в {modified1.time()}''', chat=True)
                elif event.from_user and event.user_id and (event.message == '!info' or event.message == '!инфо'):
                    response = requests.get(f'https://vk.com/foaf.php?id={event.user_id}')
                    soup = BeautifulSoup(response.text, 'lxml')
                    created = soup.find('ya:created').get('dc:date')
                    created1 = datetime.datetime.strptime(created, '%Y-%m-%dT%H:%M:%S%z').replace(tzinfo=None)
                    diff = datetime.datetime.now()-created1
                    modified = soup.find('ya:modified').get('dc:date')
                    modified1 = datetime.datetime.strptime(modified, '%Y-%m-%dT%H:%M:%S%z').replace(tzinfo=None)
                    send_msg(f'''https://vk.com/id{event.user_id}\nИмя пользователя: {first_name} {last_name}\nАккаунт существует {diff.days} дней.\nДата регистрации: {created1.month} {months[created1.month-1]} {created1.year} в {created1.time()}\nПоследнее обновление информации: {modified1.month} {months[modified1.month-1]} {modified1.year} в {modified1.time()}''')
                elif event.from_user and event.user_id and event.message == '!coin':
                    coin = 'Орёл' if random.randint(0, 1) == 1 else 'Решка'
                    send_msg(f'{coin}')
                elif event.from_user and event.user_id and (event.message == '!anek' or event.message == '!анек'):
                    send_msg(f'{get_anek()}', prefix=False)
                elif event.from_user and event.user_id:
                    con = sl.connect(os.path.dirname(__file__) + '/users.db')
                    count = 0
                    with con:
                                con.execute("""
                                    CREATE TABLE IF NOT EXISTS USER (
                                        user_id INTEGER NOT NULL PRIMARY KEY,
                                        name TEXT,
                                        permission_lvl INTEGER
                                    );
                                """)
                    with con:
                        data = con.execute("SELECT * FROM USER")
                        for row in data:
                            if event.user_id in row:
                                count += 1
                        if count == 0:
                            send_msg(f'''Привет, это сообщение отправлено автоматически.\nПока я добавляю информацию о тебе в базу данных, ты можешь ознакомиться с командами написав !help\nКоманд не так много, но в будущем их станет больше ;)''')
                            sql = 'INSERT INTO USER (user_id, name, permission_lvl) values(?, ?, ?)'
                            data = [(event.user_id, f'{first_name} {last_name}', 1)]
                            with con:
                                con.executemany(sql, data)
                if event.attachments:
                    print(
                        f"{now}\nuser_id: {event.user_id} | {first_name} {last_name}\nmessage: {event.message}\nattach: {event.attachments}\n")
                else:
                    print(
                        f"{now}\nuser_id: {event.user_id} | {first_name} {last_name}\nmessage: {event.text}\n")
        except Captcha:
            time.sleep(1)
            send_msg('Ошибка. Слишком частые запросы.')
        except Exception as e:
            time.sleep(1)
            send_msg(f'Упс. Произошла неизвестная ошибка.\n{e}')

    Каким образом можно улучшить этот ссаный говнокод?

    TupoyChel, 09 Февраля 2021

    Комментарии (97)
  8. C++ / Говнокод #25991

    0

    1. 1
    2. 2
    3. 3
    4. 4
    char (&getArray())[11] {
      static char arr[] = "1234567890";
      return arr;
    }

    Как вернуть массив из функции в C/C++

    На самом деле нет: возвращается ссылка

    Elvenfighter, 24 Октября 2019

    Комментарии (97)
  9. Куча / Говнокод #25797

    −3

    1. 1
    Каталог тредов

    syoma, 03 Сентября 2019

    Комментарии (97)
  10. Куча / Говнокод #25070

    +1

    1. 1
    2. 2
    3. 3
    Последние дни все текут от "Highload++".
    Типа встреча для "крутых" пацанов.
    Так ли это на самом деле?

    cTeKJl9lHHblu_xyu, 09 Ноября 2018

    Комментарии (97)
  11. Куча / Говнокод #24733

    −3

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Почему "Skype" и "Chrome" со временем становятся лишь хуже по части скорости работы, объёму занимаемой
    оперативной памяти и частоте взбрыкиваний, приводящих к внезапному завершению работы? Я тупой, у меня
    все мозги заплыли "PHP", и их не хватает на постижение причины вышеописанных конфузов; но, кроме меня,
    полагаю, здесь найдётся пара-тройка компетентных херов, которые могли бы всё разъяснить?
    У меня имеется версия, суть которой заключается в том, что производители компьютерного оборудования лоббируют
    намеренное увеличение создаваемой популярнейшими программами нагрузки на оборудование с целью принуждения
    пользователей к приобретению более дорогих комплектующих и "гаджетов"; но вы ведь, как всегда, начнёте кукарекать
    про конспирологию и фольговые шапки, так что можем это опустить...

    AnaILoIIipop, 07 Сентября 2018

    Комментарии (97)