1. PHP / Говнокод #26445

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $dbSort = Array("SORT" => "ASC");
    $dbFilter = Array("IBLOCK_ID" => $arResult["IBLOCK_ID"], "ID" => $arResult["ID"]);
    $dbSelect = Array("UF_MODEL_HEADLINE", "UF_CALC_HEADLINE", "UF_H1", "UF_ADVANTAGE_TITLE");
    $db_list = CIBlockSection::GetList($dbSort, $dbFilter, false, $dbSelect);
    $result = $db_list->GetNext();
    $arResult["MODEL_HEADLINE"] = $result["UF_MODEL_HEADLINE"];
    $arResult["CALC_HEADLINE"] = $result["UF_CALC_HEADLINE"];
    $arResult["UF_H1"] = $result["UF_H1"];
    $arResult["UF_ADVANTAGE_TITLE"] = $result["UF_ADVANTAGE_TITLE"];

    phpBidlokoder2, 21 Февраля 2020

    Комментарии (14)
  2. Python / Говнокод #26444

    +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
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    def generate_set(max_size, base_images, samples_per_image=100):
        assert len(base_images) == CHARS_NUM
        input_vec_len = max_size[0] * max_size[1]
        output_vec_len = CHARS_NUM
        set_size = samples_per_image * CHARS_NUM
        
        x_set = np.empty(shape=(set_size, input_vec_len))
        y_set = np.empty(shape=(set_size, output_vec_len))
    
        sample_num = 0
        for c, img in base_images.items():
            for _ in range(samples_per_image):
                x_set[sample_num] = generate_distorted_sample(img)
                y_set[sample_num] = char_to_onehot(c)
                sample_num += 1
        # LOL
        rng_state = np.random.get_state()
        np.random.shuffle(x_set)
        np.random.set_state(rng_state)
        np.random.shuffle(y_set)
        return x_set, y_set

    ТУРЕЛЬ: 1-1 сорцовый кобенный генератор по мотивам: https://govnokod.ru/26434#comment527875.
    https://github.com/gost-gk/turel
    Принцимп мухи: берём символы русского алфамита с цифрами/пуньктуацией, генерируем из них слегка искажённые картинки, тренируем элементарную модельку —

    optimizer = keras.optimizers.Adagrad(learning_rate=0.02)
    model = Sequential()
    model.add(Dense(units=CHARS_NUM * 2, activation='relu', input_dim=input_vec_len))
    model.add(Dense(units=CHARS_NUM, activation='softmax'))
    model.compile(loss='categorical_crossentropy',
    optimizer=optimizer,
    metrics=['accuracy'])

    — и пропускаем через неё входную сорцовую психозу. Настоящий «OCR»!
    Благодаря тому, что на английских символах модель не обучалась, при распознавании сорцов получается кобенный эффект.

    Моделька обучается очень быстро, десятка эпох (примерно по секунде на эпоху на моём корыте) достаточно для 97-98% точности распознавания искажённых символов.

    gost, 21 Февраля 2020

    Комментарии (156)
  3. PHP / Говнокод #26443

    0

    1. 1
    2. 2
    3. 3
    4. 4
    <?php $o_ids = array();
    foreach ($orders_num as $thiso){array_push($o_ids, $thiso->id);}
    echo implode(", ", $o_ids);
    ?>

    Найдено в дебрях легаси

    fiammathegreat, 19 Февраля 2020

    Комментарии (171)
  4. JavaScript / Говнокод #26442

    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
    // sorry, I don't want to use any JS templater
    // so I'll concatenate html as strings, which is the worst practice
    // but my IntelliJ IDEA highlights html in strings well :)
    // and I write this code just4fun
    //
    // but to respect production I'll leave here something that will never be fixed
    // TODO: rewrite in Angular.js
    //
    // done!
    
    // ...
    
    // u still read this spaghetti?
    
    let evaluate = (s) => {
        completion = [];
        hist = [];
    
        let tokens = s.split(' ').filter((s) => s !== '');
    
        if (!tokens[0]) return;
        histfile.push(s);
    
        if (tokens[0] === 'clear') clear();
        else if (tokens[0] === 'aplay') aplay();
        else if (tokens[0] === 'man') try {
            template(tokens.slice(0, 2).join('_'))();
        } catch {
            stdout('No manual entry for <span class="red">' + tokens[1] + '</span>')
        }

    Сайт-визитка на plain js для подкаста в виде эмулятора терминала с пасхалками
    https://deveeps.prost.host/

    vistefan, 19 Февраля 2020

    Комментарии (67)
  5. JavaScript / Говнокод #26441

    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
    $('#search-map').on('click', '.v-card-prev', function () {
                var v_next = $(this)
                    .parent()
                    .find('.v-card-img-block .v-card-img-hidden.active')
                    .prev();
                if ($(v_next).length == 0) {
                    $(this)
                        .parent()
                        .find('.v-card-img-hidden.active')
                        .removeClass('active');
                    $(this)
                        .parent()
                        .find('.v-card-img-hidden:last')
                        .addClass('active');
                } else {
                    $(this)
                        .parent()
                        .find('.v-card-img-hidden.active')
                        .removeClass('active');
                    $(this)
                        .parent()
                        .find(v_next)
                        .addClass('active');
                }
                $(this)
                    .parent()
                    .find('.v-card-img-hidden.active')
                    .click();
            });
    
            $('#search-map').on('click', '.offers-favorite', function () {
                var favorID = $(this)
                    .closest('.js__product')
                    .attr('data-item');
                if ($(this).hasClass('active')) var doAction = 'delete';
                else var doAction = 'add';
                updateFavorite(favorID, doAction);
                return false;
            });

    phpBidlokoder2, 18 Февраля 2020

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

    0

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

    #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.xyz/_24063
    #7: https://govnokod.ru/24538 https://govnokod.xyz/_24538
    #8: (оригинал удалён) 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
    #12: (оригинал удалён) https://govnokod.xyz/_25471
    #13: (оригинал удалён) 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

    gost, 17 Февраля 2020

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

    +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
    #include <iostream>
    #include <map>
    
    std::map<std::string, int> get_map()
    {
        return {
            { "hello", 1 },
            { "world", 2 },
            { "it's",  3 },
            { "me",    4 },
        };
    }
    
    int main()
    {
        for (auto&& [ k, v ] : get_map())
            std::cout << "k=" << k << " v=" << v << '\n';
    
        return 0;
    }

    govnokod3r, 15 Февраля 2020

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    БОЖЕСТВЕННЫЙ СУДЪ
    МАТУШКА ЛИЧНОЕ ИМЯ РОДА В ЧЕСТИ ИНГА
    ЗАПРЕЩЕНО НАРУШАТЬ КОН СВОБОДНОЙ ВОЛИ
    УТВЕРЖДЕНО

    Пост для обсуждания, разработки и каталогизации живых доброй души коберодных вореций.

    Срать тут:

    gost, 15 Февраля 2020

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

    0

    1. 1
    https://mangalib.me/fisheye-placebo/v1/c1?page=3

    именно поэтому я за «‎SSH-соединение»

    Fike, 13 Февраля 2020

    Комментарии (120)
  10. Pascal / Говнокод #26436

    +5

    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
    begin
                     G4.Caption:='X';
                     if G5.Caption='' then
                     begin
                       G5.Caption:='X';
                       if G6.Caption='' then
                       begin
                         G6.Caption:='X';
                         if G7.Caption='' then
                         begin
                           G7.Caption:='X';
                           if G8.Caption='' then G8.Caption:='X' else
                           if sg8=1 then
                              G8.Font.Style:=[fsBold,fsStrikeOut];
                         end else
                         if sg7=1 then
                            G7.Font.Style:=[fsBold,fsStrikeOut];
                       end else
                       if sg6=1 then
                          G6.Font.Style:=[fsBold,fsStrikeOut];
                     end else
                     if sg5=1 then
                        G5.Font.Style:=[fsBold,fsStrikeOut];
                   end else
                   if sg4=1 then
                      G4.Font.Style:=[fsBold,fsStrikeOut];
                 end else
                 if sg3=1 then
                    G3.Font.Style:=[fsBold,fsStrikeOut];
               end else
               if sg2=1 then
                  G2.Font.Style:=[fsBold,fsStrikeOut];
               if H2.Caption='' then H2.Caption:='X' else
               if sh2=1 then H2.Font.Style:=[fsBold,fsStrikeOut];
               if F2.Caption='' then
               begin
                 F2.Caption:='X';
                 if E3.Caption='' then
                 begin
                   E3.Caption:='X';
                   if D4.Caption='' then
                   begin
                     D4.Caption:='X';
                     if C5.Caption='' then
                     begin
                       C5.Caption:='X';
                       if B6.Caption='' then
                       begin
                         B6.Caption:='X';
                         if A7.Caption='' then A7.Caption:='X' else
                         if sa7=1 then
                         A7.Font.Style:=[fsBold,fsStrikeOut];
                       end else
                       if sb6=1 then
                       B6.Font.Style:=[fsBold,fsStrikeOut];
                     end else
                     if sc5=1 then
                     C5.Font.Style:=[fsBold,fsStrikeOut];
                   end else
                   if sd4=1 then
                   D4.Font.Style:=[fsBold,fsStrikeOut];
                 end else
                 if se3=1 then
                 E3.Font.Style:=[fsBold,fsStrikeOut];
               end else
               if sf2=1 then
               F2.Font.Style:=[fsBold,fsStrikeOut];
             end;
          6: begin //Король
        {E1}   if ((se1=1) and not ((E1.Caption<>'Ферзь') or (E1.Caption<>'Ладья') or (E1.Caption<>'Король')) or
        {D1}   ((sd1=1) and not ((E1.Caption='') and ((D1.Caption='Ферзь') or (D1.Caption='Ладья')))) or
        {C1}   ((sc1=1) and not (((E1.Caption='') and (D1.Caption='')) and ((C1.Caption='Ферзь') or (C1.Caption='Ладья')))) or
        {B1}   ((sb1=1) and not (((E1.Caption='') and (D1.Caption='') and (C1.Caption='')) and ((B1.Caption='Ферзь') or (B1.Caption='Ладья')))) or
        {A1}   ((sa1=1) and not (((E1.Caption='') and (D1.Caption='') and (C1.Caption='') and (B1.Caption='')) and ((A1.Caption='Ферзь') or (A1.Caption='Ладья')))) or
        {E2}   ((se2=1) and not ((E2.Caption='Слон') or (E2.Caption='Ферзь') or (E2.Caption='Пешка') or (E2.Caption='Король'))) or
        //ПРОДОВЖИТИ
        {D3}   ((sd3=1) and not ((E2.Caption='') and ((D3.Caption='Ферзь') or (D3.Caption='Слон')))) or
        {C4}   ((sc4=1) and not (((E2.Caption='') and (D3.Caption='')) and ((C4.Caption='Ферзь') or (C4.Caption='Слон')))) or
        {B5}   ((sb5=1) and not (((E2.Caption='') and (D3.Caption='') and (C4.Caption='')) and ((B5.Caption='Ферзь') or (B5.Caption='Слон')))) or
        {A6}   ((sa6=1) and not (((E2.Caption='') and (D3.Caption='') and (C4.Caption='') and (B5.Caption='')) and ((A6.Caption='Ферзь') or (A6.Caption='Ладья')))) or
        {F2}   ((sf2=1) and not (E2.Caption='Ладья') or (E2.Caption='Ферзь')) or
        {F3}   ((sf3=1) and not ((F2.Caption='') and ((F3.Caption='Ферзь') or (F3.Caption='Ладья')))) or
        {F4}   ((sf4=1) and not (((F2.Caption='') and (F3.Caption='')) and ((F4.Caption='Ферзь') or (F4.Caption='Ладья')))) or
        {F5}   ((sf5=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='')) and ((F5.Caption='Ферзь') or (F5.Caption='Ладья')))) or
        {F6}   ((sf6=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='')) and ((F6.Caption='Ферзь') or (F6.Caption='Ладья')))) or
        {F7}   ((sf7=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='') and (F6.Caption='')) and ((F7.Caption='Ферзь') or (F7.Caption='Ладья')))) or
        {F8}   ((sf8=1) and not (((F2.Caption='') and (F3.Caption='') and (F4.Caption='') and (F5.Caption='') and (F6.Caption='') and (F7.Caption='')) and ((F8.Caption='Ферзь') or (F8.Caption='Ладья')))) or
        {G2}   ((sg2=1) and not (G2.Caption='Ферзь') or (G2.Caption='Слон')) or
        {H3}   ((sh3=1) and not ((G2.Caption='') and ((H3.Caption='Ферзь') or (H3.Caption='Слон')))) or
        {H1}   ((sh1=1) and not (H1.Caption'Ферзь') or (H1.Caption='Слон')) or
       {Кони}  ((sh2=1) and not (H2.Caption='Конь')) or ((sg3=1) and not (G3.Caption='Конь')) or  ((se3=1) and not (E3.Caption='Конь')) or  ((sd2=1) and not(D2.Caption='Конь'))
               ) then if (F1.Caption='') then F1.Caption:='X' else
               if sf1=1 then F1.Font.Style:=[fsBold,fsStrikeOut];
             end;

    Как-то на первом или втором курсе недоунивера возникло желание сделать шахматы в ООП на Паскале. Решил закодить 64 кнопки (8*8 поле). Сделал переменные для идентификации хода черных/белых, для 2 режимов, в первом из которых кликаешь на свою фигуру (надпись на кнопке) и тебе показывают доступные ходы ею (Х куда можно поставить фигуру, подчеркнутое название вражеской фигуры при возможность её забрать). Ты кликаешь, поле очищается от подсказок, фигура перемещается, проверка на шах/мат (ад), ход передается другому цвету фигур (Жирное начертание для определения) и режим взаимодействия с игровым полем опять переходит в выбор фигуры. Теоретически закодировав каждую кнопку на все возможные события шахматы были бы закончены полностью. Вот только спустя окончания кодировки первой кнопки я заYAYлся и забросил ибо говнокод вышел в 1000 строк на одну YAYдь кнопку. Разумеется, показать могу лишь часть

    Zick, 12 Февраля 2020

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