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

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

    +73.6

    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
    package psorter;
    
    import java.util.Vector;
    
    public class CArray extends Vector {
        String type="";
    
        /**
         * constructor of /array/
         * @param i set capacity increment
         */
        public CArray(int i) {
    	this.capacityIncrement=i;
        }
    
        /**
         * add object to end of vector with check of type
         * if type same as @ first added - add this object
         * safer than add
         * @param o object to add
         */
        public void append(Object o) {
    	if ( this.type.equals("") )
    	    this.type=o.getClass().toString();
    
    	if ( o.getClass().toString().equals(this.type) ){
    	    this.add(o);
    	} else {
    	    if ( this.type.contains("Float") && o.getClass().toString().contains("Integer") )
    		this.add( Float.valueOf(o.toString()) );
    
    	    if ( this.type.contains("Double") && o.getClass().toString().contains("Integer") )
    		this.add( Double.valueOf(o.toString()) );
    	    if ( this.type.contains("Double") && o.getClass().toString().contains("Float") )
    		this.add( Double.valueOf(o.toString()) );
    
    	    if ( this.type.contains("String") && o.getClass().toString().contains("Char") )
    		this.add( o.toString() );
    	}
        }
    
        public byte compare(int i, int j) throws Exception {
    	if (type.contains("Integer")) {
    	    if ((Integer) (this.get(i)) > (Integer) (this.get(j)))
    		return 1;
    	    if ((Integer) (this.get(i)) < (Integer) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("Float")) {
    	    if ((Float) (this.get(i)) > (Float) (this.get(j)))
    		return 1;
    	    if ((Float) (this.get(i)) < (Float) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("Double")) {
    	    if ((Double) (this.get(i)) > (Double) (this.get(j)))
    		return 1;
    	    if ((Double) (this.get(i)) < (Double) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("Char")) {
    	    if ((Character) (this.get(i)) > (Character) (this.get(j)))
    		return 1;
    	    if ((Character) (this.get(i)) < (Character) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("String")) {
    	    if ( this.get(i).toString().compareTo(this.get(j).toString())>0 )
    		return 1;
    	    if ( this.get(i).toString().compareTo(this.get(j).toString())<0 )
    		return -1;
    	    return 0;
    	}
    
    	return 0;
        }
    }

    сел писать 3 лабы естественно в последнюю ночь. начал в 11. эта была около 3х. самому потом стыдно было нести такое

    ilardm, 17 Апреля 2010

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

    +159.8

    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
    function AbstractControl_getProperty (propertyName) {
    	var targetElement = this.getTargetPath(propertyName);
    	var result = null;
    	
    	if (this.isTargetAttribute(propertyName)) {
    		eval("result = targetElement." + this.getAttributeName(propertyName));
    	} else {
    		var getter = this.getGetterName(propertyName);
    		var expression = "result = targetElement." + getter + "();";
    		eval(expression);
    	}
    	return result;
    }

    Вот так наши "суровые челябинские" программисты, не имеющие представления об интроспективности javascript-а, повсюду злоупотребляют eval-ом, усложняя отладку и понимание кода.
    По хорошему, вместо первого eval-а должно бы быть:
    result = targetElement[this.getAttributeName(propertyName)];
    а вместо второго:
    result = targetElement[this.getGetterName(propertyName)]();

    Andronix, 15 Апреля 2010

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

    +157.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function dayTimestamp($t=null) {
    	if (!$t) $t = time();
    	$t = explode('-',date('Y-m-d',$t));
    	$t = mktime(0,0,0,$t[1],$t[2],$t[0]);
    	return $t;
    }

    TWINc, 12 Апреля 2010

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

    +82.6

    1. 1
    if IntToStr(n) = '2' then

    чудо-программисты, еклмн

    timurrv, 07 Апреля 2010

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

    +77.6

    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
    public void run()
        {
            try
            {            
                startExport();
            }
            catch (Throwable _t)
            {
                sendEvent(""+_t.getMessage(), true);
                logger.log(Level.SEVERE, charset, _t);
            }
            finally
            {
                System.gc();
            }
        }

    А ещё этот человек дёргает в одном сервисе gc каждые 4 секунды. Любые попытки ударить по рукам нарываются на отлуп: "так работает же!". Это не студент! Это реальный production код!

    konsoletyper, 06 Апреля 2010

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

    +149.2

    1. 1
    $is_use_newstyle = ($newstyle == 1) ? 1 : 0;

    shureg, 24 Марта 2010

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

    +170.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
    <?php
     $mounths["January"]="01";
     $mounths["February"]="02";
     $mounths["March"]="03";
     $mounths["April"]="04";
     $mounths["May"]="05";
     $mounths["June"]="06";
     $mounths["July"]="07";
     $mounths["August"]="08";
     $mounths["September"]="09";
     $mounths["October"]=10;
     $mounths["November"]=11;
     $mounths["December"]=12;
    
     $m=date("F");
     $d=date("d");
     $Y=date("Y");
     $datetime=date("Y")."-".$mounths[$m]."-".date("d")." ".date("H").":".date("i").":".date("s");
     $date=date("Y")."-".$mounths[$m]."-".date("d");
    ?>

    Ээээ, чо? Нарыл в проекте. Отпаиваюсь чаем.

    azzz, 11 Марта 2010

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

    +170.2

    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
    function is_ie8(){
    var ua = navigator.userAgent.toLowerCase();
    var is_opera = ua.indexOf("opera") != -1;
    var is_opera5 = ua.indexOf("opera/5") != -1 || ua.indexOf("opera 5") != -1;
    var is_opera6 = ua.indexOf("opera/6") != -1 || ua.indexOf("opera 6") != -1;
    var is_opera7 = ua.indexOf("opera/7") != -1 || ua.indexOf("opera 7") != -1;
    var is_opera8 = ua.indexOf("opera/8") != -1 || ua.indexOf("opera 8") != -1;
    var is_opera9 = ua.indexOf("opera/9") != -1 || ua.indexOf("opera 9") != -1;
    var is_opera95 = ua.indexOf("opera/9.5") != -1 || ua.indexOf("opera 9.5") != -1;
    var is_opera96 = ua.indexOf("opera/9.6") != -1 || ua.indexOf("opera 9.6") != -1;
    var is_opera95up = is_opera95 || is_opera96;
    
    var is_ff = ua.indexOf("firefox") != -1 && !is_opera;
    var is_gecko = ua.indexOf('gecko') != -1 && !is_opera;
    
    var is_chrome = ua.indexOf('chrome') != -1;
    var is_safari = ua.indexOf('applewebkit') != -1 && !is_chrome;
    
        var is_ie = ua.indexOf("msie") != -1  && !is_opera;
        var is_ie4 = is_ie && ua.indexOf("msie 4") != -1;
        var is_ie5 = is_ie && ua.indexOf("msie 5") != -1;
        var is_ie50 = is_ie && ua.indexOf("msie 5.0") != -1;
        var is_ie55 = is_ie && ua.indexOf("msie 5.5") != -1;
        var is_ie5up = is_ie && !is_ie4;
        var is_ie6 = is_ie && ua.indexOf("msie 6") != -1;
        var is_ie6up = is_ie5up && !is_ie55 && !is_ie5;
        var is_ie7 = is_ie && ua.indexOf("msie 7") != -1;
        var is_ie7up = is_ie6up && !is_ie6;
        var is_ie7down = is_ie7 || is_ie6 || is_ie5 || is_ie4;
    
        var is_ie8 = is_ie && ua.indexOf("msie 8") != -1;
        var is_ie8up = is_ie8 && !is_ie7down;
        if (is_ie && !is_ie8up && !is_ie8) {
            return true;
        }else return false;
    }

    Детектим IE8

    deraider, 06 Марта 2010

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

    +45.6

    1. 1
    return (hWnd) ? (bool)ShowWindow(hWnd, (state) ? SW_NORMAL : SW_HIDE) : false;

    Я долго пытался понять, что я имел ввиду.

    Altravert, 24 Февраля 2010

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

    +167.4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (isset($_POST["yes"]))
        {
    	 $query="DELETE FROM zakaz WHERE (id_tovar='$id' and id_users='$id_u)";
    	 add($query);
    	 commit();
             Echo "<b> Заказ утвержден";
       }

    Знакомая писала курсач по СУБД + PHP, мало что понимала в том что пишет) увидел в одном из фалов)

    1_and_0, 26 Января 2010

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