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

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

    +47

    1. 1
    mysql_query ("INSERT INTO mr_costadvtxt VALUES ('LAST_INSERT_ID(id+1)','$itemid','$kindofstr','$size', '$size_count','$pricered','$fordisc','$disc','$scheme_name','$pnum')") or die(mysql_error());

    psycho-coder, 24 Июля 2012

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

    +81

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    int i=0;
            for (;i<5;
                 printf("%d",i);
                 i++;
                 );

    ZevsVU, 17 Июля 2012

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

    +139

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public static IEnumerable<T> QuickSort<T>(
    	this IEnumerable<T> source) where T : IComparable<T>
    	{
    		if (!source.Any()) return source;
    		var first = source.First();
    		return source
    			.AsParallel()
    			.GroupBy(i => i.CompareTo(first))
    			.OrderBy(g => g.Key)
    			.SelectMany(g => g.Key == 0 ? g : QuickSort(g));
    	}

    HaskellGovno, 16 Июня 2012

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

    −27

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    class Screen
    {
    private:
            unsigned char *data; // do not move
            size_t size; // do not move

    USB, 09 Июня 2012

    Комментарии (27)
  6. 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)
  7. 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)
  8. 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)
  9. 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)
  10. 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)
  11. 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)