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

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

    +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
    #include <iostream>
    #include <functional>
    
    #define STD_FUNCTION(a, ...) typeof( a (*) __VA_ARGS__ )
    
    template<typename T>
    T do_op_t(T a, T b, STD_FUNCTION(T,(T,T)) op)
    {
      return op(a,b);
    }
    
    template
    <
    
      typename T,
    
      STD_FUNCTION(
        T,
        (
          T,T,
          STD_FUNCTION(
            T,
            (T,T)
          )
        )
      ) F1,
    
      STD_FUNCTION(
        T,
        (T,T)
      ) F2
    
    >
    T do_op_spec(T a, T b)
    {
      return F1(a, b, F2);
    }
    
    int add(int a, int b) { return a + b; }
    
    int mul(int a, int b) { return a * b; }
    
    std::function<int(int,int)> fnc = \
      do_op_spec\
      <
        int,
        do_op_t<int>,
        add
      >;
    
    int main()
    {
      std::cout << do_op_t<int>(9, 9, add) << "\n";
      std::cout << do_op_t<int>(9, 9, mul) << "\n";
      std::cout << do_op_spec<int, do_op_t<int>,add>(9,9)  << "\n";
      std::cout << do_op_spec<int, do_op_t<int>,mul>(9,9)  << "\n";
      std::cout << fnc(9,9) << "\n";
    }

    Какая крестопараша )))

    j123123, 23 Июля 2021

    Комментарии (97)
  3. 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)
  4. 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)
  5. Куча / Говнокод #25797

    −3

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

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

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

    +1

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

    cTeKJl9lHHblu_xyu, 09 Ноября 2018

    Комментарии (97)
  7. Куча / Говнокод #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)
  8. C++ / Говнокод #23392

    +3

    1. 1
    2. 2
    cout << "\xFFsome_message" << endl;       // OK
    cout << "\xFFanother_message" << endl;    // std::shooted_foot_exception

    Just another perl hacker shooted foot.

    gost, 08 Октября 2017

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    $a = true;
    $b = $a xor true;
    
    var_dump($b);

    ПЫХОПРОБЛЕМЫ

    http://ideone.com/cRMQor

    bool(true)

    someone, 17 Марта 2015

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

    −98

    1. 1
    [1,2,3,11,12,13,14,15,17].to_a

    Чтобы наверняка..

    rezerbit, 12 Февраля 2015

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

    +159

    1. 1
    2. 2
    3. 3
    static function beforeIblockElementAddOrUpdateResetResponseAuthor($fields){
        ...
    }

    n1ce22rus, 21 Ноября 2014

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