1. Список говнокодов пользователя gost

    Всего: 246

  2. PHP / Говнокод #26668

    +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
    public function isSpecial()
    {
        $special_ids = array(
            2222,
            3028,
            3333,
            5555,
            5702,
            6666,
            6700,
            7654,
            7777,
            8451,
            11225
        );
    
        return in_array((int)$this->getId(), $special_ids);
        //return $this->getId() == 2222 || $this->getId() == 3028 || $this->getId() == 3333 || $this->getId() == 5555 || $this->getId() == 5702;
    }

    https://github.com/wiistriker/govnokod_legacy/blob/master/modules/quoter/models/quote.php
    Рекурсивный говнокод.

    gost, 19 Мая 2020

    Комментарии (9)
  3. Python / Говнокод #26666

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    post_content = post_node.xpath('div[@class="entry-content"]')[0]
    post_code_nodes = post_content.xpath('.//code')
    if len(post_code_nodes) > 0:
        post.code = post_code_nodes[0].text
    else:
        post.code = inner_html_ru(post_content)

    Багор.

    gost, 19 Мая 2020

    Комментарии (8)
  4. Python / Говнокод #26665

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    post_content = post_node.xpath('div[@class="entry-content"]')[0]
    post_code_nodes = post_content.xpath('.//code')
    if len(post_code_nodes) > 0:
        post.code = post_code_nodes[0].text
    else:
        post.code = inner_html_ru(post_content)

    Багор.

    gost, 19 Мая 2020

    Комментарии (1)
  5. Куча / Говнокод #26635

    0

    1. 1
    IT Оффтоп #45

    #11: (vanished) https://govnokod.xyz/_25436
    #12: (vanished) https://govnokod.xyz/_25471
    #13: (vanished) https://govnokod.xyz/_25590
    #14: https://govnokod.ru/25684 https://govnokod.xyz/_25684
    #15: https://govnokod.ru/25694 https://govnokod.xyz/_25694
    #16: https://govnokod.ru/25725 https://govnokod.xyz/_25725
    #17: https://govnokod.ru/25731 https://govnokod.xyz/_25731
    #18: https://govnokod.ru/25762 https://govnokod.xyz/_25762
    #19: https://govnokod.ru/25767 https://govnokod.xyz/_25767
    #20: https://govnokod.ru/25776 https://govnokod.xyz/_25776
    #21: https://govnokod.ru/25798 https://govnokod.xyz/_25798
    #22: https://govnokod.ru/25811 https://govnokod.xyz/_25811
    #23: https://govnokod.ru/25863 https://govnokod.xyz/_25863
    #24: https://govnokod.ru/25941 https://govnokod.xyz/_25941
    #25: https://govnokod.ru/26026 https://govnokod.xyz/_26026
    #26: https://govnokod.ru/26050 https://govnokod.xyz/_26050
    #27: https://govnokod.ru/26340 https://govnokod.xyz/_26340
    #28: https://govnokod.ru/26372 https://govnokod.xyz/_26372
    #29: https://govnokod.ru/26385 https://govnokod.xyz/_26385
    #30: https://govnokod.ru/26413 https://govnokod.xyz/_26413
    #31: https://govnokod.ru/26423 https://govnokod.xyz/_26423
    #32: https://govnokod.ru/26440 https://govnokod.xyz/_26440
    #33: https://govnokod.ru/26449 https://govnokod.xyz/_26449
    #34: https://govnokod.ru/26456 https://govnokod.xyz/_26456
    #35: https://govnokod.ru/26463 https://govnokod.xyz/_26463
    #36: https://govnokod.ru/26508 https://govnokod.xyz/_26508
    #37: https://govnokod.ru/26524 https://govnokod.xyz/_26524
    #38: https://govnokod.ru/26539 https://govnokod.xyz/_26539
    #39: https://govnokod.ru/26556 https://govnokod.xyz/_26556
    #40: https://govnokod.ru/26568 https://govnokod.xyz/_26568
    #41: https://govnokod.ru/26589 https://govnokod.xyz/_26589
    #42: https://govnokod.ru/26600 https://govnokod.xyz/_26600
    #43: https://govnokod.ru/26604 https://govnokod.xyz/_26604
    #44: https://govnokod.ru/26627 https://govnokod.xyz/_26627

    gost, 05 Мая 2020

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

    0

    1. 1
    IT Оффтоп #44

    #10: https://govnokod.ru/25328 https://govnokod.xyz/_25328
    #11: (vanished) https://govnokod.xyz/_25436
    #12: (vanished) https://govnokod.xyz/_25471
    #13: (vanished) https://govnokod.xyz/_25590
    #14: https://govnokod.ru/25684 https://govnokod.xyz/_25684
    #15: https://govnokod.ru/25694 https://govnokod.xyz/_25694
    #16: https://govnokod.ru/25725 https://govnokod.xyz/_25725
    #17: https://govnokod.ru/25731 https://govnokod.xyz/_25731
    #18: https://govnokod.ru/25762 https://govnokod.xyz/_25762
    #19: https://govnokod.ru/25767 https://govnokod.xyz/_25767
    #20: https://govnokod.ru/25776 https://govnokod.xyz/_25776
    #21: https://govnokod.ru/25798 https://govnokod.xyz/_25798
    #22: https://govnokod.ru/25811 https://govnokod.xyz/_25811
    #23: https://govnokod.ru/25863 https://govnokod.xyz/_25863
    #24: https://govnokod.ru/25941 https://govnokod.xyz/_25941
    #25: https://govnokod.ru/26026 https://govnokod.xyz/_26026
    #26: https://govnokod.ru/26050 https://govnokod.xyz/_26050
    #27: https://govnokod.ru/26340 https://govnokod.xyz/_26340
    #28: https://govnokod.ru/26372 https://govnokod.xyz/_26372
    #29: https://govnokod.ru/26385 https://govnokod.xyz/_26385
    #30: https://govnokod.ru/26413 https://govnokod.xyz/_26413
    #31: https://govnokod.ru/26423 https://govnokod.xyz/_26423
    #32: https://govnokod.ru/26440 https://govnokod.xyz/_26440
    #33: https://govnokod.ru/26449 https://govnokod.xyz/_26449
    #34: https://govnokod.ru/26456 https://govnokod.xyz/_26456
    #35: https://govnokod.ru/26463 https://govnokod.xyz/_26463
    #36: https://govnokod.ru/26508 https://govnokod.xyz/_26508
    #37: https://govnokod.ru/26524 https://govnokod.xyz/_26524
    #38: https://govnokod.ru/26539 https://govnokod.xyz/_26539
    #39: https://govnokod.ru/26556 https://govnokod.xyz/_26556
    #40: https://govnokod.ru/26568 https://govnokod.xyz/_26568
    #41: https://govnokod.ru/26589 https://govnokod.xyz/_26589
    #42: https://govnokod.ru/26600 https://govnokod.xyz/_26600
    #43: https://govnokod.ru/26604 https://govnokod.xyz/_26604

    gost, 01 Мая 2020

    Комментарии (595)
  7. C++ / Говнокод #26621

    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
    struct Base { virtual const char *getName() = 0; virtual ~Base() = default; };
    struct SE_0 : Base { virtual const char *getName() override { return "SE_0"; } };
    struct SE_1 : Base { virtual const char *getName() override { return "SE_1"; } };
    struct SE_2 : Base { virtual const char *getName() override { return "SE_2"; } };
    
    enum TypesEnum {
        E__BEGIN = 0,
    
        E_0 = E__BEGIN,
        E_1,
        E_2,
    
        E__END
    };
    
    template<TypesEnum>
    struct Registry {};
    
    template<>
    struct Registry<E_0> {
        static constexpr const char *name = "The first type (SE_0)";
        using type = SE_0;
    };
    
    template<>
    struct Registry<E_1> {
        static constexpr const char *name = "A second type (SE_1)";
        using type = SE_1;
    };
    
    template<>
    struct Registry<E_2> {
        static constexpr const char *name = "And the last type (SE_2)";
        using type = SE_2;
    };
    
    template<TypesEnum CurrentType>
    std::unique_ptr<Base> createTypeImpl(const char *name)
    {
        if constexpr (CurrentType < E__END) {
            if (strstr(Registry<CurrentType>::name, name)) {
                return std::make_unique<typename Registry<CurrentType>::type>();
            }
            return createTypeImpl<static_cast<TypesEnum>(CurrentType + 1)>(name);
        } else {
            (void)name;  // Silence 'unreferenced formal parameter' warning
            return nullptr;
        }
    }
    
    std::unique_ptr<Base> createType(const char *name)
    {
        return createTypeImpl<E__BEGIN>(name);
    }
    
    int main()
    {
        std::cout << "first type: " << createType("first type")->getName() << std::endl;
        std::cout << "second type: " << createType("second type")->getName() << std::endl;
        std::cout << "last type: " << createType("last type")->getName() << std::endl;
    
        return EXIT_SUCCESS;
    }

    Упоролся.
    https://ideone.com/c11fz4

    gost, 29 Апреля 2020

    Комментарии (109)
  8. Куча / Говнокод #26611

    0

    1. 1
    Тестовый оффтоп #1

    Чтобы в «NGK» заблокировать все комменты из этого поста — нажмите на крестик справа от его номера.

    gost, 28 Апреля 2020

    Комментарии (315)
  9. Python / Говнокод #26604

    −1

    1. 1
    IT Оффтоп #43

    #9: https://govnokod.ru/24867 https://govnokod.xyz/_24867
    #10: https://govnokod.ru/25328 https://govnokod.xyz/_25328
    #11: (vanished) https://govnokod.xyz/_25436
    #12: (vanished) https://govnokod.xyz/_25471
    #13: (vanished) https://govnokod.xyz/_25590
    #14: https://govnokod.ru/25684 https://govnokod.xyz/_25684
    #15: https://govnokod.ru/25694 https://govnokod.xyz/_25694
    #16: https://govnokod.ru/25725 https://govnokod.xyz/_25725
    #17: https://govnokod.ru/25731 https://govnokod.xyz/_25731
    #18: https://govnokod.ru/25762 https://govnokod.xyz/_25762
    #19: https://govnokod.ru/25767 https://govnokod.xyz/_25767
    #20: https://govnokod.ru/25776 https://govnokod.xyz/_25776
    #21: https://govnokod.ru/25798 https://govnokod.xyz/_25798
    #22: https://govnokod.ru/25811 https://govnokod.xyz/_25811
    #23: https://govnokod.ru/25863 https://govnokod.xyz/_25863
    #24: https://govnokod.ru/25941 https://govnokod.xyz/_25941
    #25: https://govnokod.ru/26026 https://govnokod.xyz/_26026
    #26: https://govnokod.ru/26050 https://govnokod.xyz/_26050
    #27: https://govnokod.ru/26340 https://govnokod.xyz/_26340
    #28: https://govnokod.ru/26372 https://govnokod.xyz/_26372
    #29: https://govnokod.ru/26385 https://govnokod.xyz/_26385
    #30: https://govnokod.ru/26413 https://govnokod.xyz/_26413
    #31: https://govnokod.ru/26423 https://govnokod.xyz/_26423
    #32: https://govnokod.ru/26440 https://govnokod.xyz/_26440
    #33: https://govnokod.ru/26449 https://govnokod.xyz/_26449
    #34: https://govnokod.ru/26456 https://govnokod.xyz/_26456
    #35: https://govnokod.ru/26463 https://govnokod.xyz/_26463
    #36: https://govnokod.ru/26508 https://govnokod.xyz/_26508
    #37: https://govnokod.ru/26524 https://govnokod.xyz/_26524
    #38: https://govnokod.ru/26539 https://govnokod.xyz/_26539
    #39: https://govnokod.ru/26556 https://govnokod.xyz/_26556
    #40: https://govnokod.ru/26568 https://govnokod.xyz/_26568
    #41: https://govnokod.ru/26589 https://govnokod.xyz/_26589
    #42: https://govnokod.ru/26600 https://govnokod.xyz/_26600

    gost, 27 Апреля 2020

    Комментарии (496)
  10. PHP / Говнокод #26602

    +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
    for ($cycle = 1; $cycle <= 6; $cycle++) {
        $all_tasks = get_all_tasks();
        if ($all_tasks) {
            foreach($all_tasks as $one_task) {
                $lock_file_abs = __DIR__.'/locks/run_'.$one_task['id'];
                $fp = fopen($lock_file_abs,"w+");
                if (flock($fp, LOCK_EX | LOCK_NB)) {
                    solve_one_task($one_task);
                    flock($fp, LOCK_UN);
                }
                else {
                    #не можем запускать обработку задачи
                }
                fclose($fp);
                unlink($lock_file_abs);
            }
        }
        sleep(10);
    }

    «Как запускать cron чаще, чем раз в минуту при помощи PHP»
    https://habr.com/ru/post/498934/

    gost, 25 Апреля 2020

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

    0

    1. 1
    IT Оффтоп #42

    #8: (vanished) https://govnokod.xyz/_24815
    #9: https://govnokod.ru/24867 https://govnokod.xyz/_24867
    #10: https://govnokod.ru/25328 https://govnokod.xyz/_25328
    #11: (vanished) https://govnokod.xyz/_25436
    #12: (vanished) https://govnokod.xyz/_25471
    #13: (vanished) https://govnokod.xyz/_25590
    #14: https://govnokod.ru/25684 https://govnokod.xyz/_25684
    #15: https://govnokod.ru/25694 https://govnokod.xyz/_25694
    #16: https://govnokod.ru/25725 https://govnokod.xyz/_25725
    #17: https://govnokod.ru/25731 https://govnokod.xyz/_25731
    #18: https://govnokod.ru/25762 https://govnokod.xyz/_25762
    #19: https://govnokod.ru/25767 https://govnokod.xyz/_25767
    #20: https://govnokod.ru/25776 https://govnokod.xyz/_25776
    #21: https://govnokod.ru/25798 https://govnokod.xyz/_25798
    #22: https://govnokod.ru/25811 https://govnokod.xyz/_25811
    #23: https://govnokod.ru/25863 https://govnokod.xyz/_25863
    #24: https://govnokod.ru/25941 https://govnokod.xyz/_25941
    #25: https://govnokod.ru/26026 https://govnokod.xyz/_26026
    #26: https://govnokod.ru/26050 https://govnokod.xyz/_26050
    #27: https://govnokod.ru/26340 https://govnokod.xyz/_26340
    #28: https://govnokod.ru/26372 https://govnokod.xyz/_26372
    #29: https://govnokod.ru/26385 https://govnokod.xyz/_26385
    #30: https://govnokod.ru/26413 https://govnokod.xyz/_26413
    #31: https://govnokod.ru/26423 https://govnokod.xyz/_26423
    #32: https://govnokod.ru/26440 https://govnokod.xyz/_26440
    #33: https://govnokod.ru/26449 https://govnokod.xyz/_26449
    #34: https://govnokod.ru/26456 https://govnokod.xyz/_26456
    #35: https://govnokod.ru/26463 https://govnokod.xyz/_26463
    #36: https://govnokod.ru/26508 https://govnokod.xyz/_26508
    #37: https://govnokod.ru/26524 https://govnokod.xyz/_26524
    #38: https://govnokod.ru/26539 https://govnokod.xyz/_26539
    #39: https://govnokod.ru/26556 https://govnokod.xyz/_26556
    #40: https://govnokod.ru/26568 https://govnokod.xyz/_26568
    #41: https://govnokod.ru/26589 https://govnokod.xyz/_26589

    gost, 24 Апреля 2020

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