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

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

    +126

    1. 1
    2. 2
    3. 3
    using питух = String;
    ...
    protected питух AccessToken { get; set; }

    В память о плавающем

    reshetochnik, 24 Августа 2014

    Комментарии (24)
  3. C# / Говнокод #16571

    +134

    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
    String r_count = "";
                String r_cat = "";
                String r_pansion = "";
                for (Int32 ii = 0; ii < rows.Count; ii++)
                {
                    Int32 j = rows[ii].NNight;
                    DateTime d = rows[ii].DateBeg;
                    DateTime d_e = rows[ii].DateEnd;
                    Int32 type = rows[ii].MinLength > 0 ? 3 : 2;
                    j = (type == 3) ? -1 : j;
    
                    Int32 lengthMin = rows[ii].MinLength;
                    if (((d < date1 || d > date2) && type != 3))
                        continue;
                    else
                        if (!(d <= date1 && d_e >= date1 || d <= date2 && d_e >= date2) && date1 != DateTime.MinValue && date2 != DateTime.MaxValue && type == 3)
                            continue;
                    String _r_count = _Rooms[rows[ii].RoomId];
                    String _r_cat = _RoomCat[rows[ii].RoomCatId];
                    String _r_pansion = _Pansions[rows[ii].PansionId];
                    List<String> a = new List<string>();
                    if (_r_count != r_count || _r_cat != r_cat || _r_pansion != r_pansion)
                    {
                        if (!String.IsNullOrEmpty(r_count) && !String.IsNullOrEmpty(r_cat))
                        {
                            Pricing.RoomCat cat = new Pricing.RoomCat();
                            cat.RoomCount = r_count;
                            cat.RoomName = r_cat;
                            cat.PansionName = r_pansion;
    
                            p.rooms.Add(cat);
                        }
                        r_count = _r_count;
                        r_cat = _r_cat;
                        r_pansion = _r_pansion;
                    }

    Краху туроператоров способствовали также и собственные инженеры.

    tablecell, 20 Августа 2014

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

    +134

    1. 1
    2. 2
    3. 3
    class UnathorizedDevice : ArgumentException { public UnathorizedDevice() : base() { } }
    
    class LocalException : ArgumentException { public LocalException(string message) : base(message) { } }

    Говно или не говно? Мне кажется первое

    Smekalisty, 19 Августа 2014

    Комментарии (24)
  5. Java / Говнокод #16487

    +69

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    "add()\n";
    assert((row_indx >= 0 && row_indx <= rows) && 
    (col_indx >= 0 && col_indx < cols)
    );
    
    if(row_indx == rows)
    addRow();
    
    if(init_flag_arr[row_indx][col_indx])
    {
    std::cout « "in moving\n";
    int uninit_i, uninit_j;
    bool found = false;
    for(int i = row_indx; found == false && i < rows; i++)
    for(int j = col_indx; found == false && j < cols; j++)
    if(!init_flag_arr[i][j]) // если флаг == false
    {
    std::cout « "found!\n";
    uninit_i = i;
    uninit_j = j;
    found = true;
    
    }
    if(!found)
    {
    std::cout « "not found!\n";
    addRow(); // добовляем новую строку в матрицу (rows++)
    uninit_i = rows - 1;
    uninit_j = 0;
    }
    
    bool exit = false;
    for(int i = uninit_i, j = uninit_j; exit == false; i--)
    {
    for(; ;j--)
    {
    if(j == col_indx && i == row_indx)
    {
    exit = true;
    break;
    }
    if(j == 0)
    {
    matrix[i][j] = matrix[i - 1][cols - 1];
    init_flag_arr[i][j] = init_flag_arr[i - 1][cols - 1];
    break; 
    }
    matrix[i][j] = matrix[i][j - 1];
    init_flag_arr[i][j] = init_flag_arr[i][j - 1];
    
    }
    j = cols - 1;
    }
    } 
    matrix[row_indx][col_indx] = obj;
    init_flag_arr[row_indx][col_indx] = true;
    std::cout « "end add()\n";
    
    }
    
    // Для дебага, вывод инициализированных ячеек матрицы
    void Matrix::InitTable(std::ostream& os)const // чисто для дебага
    {
    for(int i = 0; i < rows; i++)
    {
    for(int j = 0; j < cols; j++)
    if(!init_flag_arr[i][j])
    os « "false\t";
    else
    os « "true\t";
    os « std::endl;
    }
    }
    // Удаление объекта с матрицы
    void Matrix::remove(int row_indx, int col_indx)
    {
    std::cout « "remove()\n";
    assert((row_indx >= 0 && row_indx < rows) && 
    (col_indx >= 0 && col_indx < cols)
    );
    matrix[row_indx][col_indx] = 0;
    init_flag_arr[row_indx][col_indx] = false;
    
    std::cout « "end remove()\n";
    }
    
    void Matrix::removeRow(int row_indx)
    {
    assert(row_indx >= 0 && row_indx < rows);
    int** new_matrix = new int*[rows - 1];
    bool** new_init_flag_arr = new bool*[rows];
    for(int i = 0; i < rows - 1; i++)
    {
    new_matrix[i] = new int[cols];
    new_init_flag_arr[i] = new bool[cols];
    //for(int j = 0; j < cols; j++)
    //{
    // new_matrix[i][j] = 0;
    // new_init_flag_arr[i][j] = false;
    //}/

    ...

    ana_stasia , 06 Августа 2014

    Комментарии (24)
  6. PHP / Говнокод #16236

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    # http://habrahabr.ru/post/227277/
    # открыл первый попавшийся скрипт на гитхабе по ссылке в посте, дальше не читал
    
    function validate_email($str)
    {
        return preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/',$str);
    }

    Sulik78, 25 Июня 2014

    Комментарии (24)
  7. SQL / Говнокод #16207

    −166

    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
    CREATE OR REPLACE FUNCTION "GET_SOTR_FULL_NAME" (sotr_id in number)
      RETURN  varchar2 IS
    cursor surname (sotr_id number)
     is
      select fc_fam from tsotr
      where tsotr.fk_id=sotr_id;
    cursor name (sotr_id number)
     is
      select fc_name from tsotr
      where tsotr.fk_id=sotr_id;
    cursor patronym (sotr_id number)
     is
      select fc_otch from tsotr
      where tsotr.fk_id=sotr_id;
     fio   varchar2(90);
     fam   varchar2(30);
     im    varchar2(30);
     otch  varchar2(30);
    BEGIN
      open surname (sotr_id);
       fetch surname into fam;
      close surname;
      open name (sotr_id);
       fetch name into im;
      close name;
      open patronym (sotr_id);
       fetch patronym into otch;
      close patronym;
       fio:=fam||' '||im||' '||otch;
      return fio;
    END;

    По ИД сотрудника получаем его ФИО

    Dimm_J, 23 Июня 2014

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

    +126

    1. 1
    2. 2
    put = "hello"
    put put # Гениально!

    Ну что же, открылся онлайн интерпретатор Lapis-а на отдельном сайте!
    http://lapis.at.ua/Lapis.htm

    Mobac, 10 Мая 2014

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

    +12

    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
    AttachmentService::MimeType AttachmentService::mimeTypeByCodeKey(const QString &codeKey) const
     {
         if(codeKey.toLower() == QString("MimeType_PDF").toLower())       return MimeType_PDF;
         if(codeKey.toLower() == QString("MimeType_JPEG").toLower())      return MimeType_JPEG;
         if(codeKey.toLower() == QString("MimeType_PNG").toLower())       return MimeType_PNG;
         if(codeKey.toLower() == QString("MimeType_HTML").toLower())      return MimeType_HTML;
         if(codeKey.toLower() == QString("MimeType_ZHTML").toLower())     return MimeType_ZHTML;
         if(codeKey.toLower() == QString("MimeType_TEXT").toLower())      return MimeType_TEXT;
         if(codeKey.toLower() == QString("MimeType_XLS").toLower())       return MimeType_XLS;
         if(codeKey.toLower() == QString("MimeType_DOC").toLower())       return MimeType_DOC;
         if(codeKey.toLower() == QString("MimeType_PPT").toLower())       return MimeType_PPT;
         if(codeKey.toLower() == QString("MimeType_GIF").toLower())       return MimeType_GIF;
         if(codeKey.toLower() == QString("MimeType_BMP").toLower())       return MimeType_BMP;
         if(codeKey.toLower() == QString("MimeType_MPEG").toLower())      return MimeType_MPEG;
         if(codeKey.toLower() == QString("MimeType_MP4").toLower())       return MimeType_MP4;
         if(codeKey.toLower() == QString("MimeType_MP3").toLower())       return MimeType_MP3;
         return MimeType_UNKNOWN;
    }

    Коллега откопал в моём коде, написанном под какими-то веществами по ходу.
    Изначально было сравнение строк как есть, без приведения в нижний регистр, а потом понадобилось подстраховаться от левого регистра символов.

    FlySnake, 09 Мая 2014

    Комментарии (24)
  10. Assembler / Говнокод #15892

    +146

    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
    .text:08104D0B                 mov     ebx, [ebp+arg_0]
    .text:08104D0E                 mov     ecx, [ebp+var_C]
    .text:08104D11                 mov     eax, 51EB851Fh
    .text:08104D16                 imul    ecx
    .text:08104D18                 sar     edx, 4
    .text:08104D1B                 mov     eax, ecx
    .text:08104D1D                 sar     eax, 1Fh
    .text:08104D20                 sub     edx, eax
    .text:08104D22                 mov     [ebp+var_C], edx
    .text:08104D25                 mov     ecx, [ebx+38h]
    .text:08104D28                 mov     eax, 51EB851Fh
    .text:08104D2D                 imul    ecx
    .text:08104D2F                 sar     edx, 4
    .text:08104D32                 mov     eax, ecx
    .text:08104D34                 sar     eax, 1Fh
    .text:08104D37                 sub     edx, eax
    .text:08104D39                 mov     [ebx+38h], edx
    .text:08104D3C                 cmp     [ebp+var_C], 0
    .text:08104D40                 jg      short loc_8104D55
    .text:08104D42                 mov     [ebp+var_C], 1
    .text:08104D49                 nop
    .text:08104D4A                 nop
    .text:08104D4B                 nop
    .text:08104D4C                 nop
    .text:08104D4D                 nop
    .text:08104D4E                 nop
    .text:08104D4F                 nop
    .text:08104D50                 nop
    .text:08104D51                 nop
    .text:08104D52                 nop
    .text:08104D53                 nop
    .text:08104D54                 nop
    .text:08104D55
    .text:08104D55 loc_8104D55:                            ; CODE XREF: session_skill::StartSession(bool)+222j
    .text:08104D55                 mov     eax, [ebp+arg_0]
    .text:08104D58                 cmp     byte ptr [eax+29h], 0
    .text:08104D5C                 jz      short loc_8104D74
    .text:08104D5E                 mov     ebx, [ebp+arg_0]
    .text:08104D61                 sub     esp, 0Ch
    .text:08104D64                 push    offset g_timer
    .text:08104D69                 call    _ZN5abase5timer8get_tickEv ; abase::timer::get_tick(void)
    .text:08104D6E                 add     esp, 10h
    .text:08104D71                 mov     [ebx+40h], eax
    .text:08104D74
    .text:08104D74 loc_8104D74:                            ; CODE XREF: session_skill::StartSession(bool)+23Ej
    .text:08104D74                 sub     esp, 0Ch
    .text:08104D77                 push    [ebp+var_C]
    .text:08104D7A                 push    0
    .text:08104D7C                 push    14h
    .text:08104D7E                 push    offset g_timer
    .text:08104D83                 mov     eax, [ebp+arg_0]
    .text:08104D86                 add     eax, 10h
    .text:08104D89                 push    eax
    .text:08104D8A                 call    _ZN5abase10timer_task8SetTimerERNS_5timerEiii ; abase::timer_task::SetTimer(abase::timer &,int,int,int)
    .text:08104D8F                 add     esp, 20h
    .text:08104D92                 sub     esp, 8
    .text:08104D95                 sub     esp, 4
    .text:08104D98                 push    18h             ; size
    .text:08104D9A                 call    _ZN5abase12ASmallObjectnwEj ; abase::ASmallObject::operator new(uint)
    .text:08104D9F                 add     esp, 8
    .text:08104DA2                 mov     [ebp+ptr], eax
    .text:08104DA5                 mov     [ebp+var_19], 1
    .text:08104DA9                 sub     esp, 8
    .text:08104DAC                 push    0Dh
    .text:08104DAE                 mov     eax, [ebp+arg_0]
    .text:08104DB1                 push    dword ptr [eax+8]
    .text:08104DB4                 mov     eax, [ebp+arg_0]
    .text:08104DB7                 push    dword ptr [eax+4]
    .text:08104DBA                 push    [ebp+ptr]
    .text:08104DBD                 call    _ZN22skill_interrupt_filterC1EP11gactive_impii ; skill_interrupt_filter::skill_interrupt_filter(gactive_imp *,int,int)
    .text:08104DC2                 add     esp, 18h
    .text:08104DC5                 mov     [ebp+var_19], 0
    .text:08104DC9                 mov     eax, [ebp+ptr]
    .text:08104DCC                 push    eax
    .text:08104DCD                 mov     eax, [ebp+arg_0]
    .text:08104DD0                 mov     eax, [eax+4]
    .text:08104DD3                 add     eax, 100h
    .text:08104DD8                 push    eax
    .text:08104DD9                 call    _ZN10filter_man9AddFilterEP6filter ; filter_man::AddFilter(filter *)
    .text:08104DDE                 add     esp, 10h
    .text:08104DE1                 jmp     short loc_8104E13

    вот собсно

    myWeb, 03 Мая 2014

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

    +153

    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
    if (!empty($_POST["favoriteColor"])) {
        switch($_POST["favoriteColor"]) {
            case "Lightred":
                $strBackgroundColor = "#FFDAB9";
                break;
            case "Lightgreen":
                $strBackgroundColor = "Lightgreen";
                break;
            case "Lightblue":
                $strBackgroundColor = "Lightblue";
                break;
            case "Lightgray":
                $strBackgroundColor = "Lightgray";
                break;
            default:
                $strBackgroundColor = "Gray";
                break;
        }
    } else {
        $strBackgroundColor = "Gray";
    }

    jkhne4pijgberg, 29 Апреля 2014

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