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

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

    +65.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    //какой-то .h-файл
    namespace Error {
    	struct Put_error{
    		const char * Message;
    		Put_error(const char * e) { Message = e; }
    	};
    ...
    
    //в каком-то методе в другом файле
    	  string msg = "Error: cannot open input file " + string(fileInputName) + "\n";
    	  throw Error::Put_error(msg.c_str());

    Lexey, 03 Ноября 2009

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

    +75.3

    1. 1
    2. 2
    3. 3
    <meta http-equiv="Тип-содержимое" content="text/html; charset=windows-1251"><meta http-equiv="Тип-содержимое" content="text/html; charset=windows-1251">
    <meta http-equiv="Тип-содержимое" content="text/html; charset=windows-1251"><meta http-equiv="Тип-содержимое" content="text/html; charset=windows-1251">
    <meta http-equiv="Тип-содержимое" content="text/html; charset=windows-1251"><meta http-equiv="Тип-содержимое" content="text/html; charset=windows-1251"><meta http-equiv="Тип-содержимое" content="text/html; charset=windows-1251">

    Случайно открыл исходный код заглавной страницы сайта utel.tv, а там вот так указывают Content-Type, видимо чтобы непонятливые браузеры поняли хотя-бы с седьмого раза. Может объяснить им, что тип контента это конечно оно, но не туда? :)

    eveel, 20 Октября 2009

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

    +130.5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    try
    {
    	// some logic
    }
    catch(Exception ex)
    {
    	throw;
    }

    Error handling :)

    bugotrep, 16 Октября 2009

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

    +159.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
    // Create new script element and start loading.
    _obtainScript: function(id, href) { with (document) {
        var span = null;
        // Oh shit! Damned stupid fucked Opera 7.23 does not allow to create SCRIPT 
        // element over createElement (in HEAD or BODY section or in nested SPAN - 
        // no matter): it is created deadly, and does not respons on href assignment.
        // So - always create SPAN.
        var span = createElement("SPAN");
        span.style.display = 'none';
        body.appendChild(span);
        span.innerHTML = 'Text for stupid IE.<s'+'cript></' + 'script>';
        setTimeout(function() {
            var s = span.getElementsByTagName("script")[0];
            s.language = "JavaScript";
            if (s.setAttribute) s.setAttribute('src', href); else s.src = href;
        }, 10);
        this._id = id;
        this._span = span;
    }},

    коммент жжот, грубо, но справедливо

    via xeonix

    striker, 12 Октября 2009

    Комментарии (15)
  6. C# / Говнокод #1957

    +105.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
    //одногрупнику надо было проверить, является ли "obj" - "А"
    //наблюдал за процессом, и плакал
    //----------------------------------------------------------------------------------
    //1 версия
    static bool IsA(object obj) {
    if (obj.GetType().Name.Equals("A", StringComparison.InvariantCultureIgnoreCase))
        return true;
        else return false;
    }
    //----------------------------------------------------------------------------------
    //2 версия
    static bool IsA(object obj) {
        A a = new A();
        if (obj.GetType().Equals(a.GetType()))
            return true;
        else return false;
    }
    //----------------------------------------------------------------------------------
    //3 версия
    static bool IsA(object obj) {
        if (obj.GetType().Equals(typeof(A)))
            return true;
        else return false;
    }
    //----------------------------------------------------------------------------------
    //потом он вспомнил, что от "A" могут наследоваться другие классы
    static bool IsA(object obj) {
        Type typeObj = obj.GetType();
        do {
            if (typeObj.Equals(typeof(object)))
                return false;
            else if (typeObj.Equals(typeof(A)))
                return true;
            else typeObj = typeObj.BaseType;
        } while (true);
    }
    
    //плачу, смеюсь и плачу, а с виду одногрупник вроде не Индус...
    //...и весь этот говнокод был написан, вместо простого:
    static bool IsA(object obj) { return obj is A; }

    via xeonix

    striker, 12 Октября 2009

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

    +139.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    var complete = new ManualResetEvent(false);
    
    ThreadPool.QueueUserWorkItem(
    	delegate
    		{
    			service.StartDownloadUpdatesProcess(complete);
    		});
    
    complete.WaitOne();

    Запустим поток, а потом подождем пока он закончиться.

    Mike Chaliy, 04 Октября 2009

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

    +170.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
    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
    98. 98
    <?php
    $mm=strlen( $titLE);
    $tit='';   
    for ($i=0;$i<=$mm;$i++)
    {
    $ss= $titLE[$i];
    switch ($ss) 
    {
    case "щ": $tit= $tit."sch";  break;
    case "ч": $tit= $tit."ch";  break;
    case "ш": $tit= $tit."sh";  break; 
    case "я": $tit= $tit."ja";  break;
    case "ю": $tit= $tit."ju";  break;
    case "ё": $tit= $tit."jo";  break;
    case "ж": $tit= $tit."zh";  break;
    case "э": $tit= $tit."e";  break;
    case "Щ": $tit= $tit."Sch";  break; 
     case "Ч": $tit= $tit."Ch";  break;
     case "Ш": $tit= $tit."Sh";  break;
     case "Я": $tit= $tit."Ja";  break;
    case "Ю": $tit= $tit."Ju";  break;
    case "Ё": $tit= $tit."Jo";  break; 
    case "Ж": $tit= $tit."Zh";  break;
    case "Э": $tit= $tit."E";  break;
    case "ь": $tit= $tit."";  break; 
    case "ъ": $tit= $tit."'";  break; 
    case "а": $tit= $tit."a";  break;
     case "б": $tit= $tit."b";  break;
    case "ц": $tit= $tit."c";  break;
    case "д": $tit= $tit."d";  break;
    case "е": $tit= $tit."e";  break; 
    case "ф": $tit= $tit."f";  break; 
    case "г": $tit= $tit."g";  break;
    case "х": $tit= $tit."h";  break; 
    case "и": $tit= $tit."i";  break; 
    case "й": $tit= $tit."j";  break;
    case "к":
         {
    
            if ($str[$i+1]=="с" ) {
            $tit= $tit."x";  
           $i=$i+1; break;}
             $tit= $tit."k";  break;
           }
    case "л": $tit= $tit."l";  break;
    case "м": $tit= $tit."m";  break;
    case "н": $tit= $tit."n";  break;
    case "о": $tit= $tit."o";  break;
    case "п": $tit= $tit."p";  break; 
    case "р": $tit= $tit."r";  break; 
    case "с": $tit= $tit."s";  break;
    case "т": $tit= $tit."t";  break;
    case "у": $tit= $tit."u";  break;
    case "в": $tit= $tit."v";  break;
    case "ы": $tit= $tit."y";  break;
    case "з": $tit= $tit."z";  break; 
    case "Ь": $tit= $tit."'";  break;
    case "Ъ": $tit= $tit."'";  break;
    case "А": $tit= $tit."A";  break;
    case "Б": $tit= $tit."B";  break; 
    case "Ц": $tit= $tit."C";  break;
    case "Д": $tit= $tit."D";  break;
     case "Е": $tit= $tit."E";  break;
    case "Ф": $tit= $tit."F";  break;
    case "Г": $tit= $tit."G";  break;
    case "Х": $tit= $tit."H";  break;
    case "И": $tit= $tit."I";  break;
    case "Й": $tit= $tit."J";  break;
    case "К":    
         {
          if ($str[$i+1]=="С" ) {
            $tit= $tit."X";  
           $i=$i+1; break;}
    
          if ($str[$i+1]=="с" ) {
            $tit= $tit."X";  
           $i=$i+1; break;}
    
           $tit= $tit."K"; break;
           }
    case "Л": $tit= $tit."L";  break;
     case "М": $tit= $tit."M";  break;
    case "Н": $tit= $tit."N";  break;
    case "О": $tit= $tit."O";  break;
    case "П": $tit= $tit."P";  break;  
    case "Р": $tit= $tit."R";  break;
    case "С": $tit= $tit."S";  break;
    case "Т": $tit= $tit."T";  break; 
     case "У": $tit= $tit."U";  break; 
     case "В": $tit= $tit."V";  break;
    case "Ы": $tit= $tit."Y";  break;
    case "З": $tit= $tit."Z";  break;
    case " ": $tit= $tit." ";  break;
    default:
            $end1= $tit;
      }
    }
    ?>

    транслитизатор!!!!!!!

    yamaha252, 29 Сентября 2009

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

    +129.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
    // IPrincipal Implementation
    public bool IsInRole(string role)
    {
      return Array.BinarySearch( _roles, role ) >=0 ? true : false;
    }
    public IIdentity Identity
    {
      get
      {
        return _identity;
      }
    }

    Взято из Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication (http://msdn.microsoft.com/en-us/library/aa302401.aspx)

    Step 4. Create a Class that Implements and Extends IPrincipal
    6. Implement the IsInRole method and Identity property defined by the IPrincipal interface as shown below.

    mikle.smirnov, 16 Сентября 2009

    Комментарии (15)
  10. C++ / Говнокод #1769

    +49.9

    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
    bool __fastcall TForm1::ImportFile(AnsiString FName, int Direction)
    {
    bool StatusUpload;
    StatusUpload = true;
    
    TStringList *Inside;
    Inside = new TStringList;
    Inside->LoadFromFile(FName);
    if (Direction == 1)
    {
      // ...
      date_made = StrToSqlDate(Inside->Strings[1]);
      ops = Inside->Strings[0];
    
      Inside->Delete(0);
      Inside->Delete(0);
      Inside->Delete(0);
    
      int Iterations = (Inside->Count/5);
      for (int i=0; i<Iterations; i++)
      {
        AnsiString A, B, C, D, E;
        A = Inside->Strings[0].Trim();
        B = Inside->Strings[1].Trim();
        C = Inside->Strings[2].Trim();
        D = Inside->Strings[3].Trim();
        E = Inside->Strings[4].Trim();
        for (int j=0; j<5;j++)
           Inside->Delete(0);
    
        if (A == "1.1.2")
          E='1';
    
        if (A == "4.13" || A == "4.13" || A == "4.13")
    	  E='20';
        C = RemoveZPT(C);
    	ADOQuery1->SQL->Text = "INSERT INTO dnevnik_inside (row_id, ops, date_made, code, sign, val, val_init, direction, type) VALUES ("
          + row_id + ", '" + ops + "', '" + date_made + "', '" + A + "', '"
          + B + "', " + C + ", " + C + ", '" + D +"', '"+E+"')";
        ADOQuery1->ExecSQL();
      }
      Trans->CommitRetaining();
    }

    Собсно, название функции говорит само за себя :)
    П.С. Коллега, не обижайся!

    labutinpa, 05 Сентября 2009

    Комментарии (15)
  11. C++ / Говнокод #1766

    +63.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if
    (
    IsFiltred
    //проверка на фильтрованность массива
    ==
    true
    )
    {

    Нет слов.

    Говногость, 04 Сентября 2009

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