1. SQL / Говнокод #26417

    +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
    SET @from = 11836;
    SET @to = 11840;
    
    INSERT INTO `sprinter_catalog_tree` (
        `sprinter_catalog_tree`.`level`,
        `sprinter_catalog_tree`.`position`,
        `sprinter_catalog_tree`.`parent_id`,
        `sprinter_catalog_tree`.`catalog`,
        `sprinter_catalog_tree`.`info_id`,
    --  ...
    )
    SELECT
        `sprinter_catalog_tree`.`level`,
        `sprinter_catalog_tree`.`position`,
        @to,
        `sprinter_catalog_tree`.`catalog`,
        `sprinter_catalog_tree`.`info_id`,
        `sprinter_catalog_tree`.`format_id`,
        `sprinter_catalog_tree`.`linked_id`,
        `sprinter_catalog_tree`.`linked_shablon_id`,
    --  ...
    FROM `sprinter_catalog_tree` where parent_id = @from order by id;
    
    INSERT INTO `sprinter_catalog_tree` (
        `sprinter_catalog_tree`.`level`,
        `sprinter_catalog_tree`.`position`,
        `sprinter_catalog_tree`.`parent_id`,
        `sprinter_catalog_tree`.`catalog`,
        `sprinter_catalog_tree`.`info_id`,
    --  ...
    )
    SELECT
        a.`level`,
        a.`position`,
        (SELECT id from sprinter_catalog_tree as b where b.parent_id = @to and b.name like (SELECT name from sprinter_catalog_tree where id = a.parent_id)),
        a.`catalog`,
        a.`info_id`,
        a.`format_id`,
        a.`linked_id`,
        a.`linked_shablon_id`,
    --  ...
    FROM `sprinter_catalog_tree` as a where parent_id in (SELECT id FROM sprinter_catalog_tree where parent_id = @from) order by id;
    
    INSERT INTO `sprinter_catalog_info`
    (`name`,
    `eng_name`,
    `text`,
    --  ..
    )
    SELECT
        `sprinter_catalog_info`.`name`,
        `sprinter_catalog_info`.`eng_name`,
        `sprinter_catalog_info`.`text`,
        `sprinter_catalog_info`.`short_text`,
    --  ...
    FROM `sprinter_catalog_info` where id in (SELECT info_id from `sprinter_catalog_tree` where parent_id = @from or parent_id in (SELECT id from `sprinter_catalog_tree` where parent_id = @from));
    
    CREATE temporary table if not exists ids
    SELECT id from `sprinter_catalog_tree` where parent_id = @to or parent_id in (SELECT id from `sprinter_catalog_tree` where parent_id = @to);
    
    UPDATE sprinter_catalog_tree as a SET info_id = (SELECT id from sprinter_catalog_info as b where a.name like b.name order by id desc limit 1) where a.id in (SELECT id from ids);
    
    DROP table ids;

    Высрал вот такое говно в качестве write-n-throw скрипта.

    Дано: есть элементы дерева, хранящиеся в таблице sprinter_catalog_tree, связаны друг с другом через parent_id. Каждому из них соответствует указанный в info_id элемент таблицы sprinter_catalog_info.

    Задача: скопировать все вложенные в раздел @from каталога элементы и его подразделы (вложенность не более 1 уровня) в раздел @to, так чтобы у них были новые id, и также скопировать соответствующие им sprinter_catalog_info. Скопированные sprinter_catalog_tree должны указывать на корректные sprinter_catalog_info, id которых заранее не известны.

    Вот такое говно получилось, расскажите как надо было?

    vistefan, 05 Февраля 2020

    Комментарии (194)
  2. JavaScript / Говнокод #26415

    +3

    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
    var   words=
        [
     
            {   
                 'тупая русня ':1/10
                ,'на бутылку':1/8
                ,'у тебя же прыщи':1/12
                ,'руснявый':1/8
                ,'прыщеблядский':1/8
                ,',обоссался':1/10
                ,'обоссал':1/10
                ,', маму твою ебал,':1/12
                ,'стекломойная русня':1/8
                ,'гермашка': 1/10
                ,'туши пердак':1/8
            }
            ,{
                'садись на бутылку':1/8
            }
            ,{'стекломойный русачок':1/11,' пуйло':1/7,'ко-ко-ко':1/6,'рашка':1/10,', пидорахен':1/10}        
            ,{'пидораха,': 1/6,', пидораха полыхнула,': 1/12
                ,'козлодойч': 1/12
                ,'гермашка': 1/10
             }
            ,{  
                'свинособака':1/6
                ,', мамку ебал,':1/12
                ,'бамп отсосу ':1/13
                ,', маму твою,':1/12            
                ,'скрепы':1/11
                ,' пидораха,':1/8
                ,'cтекломойный':1/8
                ,'стекломоя наебнул':1/8
                ,'садись на бутылку':1/10
                ,'днище':1/7
                ,'русня':1/9
                ,'кремлебот ':1/6
                ,'порватка':1/10            
                ,'порвался':1/15
                ,'руснявая пидараха': 1/11
                ,'бубарех': 1/10
                ,'хуйня': 1/10
                ,'залупин': 1/13
                ,'хуйло': 1/12
            }
    ];

    Словарь слов-маркеров анона с /po для склейки крупных кусков кобенады и твердой мелкой психозы.

    Даже простейший скрипт, рандомно вставляющий данные фразы показывает весьма аутентичный результат.

    3.14159265, 05 Февраля 2020

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

    0

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

    #1: https://govnokod.ru/18142 https://govnokod.xyz/_18142
    #2: https://govnokod.ru/18378 https://govnokod.xyz/_18378
    #3: https://govnokod.ru/19667 https://govnokod.xyz/_19667
    #4: https://govnokod.ru/21160 https://govnokod.xyz/_21160
    #5: https://govnokod.ru/21772 https://govnokod.xyz/_21772
    #6: https://govnokod.ru/24063 (потёр пидор сракер) https://govnokod.xyz/_24063
    #7: https://govnokod.ru/24538 https://govnokod.xyz/_24538
    #8: https://govnokod.ru/24815 (потёр пидор сракер) https://govnokod.xyz/_24815
    #9: https://govnokod.ru/24867 https://govnokod.xyz/_24867
    #10: https://govnokod.ru/25328 https://govnokod.xyz/_25328
    #11: https://govnokod.xyz/_25436 https://govnokod.ru/25436 (потёр пидор сракер)
    #12: https://govnokod.xyz/_25471
    #13: https://govnokod.xyz/_25590 (потёр пидор сракер)
    #14: https://govnokod.xyz/_25684
    #15: https://govnokod.xyz/_25694
    #16: https://govnokod.xyz/_25725
    #17: https://govnokod.xyz/_25731
    #18: https://govnokod.xyz/_25762
    #19: https://govnokod.xyz/_25767
    #20: https://govnokod.xyz/_25776
    #21: https://govnokod.xyz/_25798
    #22: https://govnokod.xyz/_25811
    #23: https://govnokod.xyz/_25863
    #24: https://govnokod.xyz/_25941
    #25: https://govnokod.xyz/_26026
    #26: https://govnokod.xyz/_26050
    #27: https://govnokod.xyz/_26340
    #28: https://govnokod.xyz/_26372
    #29: https://govnokod.xyz/_26385

    syoma, 04 Февраля 2020

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

    +6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    # coding: inlinec
    from inlinec import inlinec
    
    @inlinec
    def test():
        #include<stdio.h>
        void test() {
            printf("Hello, world");
        }

    https://www.opennet.ru/opennews/art.shtml?num=52306 - Inlinec - новый способ использования Си-кода в Python-скриптах

    Сишные вставки в питоне

    j123123, 04 Февраля 2020

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

    +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
    define method display (i :: <integer>)
      do-display-integer(i);
    end;
    
    define method display (s :: <string>)
      do-display-string(s);
    end;
    
    define method display (f :: <float>)
      do-display-float(f);
    end;
    
    define method display (c :: <collection>)
      for (item in c)
        display(item);  // runtime dispatch
      end;
    end;

    В закромах истории нашёлся язык с runtime dispatch/multimethods.

    Desktop, 03 Февраля 2020

    Комментарии (20)
  6. JavaScript / Говнокод #26409

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    for (var i = 0; i < self.Collection().length; i++) {
                ///НЕ УДАЛЯЙТЕ ОТОРВУ РУКИ!!!!!
                if (self.Collection()[i].IsSecuringApplications() == true) {
                    continue;
                }
                TotalContractSumm = Math.round((TotalContractSumm + parseFloat(self.Collection()[i].ContractGuarantee)) * 100) / 100;
                TotalApplicationSumm = Math.round((TotalApplicationSumm + parseFloat(self.Collection()[i].ApplicationGuarantee)) * 100) / 100;
    }

    Вот что бывает, когда нет code review.

    sevser, 03 Февраля 2020

    Комментарии (16)
  7. Kotlin / Говнокод #26408

    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
    data class User(
    
        @Expose
        @SerializedName("email")
        val email: String? = null,
    
        @Expose
        @SerializedName("username")
        val username: String? = null,
    
        @Expose
        @SerializedName("image")
        val image: String? = null
    ) {
        override fun toString(): String {
            return "User(email=$email, username=$username, image=$image)"
        }
    }

    JetBrains сделали прекрасный стандартный toString у дата классов, а они всё равно пишут свой туСтринг, который выдаёт результат в точности повторяющий стандартный.

    https://github.com/mitchtabian/MVIExample/blob/master/app/src/main/java/com/codingwithmitch/mviexample/model/User.kt

    Gorr, 03 Февраля 2020

    Комментарии (76)
  8. Perl / Говнокод #26407

    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
    $the_cow = <<EOC;
          $thoughts
           $thoughts                            @@@###==#######@#@@@@@@@@@@@@
                                       @@@###====***====##########@@@@#
                                       @@@###===***++********===###@@@#
                                      #@@###==*****+++++++++**===##@@@#
                                      =@@#####==****++++++++***==###@@@
                                     #@@=##======*++*+++++***===###@@#
                                     #@#===###===#**+++++*+***==###@#
                                     @###**#=*++==#=****==#===####@@#
                                    ##====**==***+==++==##@###=###@@#
                     ###=====***=######====*******==*+*=*+***=##=###
                ###====******+++*=#####===******===**==*****====##
              #===*******++++++++=######==******#=***==******==##
            #===******+++++++++++*=#####==**+++=#=*+*==****==####
          #===****++++++++++++++++*=####=**++++**=====*+***==###=###
        ##==****++++++++++++++++++*=####===***===*=*=**+***==##**===###
       ##==***++++++++++++++++++++*#######=======*====****==##=***====###
      ##==***+++++++++++++++:+++++*######===#@@@@@@##=====##===****=====##
      #===***++++++++++++++++++++*=########===@@@@@@@######=====**++*=====##@@
     ##===*****++*++++++++++++++**=####@@@@@##=====####@##=======******====###
    ###===***********+++++++++++***=####@#@######=##@@###===#===*********====#
    ##====*************+*****+******=###@@#@##@##@@@####======*****+******====
    ###===***************************=##@@@@@@@@######=======****++++*+****===
    @##=====**************************===#########=#========*****++++++++**===
    ###======*********************========######================**********====
    ####=======****=**********==================================**=*==***=====
    ####============***====*=======================================*=**======#

    Пахом для cowsay

    ExModE, 03 Февраля 2020

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

    +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
    function send_message_with_photo($token, $peer_id, $message, $image_file_path) {
        $ch = curl_init();
    
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
    
        /* Получаем ссылку для загрузки фотографии */
    
        curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/photos.getMessagesUploadServer');
        curl_setopt($ch, CURLOPT_POSTFIELDS, array(
            "access_token" => $token,
            "v" => "5.103"
        ));
    
        $result = json_decode(curl_exec($ch), true);
    
        $upload_url = $result['response']['upload_url'];
    
        /* Отправляем фотографию */
    
        curl_setopt($ch, CURLOPT_URL, $upload_url);
        $file = curl_file_create($image_file_path);
        curl_setopt($ch, CURLOPT_POSTFIELDS, array(
            "photo" => $file,
        ));
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
    
        $result = json_decode(curl_exec($ch), true);
    
        $server = $result['server'];
        $photo = $result['photo'];
        $hash = $result['hash'];
    
        /* Сохраняем фотографию */    
    
        curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/photos.saveMessagesPhoto');
        curl_setopt($ch, CURLOPT_POSTFIELDS, array(
            "access_token" => $token,
            "v" => "5.103",
            "server" => $server,
            "photo" => $photo,
            "hash" => $hash
        ));
    
        $result = json_decode(curl_exec($ch), true);
    
        $photo_id = strval($result['response'][0]['id']);
        $owner_id = strval($result['response'][0]['owner_id']);
    
        $attachment = "photo" . $owner_id . "_" . $photo_id;
    
        /* Отправляем сообщение */
    
        curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/messages.send');
        curl_setopt($ch, CURLOPT_POSTFIELDS, array(
            "access_token" => $token,
            "v" => "5.103",
            "random_id" => rand(),
            "peer_id" => $peer_id,
            "message" => $message,
            "attachment" => $attachment 
        ));
    
        $result =  json_decode(curl_exec($ch), true);
    
        curl_close($ch);
    }

    Говнокод для загрузки фото в ВК)

    kaluginvlad, 01 Февраля 2020

    Комментарии (104)
  10. Python / Говнокод #26402

    −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
    95. 95
    96. 96
    97. 97
    g = {'А', 'Е', 'Ё', 'И', 'У', 'О', 'Я', 'Ы', 'Э', 'Ю'}
    s = input().split()
    last = -1
    start = -1
    first = 0
    f = 0
    GL = 0
    gl = 0
    cnt = 0
    el = s[0]
    if len(s) == 1:
        el = s[0]
        for i in range(len(el)):
            if el[i].isupper() and el[i] not in g:
                print('ошибка')
                exit()
            if el[i].isupper() and f:
                print('ошибка')
                exit()
            if el[i].upper() in g:
                gl += 1
                GL += 1
            if el[i].isupper():
                start = gl
                f = 1
        if gl and not f:
            print('ошибка')
            exit()
        if start == -1:
            print('не стихи')
            exit()
        if (start == 2 and gl == 3) \
                or (start == 1 and gl == 2) \
                or (start == 2 and gl == 2):
            print('недостаточно информации')
            exit()
    last = -1
    start = -1
    first = 0
    GL = 0
    f = 0
    gl = 0
    cnt = 0
    el = s[0]
    while start == -1 and first < len(s):
        el = s[first]
        first += 1
        for i in range(len(el)):
            if el[i].isupper() and el[i] not in g:
                print('ошибка')
                exit()
            if el[i].isupper() and f:
                print('ошибка')
                exit()
            if el[i].upper() in g:
                gl += 1
                GL += 1
            if el[i].isupper():
                start = gl
                gl = 0
                f = 1
        if gl and not f:
            print('ошибка')
            exit()
    if start == -1:
        print('не стихи')
        exit()
    cnt = gl
    for k in range(first, len(s)):
        el = s[k]
        f = 0
        gl = 0
        cnt = cnt
        for i in range(len(el)):
            if el[i].upper() in g:
                cnt += 1
                gl += 1
                GL += 1
            if el[i].isupper() and el[i] not in g:
                print('ошибка')
                exit()
            if el[i].isupper() and f:
                print('ошибка')
                exit()
            if el[i].isupper():
                if last == -1:
                    last = cnt
                    cnt = 0
                elif cnt != last:
                    print('не стихи')
                    exit()
                else:
                    cnt = 0
                f = 1
        if gl and not f:
            print('ошибка')
            exit()

    if GL == 1:
    print('не стихи')
    exit()
    if start > 3 or last > 3 or cnt > 2:
    print('не стихи')
    exit()
    if start == 1:
    if last == 2 and cnt < last:
    print('хорей')
    elif (last == 3 or last == -1) \
    and cnt < 3:
    print('дактиль')
    else:
    print('не стихи')
    elif start == 2:
    if (last == 2 and cnt < last) \
    or last == -1:
    print('ямб')
    elif last == 3:
    print('амфибрахий')
    else:
    print('не стихи')
    elif start == 3 \
    and (last == 3 or last == -1):
    print('анапест')
    else:
    print('не стихи')

    kodic, 31 Января 2020

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