1. Java / Говнокод #27228

    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
    {
        "error": false,
        "message": "Ok",
        "data": {
            "countries": [
                {
                    "country": {
                        "id": 24,
                        "iso_a2": "CA",
                        "name": "Canada",
                        "prefix": "1",
                        "vendors": [
                            1
                        ]
                    },
                    "city": {
                        "id": 3723,
                        "region_id": 8,
                        "name": "Toronto",
                        "prefix": "416",
                        "icon_url": null,
                        "setup": 0.25,
                        "monthly": 1.88
                    }
                },
                {
                    "country": {
                        "id": 51,
                        "iso_a2": "IL",
                        "name": "Israel",
                        "prefix": "972",
                        "vendors": [
                            1
                        ]
                    },
                    "city": {
                        "id": 122,
                        "region_id": null,
                        "name": "Jerusalem",
                        "prefix": "2",
                        "icon_url": null,
                        "setup": 0.25,
                        "monthly": 1.88
                    }
                },
                {
                    "country": {
                        "id": 94,
                        "iso_a2": "GB",
                        "name": "United Kingdom",
                        "prefix": "44",
                        "vendors": [
                            1
                        ]
                    },
                    "city": {
                        "id": 4701,
                        "region_id": null,
                        "name": "London",
                        "prefix": "207",
                        "icon_url": null,
                        "setup": 0.25,
                        "monthly": 1.88
                    }
                },
                {
                    "country": {
                        "id": 95,
                        "iso_a2": "US",
                        "name": "United States",
                        "prefix": "1",
                        "vendors": [
                            1,
                            2
                        ]
                    },
                    "city": {
                        "id": 6400,
                        "region_id": 44,
                        "name": "New York",
                        "prefix": "332",
                        "icon_url": null,
                        "setup": 0.25,
                        "monthly": 1.88
                    }
                }
            ]
        }
    }

    CTO написал апишечку для возврата доступных локейшнов по странам для покупки телефонных номеров

    изыск 2021 я такого и в 2000ых не встречал !!!

    alexis-ag, 01 Февраля 2021

    Комментарии (20)
  2. Си / Говнокод #27227

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    char* to_str(int i) {
        char* s = malloc(12);
        sprintf(s, "%d", i);
        return s;
    }

    Как в сишке без RAII принято жить? Пиздец какой-то. Буфер в функцию передавать?

    Что мешает завезти RAII в сишку?

    3_dar, 30 Января 2021

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

    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
    def filter_goods(items, date_registered_from=0, date_registered_to=99999999999, from_finished_entries=0, to_finished_entries=99999, views_from=0, views_to=999999, activeGoodsFrom=0, activeGoodsTo=999999, delete_no_delivery=False, delete_comapnies=False, delete_duplicates=False, published_later_then=0):
        ids = []
        q = Queue()
        for i in items:
            if i[0]['date_created'] >= published_later_then:
                if i[1]['date_registered'] >= date_registered_from:
                    if i[1]['date_registered'] <= date_registered_to:
                        if i[1]['prods_sold_cnt'] >= from_finished_entries:
                            if i[1]['prods_sold_cnt'] <= to_finished_entries:
                                if i[0]['views'] >= views_from:
                                    if i[0]['views'] <= views_to:
                                        if i[1]['prods_active_cnt'] >= activeGoodsFrom:
                                            if i[1]['prods_active_cnt'] <= activeGoodsTo:
                                                if delete_no_delivery:
                                                    if i[0]['delivery_enabled'] or delete_no_delivery == False:
                                                        if not (delete_comapnies and i[1]['type'] == 'person'):
                                                            if delete_comapnies == False:
                                                                if delete_duplicates:
                                                                    if i[0]['owner']['id'] not in ids:
                                                                        ids.append(i[0]['owner']['id'])
                                                                        q.put(i[0]['id'])
                                                                else:
                                                                    q.put(i[0]['id'])
                                                        return q

    Стояла задача написать самый длинный if? Человек не знает про and? Этого мы никогда не узнаем.

    katant, 30 Января 2021

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

    +1

    1. 1
    Немного богословия.

    In the beginning was the word; and version of this Word was 1.0

    Sers, 29 Января 2021

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

    −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
    <?php
    header ('Access-Control-Allow-Origin: *');//Разрешили кроссдоменные запросы
     
    $mysql_host = "хост";
    $mysql_database = "Бд";
    $mysql_user = "Юзернейм";
    $mysql_password = "пОроль";
     
    $link = mysql_connect($mysql_host, $mysql_user, $mysql_password) or die("Ошибка при подключении MySQL" );
    mysql_select_db($mysql_database, $link) or die ('Ошибка при подключении к БД');
     
        if (isset($_POST['login'])) { $login = $_POST['login']; if ($login == '') { unset($login);} }
        if (isset($_POST['password'])) { $password=$_POST['password']; if ($password =='') { unset($password);} }
        if (isset($_POST['email'])) { $email=$_POST['email']; if ($email =='') { unset($email);} }
        if (isset($_POST['silvercoin'])) { $silvercoin=$_POST['silvercoin']; if ($silvercoin =='') { unset($silvercoin);} }
        if (isset($_POST['goldcoin'])) { $goldcoin=$_POST['goldcoin']; if ($goldcoin =='') { unset($goldcoin);} }
    if (empty($login) or empty($password) or empty($email))
        {
        echo ("Вы ввели не всю информацию, заполните все поля!");
        exit();
        }
        $login = stripslashes($login);
        $login = htmlspecialchars($login);
        $password = stripslashes($password);
        $password = htmlspecialchars($password);
        $email = stripslashes($email);
        $email = htmlspecialchars($email);
        $silvercoin = stripslashes($silvercoin);
        $silvercoin = htmlspecialchars($silvercoin);
        $goldcoin = stripslashes($goldcoin);
        $goldcoin = htmlspecialchars($goldcoin);
        $login = trim($login);
        $password = trim($password);
        $email = trim($email);
        $silvercoin = trim($silvercoin);
        $goldcoin = trim($goldcoin);
        $q1 = mysql_query("SELECT login FROM `accounts` WHERE `login`='".$login."'");
        $loginb = mysql_fetch_array($q1);
        $loginbd=$loginb['login'];
        if($loginbd == $login){
        echo("Извините, введённый вами логин уже зарегистрирован.");
        exit();
        }
         else
        $result2 = mysql_query ("INSERT INTO accounts (login,password,email) VALUES('$login','$password','$email')");
        if ($result2=='TRUE')
        {
        echo "Вы успешно зарегистрированы!";
        }
    else {
        echo "Ошибка! Вы не зарегистрированы.";
        }
    ?>

    Использование бредо-заголовок в 2 строке
    Использование Инструмента в 2к21, который в PHP5.5.0 20 июня 2013 Объявлен как устаревший, а в PHP 7.0.0 удален
    Нет задающей кодировки подключения к БД
    Глупая, дешевая валидация данных начиная с 12 и заканчивая 46 строкой
    SQL-injection привет!
    46 строка - невероятно проверять boolean тип
    37 - 39 строка - юзер не найден - лови ошибку!

    Чуть не забыл... скрипт не в кодировке UTF-8 no BOM

    https://php.ru/forum/threads/pomogite-ispravit-oshibku-cannot-modify-header-information-headers-already-sent-by.90359/

    Привет 2010 году !

    MouseZver, 25 Января 2021

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

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    Как известно, язык C# придумал Андерс Хейлсберг. В связи с этим, на первых порах его жутко атаковали журналисты, в попытке снять интервью.
    Делали они это столь навячиво, что обычно вежливый и корректный Хейлсберг стал грубым и несдержанным. Он избегал журналистов, но они не отставали.
    
    Однажды его подстерегли в метро - он едва смог вырваться из назойливой толпы,  -  затем его почти сразу прижали в переулке. 
    -Господин Хейлсберг, пару слов для издания КомпНьюс...
    -Пошли на хуй, - прошептал Андерс, ускорив шаг. В ту же минуту его затерла толпа и на него упал яркий свет. 
    -Прямой эфир!
    Андерс замялся. Уйти из кадра было бы несложно, но это могло сказаться на репутации. Кинооператор уже наставил камеру. 
    Из толпы вышел наиболее задиристый человек с микрофоном.
    -Скажите, господин Хейлсберг, почему Вы добавили в это говно столько сахара? Почему не сделали его ванильным - как Делфи?
    -Потому, что глупо добавлять ванилин в говно, которое будут пробовать на вкус, огрызнулся Хейлсберг, и, тяжко размахнувшись, ударил по объективу дипломатом.

    guest3, 24 Января 2021

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

    +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
    // https://quuxplusone.github.io/blog/2021/01/13/conversion-operator-lookup/
    
    struct A {
        using T = T1;
        using U = U1;
        operator U1 T1::*();
        operator U1 T2::*();
        operator U2 T1::*();
        operator U2 T2::*();
    };
    
    inline auto which(U1 T1::*) { return "gcc"; }
    inline auto which(U1 T2::*) { return "icc"; }
    inline auto which(U2 T1::*) { return "msvc"; }
    inline auto which(U2 T2::*) { return "clang"; }
    
    int main() {
        A a;
        using T = T2;
        using U = U2;
        puts(which(a.operator U T::*()));
    }

    > As of this writing (but perhaps not for very much longer!) the four mainstream compilers on Godbolt Compiler Explorer give four different answers for this simple C++ program:

    > According to the current draft standard, it sounds like the conforming answer is “they should both be looked up in the scope of A”; i.e., GCC’s answer is correct and the others are wrong in three different ways.

    Какой багор )))

    j123123, 21 Января 2021

    Комментарии (5)
  8. PHP / Говнокод #27221

    −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
    <?php 
    		if($theme_options->get( 'header_type' ) == 2) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_02.tpl'); 
    		} elseif($theme_options->get( 'header_type' ) == 3) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_03.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 4) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_04.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 5) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_05.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 6) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_06.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 7) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_07.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 8) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_08.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 9) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_09.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 10) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_10.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 11) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_11.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 12) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_12.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 13) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_13.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 14) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_14.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 15) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_15.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 16) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_16.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 17) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_17.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 18) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_18.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 19) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_19.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 20) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_20.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 21) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_21.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 22) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_22.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 23) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_23.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 24) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_24.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 25) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_25.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 26) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_26.tpl');
    		} elseif($theme_options->get( 'header_type' ) == 27) {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_27.tpl');
    		} else {
    			include('catalog/view/theme/'.$config->get('config_template').'/template/common/header/header_01.tpl');
    		}	
    		?>

    phpBidlokoder2, 21 Января 2021

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

    +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
    void testToken(const char *value, size_t tokenExpected)
    {
        antlr4::ANTLRInputStream input(value);
        typescript::TypeScriptLexerANTLR lexer(&input);
    
        auto tokens = lexer.getAllTokens();
    
        printTokens(lexer, tokens);
    
        auto token = tokens.front().get();
    
        std::ostringstream stringStream;
        stringStream << "Expecting: [" << lexer.getTokenNames()[tokenExpected] << "] \"" << value << "\" but get: [" << lexer.getTokenNames()[token->getType()] << "] \"" << token->getText() << "\".";
        auto msg = stringStream.str();    
    
        ASSERT_EQUAL_MSG(token->getType(), tokenExpected, msg);
        ASSERT_THROW_MSG(token->getText().compare(value) == 0, msg);
    }
    
    void testOctalIntegerLiteral()
    {
        testToken("01", l::OctalIntegerLiteral);
    }

    Мой расказ о том как жизни было нехрен делать и я начал писать копилятор для TypeScript. как это "пинание х..я" кончиться я не знаю. но вот начал с простого. собрал минимум для разработки это LLVM и ANTLR4. И уже написал свой первый (ну не совсем) lexer.

    вот тут можно посмотреть на убогость говнокода.
    https://github.com/ASDAlexander77/TypeScriptCompiler

    ASD_77, 20 Января 2021

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

    0

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

    #49: https://govnokod.ru/26750 https://govnokod.xyz/_26750
    #49: https://govnokod.ru/26776 https://govnokod.xyz/_26776
    #50: https://govnokod.ru/26804 https://govnokod.xyz/_26804
    #51: https://govnokod.ru/26809 https://govnokod.xyz/_26809
    #52: https://govnokod.ru/26817 https://govnokod.xyz/_26817
    #53: https://govnokod.ru/26833 https://govnokod.xyz/_26833
    #54: https://govnokod.ru/26840 https://govnokod.xyz/_26840
    #55: https://govnokod.ru/26844 https://govnokod.xyz/_26844
    #56: https://govnokod.ru/26862 https://govnokod.xyz/_26862
    #57: https://govnokod.ru/26890 https://govnokod.xyz/_26890
    #58: https://govnokod.ru/26916 https://govnokod.xyz/_26916
    #59: https://govnokod.ru/26934 https://govnokod.xyz/_26934
    #60: https://govnokod.ru/26949 https://govnokod.xyz/_26949
    #61: https://govnokod.ru/26980 https://govnokod.xyz/_26980
    #62: https://govnokod.ru/26999 https://govnokod.xyz/_26999
    #63: https://govnokod.ru/27004 https://govnokod.xyz/_27004
    #64: https://govnokod.ru/27020 https://govnokod.xyz/_27020
    #65: https://govnokod.ru/27027 https://govnokod.xyz/_27027
    #66: https://govnokod.ru/27040 https://govnokod.xyz/_27040
    #67: https://govnokod.ru/27049 https://govnokod.xyz/_27049
    #68: https://govnokod.ru/27061 https://govnokod.xyz/_27061
    #69: https://govnokod.ru/27071 https://govnokod.xyz/_27071
    #70: https://govnokod.ru/27097 https://govnokod.xyz/_27097
    #71: https://govnokod.ru/27115 https://govnokod.xyz/_27115
    #72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
    #73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
    #74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
    #75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
    #76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
    #77: https://govnokod.ru/27186 https://govnokod.xyz/_27186

    nepeKamHblu_nemyx, 20 Января 2021

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