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

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

    +52

    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
    header( 'Content-Type: text/html; charset=utf-8' );
    
    $year  = date( 'Y' );
    
    $months = array( 1 => 'Январь', 'Фервраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь' );
    
    $infoYear = getdate( mktime( 0, 0, 0, 1, 1, $year, 0 ) );
    
    $weekDay = $infoYear['wday'] == 0 ? 7 : $infoYear['wday']; // wday - номер дня недели. 0 - Воскресение. Делаем воскресение седьмым днем.
    
    echo "<h2>$year</h2>";
    
    for ( $month = 1; $month <= 12; $month++ ) {
    	echo '<div style="float: left; padding: 2px;"><b>' . $months[$month] . '</b>';
    	echo '<table border="1">';
    	echo '<th>Пн</th><th>Вт</th><th>Ср</th><th>Чт</th><th>Пт</th><th>Сб</th><th>Вс</th>';
    	echo '<tr>';
    	
    	for ( $day = 1; $day < 31; $day++ ) {
    		
    		if ( checkdate($month, $day, $year) ) {
    			
    			if ( $day == 1 )
    				for ( $i = 1; $i < $weekDay; $i++ )
    					echo '<td> </td>';
    			
    			printf( '<td>%02d</td>', $day );
    			
    			$weekDay++;
    			if ( $weekDay > 7 ) {
    				$weekDay = 1;
    				echo '</tr><tr>';
    			}
    		}
    	}
    	
    	echo '</tr></table></div>';
    }

    Задача: Вывести календарь, для установки нужных дат админом и сохранить их в БД.
    Остается отрефракторить и добавить checkbox'ы.

    psycho-coder, 09 Июня 2012

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

    +112

    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
    switch (SelectedCategory)
                {
                    case "Landscapers":
                        inputSearch.Value = "Landscapers";
                        break;
    
                    case "Baby sitters":
                        inputSearch.Value = "Baby sitters";
                        break;
    
                    case "Doctor":
                        inputSearch.Value = "Doctor";
                        break;
    
                    case "Cleaning services":
                        inputSearch.Value = "Cleaning services";
                        break;
    
                    case "Pet sitters":
                        inputSearch.Value = "Pet sitters";
                        break;
    
                    case "Handyman":
                        inputSearch.Value = "Handyman";
                        break;
    
                    case "Electrical services":
                        inputSearch.Value = "Electrical services";
                        break;
    
                    case "Tutor":
                        inputSearch.Value = "Tutor";
                        break;
    
                    case "Dog walker":
                        inputSearch.Value = "Dog walker";
                        break;
    
                    case "Plumbing":
                        inputSearch.Value = "Plumbing";
                        break;
    
                    case "Caterers":
                        inputSearch.Value = "Caterers";
                        break;
    
                    case "Misc":
                        inputSearch.Value = "Misc";
                        break;
                }

    обычный switch

    mangyst, 30 Мая 2012

    Комментарии (27)
  4. VisualBasic / Говнокод #10337

    −117

    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
    For t = 3 To u
     If Cells(t, 204).Text = " " Or Cells(t, 204).Text = "" Then
       If Cells(t + 1, 204).Text = " " Or Cells(t + 1, 204).Text = "" Then
        If Cells(t + 2, 204).Text = " " Or Cells(t + 2, 204).Text = "" Then
         If Cells(t + 3, 204).Text = " " Or Cells(t + 3, 204).Text = "" Then
         If Cells(t + 4, 204).Text = " " Or Cells(t + 4, 204).Text = "" Then
         If Cells(t + 5, 204).Text = " " Or Cells(t + 5, 204).Text = "" Then
         If Cells(t + 6, 204).Text = " " Or Cells(t + 6, 204).Text = "" Then
         If Cells(t + 7, 204).Text = " " Or Cells(t + 7, 204).Text = "" Then
         If Cells(t + 8, 204).Text = " " Or Cells(t + 8, 204).Text = "" Then
         If Cells(t + 9, 204).Text = " " Or Cells(t + 9, 204).Text = "" Then
         If Cells(t + 10, 204).Text = " " Or Cells(t + 10, 204).Text = "" Then
         If Cells(t + 11, 204).Text = " " Or Cells(t + 11, 204).Text = "" Then
         If Cells(t + 12, 204).Text = " " Or Cells(t + 12, 204).Text = "" Then
         If Cells(t + 13, 204).Text = " " Or Cells(t + 13, 204).Text = "" Then
         If Cells(t + 14, 204).Text = " " Or Cells(t + 14, 204).Text = "" Then
         If Cells(t + 15, 204).Text = " " Or Cells(t + 15, 204).Text = "" Then
         If Cells(t + 16, 204).Text = " " Or Cells(t + 16, 204).Text = "" Then
         If Cells(t + 17, 204).Text = " " Or Cells(t + 17, 204).Text = "" Then
         If Cells(t + 18, 204).Text = " " Or Cells(t + 18, 204).Text = "" Then
         If Cells(t + 19, 204).Text = " " Or Cells(t + 19, 204).Text = "" Then
         If Cells(t + 20, 204).Text = " " Or Cells(t + 20, 204).Text = "" Then
         If Cells(t + 21, 204).Text = " " Or Cells(t + 21, 204).Text = "" Then
         If Cells(t + 22, 204).Text = " " Or Cells(t + 22, 204).Text = "" Then
         If Cells(t + 23, 204).Text = " " Or Cells(t + 23, 204).Text = "" Then
         If Cells(t + 24, 204).Text = " " Or Cells(t + 24, 204).Text = "" Then
         If Cells(t + 25, 204).Text = " " Or Cells(t + 25, 204).Text = "" Then
         If Cells(t + 26, 204).Text = " " Or Cells(t + 26, 204).Text = "" Then
         If Cells(t + 27, 204).Text = " " Or Cells(t + 27, 204).Text = "" Then
         If Cells(t + 28, 204).Text = " " Or Cells(t + 28, 204).Text = "" Then
         If Cells(t + 29, 204).Text = " " Or Cells(t + 29, 204).Text = "" Then
         If Cells(t + 30, 204).Text = " " Or Cells(t + 30, 204).Text = "" Then
         If Cells(t + 31, 204).Text = " " Or Cells(t + 31, 204).Text = "" Then
         If Cells(t + 32, 204).Text = " " Or Cells(t + 32, 204).Text = "" Then
         If Cells(t + 33, 204).Text = " " Or Cells(t + 33, 204).Text = "" Then
         If Cells(t + 34, 204).Text = " " Or Cells(t + 34, 204).Text = "" Then
                  GoTo zan4:
              End If
            End If
          End If
        End If
         End If
         End If
            End If
          End If
        End If
         End If
         End If
            End If
          End If
        End If
         End If
         End If
            End If
          End If
        End If
         End If
         End If
            End If
          End If
        End If
         End If
         End If
            End If
          End If
        End If
         End If
         End If
            End If
          End If
        End If
         End If
    Next t
    zan4:

    Кусок реально используемого "проэкта", используется у нас на призводстве.
    И вот-такого штук 10 в коде.

    ноу коментс.

    adli__82, 21 Мая 2012

    Комментарии (27)
  5. C++ / Говнокод #9686

    +999

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    assert(t1.tm_sec == t2.tm_sec);
            assert(t1.tm_min == t2.tm_min);
            assert(t1.tm_hour == t2.tm_hour);
            assert(t1.tm_mday == t2.tm_mday);
            assert(t1.tm_mon == t2.tm_mon);
            assert(t1.tm_year == t2.tm_year);
            assert(t1.tm_wday == t2.tm_wday);
            assert(t1.tm_yday == t2.tm_yday);
            assert(t1.tm_isdst == t2.tm_isdst);

    фрагмент из кода библиотеки SOCI: http://soci.sourceforge.net/

    наконец-то исправили на: assert(memcmp(&t1, &t2, sizeof(std::tm)) == 0);

    niXman, 15 Марта 2012

    Комментарии (27)
  6. Java / Говнокод #9530

    +82

    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
    private static final String QUERY = 
            new StringBuffer("SELECT p.id FROM policysummary p ") 
                .append(" WHERE p.currentRevisionInd     = 1 ") 
                .append("AND p.policyStatusCd          IN ('issued') ") 
                .append("AND p.timedPolicyStatusCd     IN ('inForce') ") 
                .append("AND p.txType                  IN ('policy','renewal','endorsement','reinstatement') ") 
                .append("AND p.expiration <= :requestDate ") 
                .append("AND :requestDate <= (p.expiration + :requestTo) ") 
                .append("AND NOT EXISTS ") 
                .append("  (SELECT prs.id ") 
                .append("  FROM PolicyReportStatus prs ") 
                .append("  WHERE prs.policyId  = p.id ") 
                .append("  AND prs.mvrOrderDt IS NOT NULL ") 
                .append("  )") 
                .toString();

    Недавно выдавили заграничные коллеги

    roman-kashitsyn, 24 Февраля 2012

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

    +953

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    void Update()
    {
    	float anime = (animation.wrapMode = WrapMode.Loop);
    	anime = false;
    }

    Хентай повышенной концентрации.

    alexz, 19 Января 2012

    Комментарии (27)
  8. C++ / Говнокод #9053

    +1000

    1. 1
    const double pi = acos(-1.0);

    В каждой посылке codeforces - участника shentianxiao.

    P.S. Он - китаец

    VisualPaul, 08 Января 2012

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

    +1006

    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
    99. 99
    const unsigned BAD_VALUE = (unsigned) -1;
    typedef pair<string, unsigned> RomeDecPair;
    typedef map<string, unsigned> Table;
    Table g_table;
     
    void InitTables()
    {
      g_table["I"] = 1;
      g_table["II"] = 2;
      g_table["III"] = 3;
      g_table["IV"] = 4;
      g_table["V"] = 5;
      g_table["VI"] = 6;
      g_table["VII"] = 7;
      g_table["VIII"] = 8;
      g_table["IX"] = 9;
      g_table["X"] = 10;
      g_table["XX"] = 20;
      g_table["XXX"] = 30;
      g_table["XL"] = 40;
      g_table["L"] = 50;
      g_table["XC"] = 90;
      g_table["C"] = 100;
      g_table["CC"] = 200;
      g_table["CCC"] = 300;
      g_table["CD"] = 400;
      g_table["D"] = 500;
      g_table["CM"] = 900;
      g_table["M"] = 1000;
      g_table["MM"] = 2000;
      g_table["MMM"] = 3000;
    }
    .....
    int main()
    {
      InitTables();
     
      vector<RomeDecPair> tests;
     
      tests.push_back(make_pair("I", 1));
      tests.push_back(make_pair("II", 2));
      tests.push_back(make_pair("III", 3));
      tests.push_back(make_pair("IV", 4));
      tests.push_back(make_pair("V", 5));
      tests.push_back(make_pair("VI", 6));
      tests.push_back(make_pair("VII", 7));
      tests.push_back(make_pair("VIII", 8));
      tests.push_back(make_pair("IX", 9));
      tests.push_back(make_pair("X", 10));
      tests.push_back(make_pair("XI", 11));
      tests.push_back(make_pair("XII", 12));
      tests.push_back(make_pair("XIII", 13));
      tests.push_back(make_pair("XIV", 14));
      tests.push_back(make_pair("XV", 15));
      tests.push_back(make_pair("XVI", 16));
      tests.push_back(make_pair("XVII", 17));
      tests.push_back(make_pair("XVIII", 18));
      tests.push_back(make_pair("XIX", 19));
      tests.push_back(make_pair("XX", 20));
      tests.push_back(make_pair("XXI", 21));
      tests.push_back(make_pair("XL", 40));
      tests.push_back(make_pair("XLII", 42));
      tests.push_back(make_pair("LIX", 59));
      tests.push_back(make_pair("LXXVII", 77));
      tests.push_back(make_pair("XC", 90));
      tests.push_back(make_pair("CX", 110));
      tests.push_back(make_pair("CDXCIX", 499));
      tests.push_back(make_pair("DLXXXIII", 583));
      tests.push_back(make_pair("DCCCLXXXVIII", 888));
      tests.push_back(make_pair("MDCLXVIII", 1668));
      tests.push_back(make_pair("MCMLXXXIX", 1989));
      tests.push_back(make_pair("MMMCMXCIX", 3999));
     
      tests.push_back(make_pair("", BAD_VALUE));
      tests.push_back(make_pair("IIIV", BAD_VALUE));
      tests.push_back(make_pair("IIV", BAD_VALUE));
      tests.push_back(make_pair("IIII", BAD_VALUE));
      tests.push_back(make_pair("IIX", BAD_VALUE));
      tests.push_back(make_pair("XIIII", BAD_VALUE));
      tests.push_back(make_pair("XIIIIX", BAD_VALUE));
      tests.push_back(make_pair("XIIIIX", BAD_VALUE));
      tests.push_back(make_pair("XXXX", BAD_VALUE));
      tests.push_back(make_pair("LL", BAD_VALUE));
      tests.push_back(make_pair("CLC", BAD_VALUE));
      tests.push_back(make_pair("CLL", BAD_VALUE));
      tests.push_back(make_pair("DLD", BAD_VALUE));
      tests.push_back(make_pair("LDD", BAD_VALUE));
      tests.push_back(make_pair("LLI", BAD_VALUE));
      tests.push_back(make_pair("MMMCMXCX", BAD_VALUE));
      tests.push_back(make_pair("AXX", BAD_VALUE));
      tests.push_back(make_pair("LXA", BAD_VALUE));
     
      for (vector<RomeDecPair>::const_iterator it = tests.begin(), end = tests.end(); it != end; ++it)
      {
        CheckConversion(*it);
      }
     
      return 0;
    }

    bugaga, 10 Декабря 2011

    Комментарии (27)
  10. Java / Говнокод #8593

    +80

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Calendar startCal = Calendar.getInstance();
    startCal.setTime(DateUtils.truncateDateAndTimeToDateOnly(startDate));
    Date strtDt = startCal.getTime();
    
    Calendar endCal = Calendar.getInstance();
    endCal.setTime(DateUtils.truncateDateAndTimeToDateOnly(endDate));
    Date endDt = endCal.getTime();

    Далее по тексту strtDt и endDt используются ровно один раз, startCal и endCal не используются больше вообще. Утилитный метод возвращает требуемый экземпляр класса Date.

    roman-kashitsyn, 21 Ноября 2011

    Комментарии (27)
  11. JavaScript / Говнокод #8589

    +181

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if ( FILM_COMEDIA ) {TEXT = "комедия"}
    if ( FILM_UJASTIC ) {TEXT = "ужастик"}
    if ( FILM_DRAMA ) {TEXT = "драма"}
    ....
    if ( FILM_COMEDIA ) {if ( FILM_DRAMA ) {TEXT = "комедия, драма"} }
    .....
    if ( FILM_MUSIC ) { if ( FILM_SEMEYNIY ) { if ( FILM_PORNO ) { TEXT = "музыкальный, семейный, эротика" } } }
    ...

    Проверка жанров фильма.

    noccc, 20 Ноября 2011

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