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

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

    +160

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    var a = [1,2,3,4,5,6,7,8,9];
    document.write('1' + '!='+ a[0] + '<br>');
    document.write('2' +'!=' + a[0] * a[1] + '<br>');
    document.write('3' +'!=' + a[0] * a[1] * a[2] + '<br>');
    document.write('4' +'!=' + a[0] * a[1] * a[2] * a[3] + '<br>');
    document.write('5' +'!=' + a[0] * a[1] * a[2] * a[3] * a[4] + '<br>');
    document.write('6' +'!=' + a[0] * a[1] * a[2] * a[3] * a[4] * a[5] + '<br>');
    document.write('7' +'!=' + a[0] * a[1] * a[2] * a[3] * a[4] * a[5] * a[6] + '<br>');
    document.write('8' +'!=' + a[0] * a[1] * a[2] * a[3] * a[4] * a[5] * a[6] * a[7] + '<br>');
    document.write('9' +'!=' + a[0] * a[1] * a[2] * a[3] * a[4] * a[5] * a[6] * a[7] * a[8] + '<br>');

    Таблица факториалов до 9

    spellproff, 09 Апреля 2014

    Комментарии (17)
  3. ActionScript / Говнокод #15695

    −136

    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
    /**
     *  @private
     *  Calculates the height needed for heightInLines lines using the default
     *  font.
     */
    private function calculateHeightInLines():Number
    {
        var height:Number = getStyle("paddingTop") + getStyle("paddingBottom");
        
        if (_heightInLines == 0)
            return height;
        
        var effectiveHeightInLines:int;
        
        // If both height and width are NaN use 10 lines.  Otherwise if 
        // only height is NaN, use 1.
        if (isNaN(_heightInLines))
            effectiveHeightInLines = isNaN(_widthInChars) ? 10 : 1;   
        else
            effectiveHeightInLines = _heightInLines;
        
        // Position of the baseline of first line in the container.
        value = getStyle("firstBaselineOffset");
        if (value == lineHeight)
            height += lineHeight;
        else if (value is Number)
            height += Number(value);
        else
            height += ascent;
        
        // Distance from baseline to baseline.  Can be +/- number or 
        // or +/- percent (in form "120%") or "undefined".  
        if (effectiveHeightInLines > 1)
        {
            var value:Object = getStyle("lineHeight");     
            var lineHeight:Number =
                RichEditableText.getNumberOrPercentOf(value, getStyle("fontSize"));
            
            // Default is 120%
            if (isNaN(lineHeight))
                lineHeight = getStyle("fontSize") * 1.2;
            
            height += (effectiveHeightInLines - 1) * lineHeight;
        }            
        
        // Add in descent of last line.
        height += descent;              
        
        return height;
    }

    Внимательно следим за жизненным циклом переменной lineHeight.

    wvxvw, 07 Апреля 2014

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

    +128

    1. 1
    2. 2
    3. 3
    if (f > 1) { }
    else
    chart5.Series[1].Points.AddXY(i, f);

    Было замечено за коллегой

    goaquit, 05 Апреля 2014

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

    +81

    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
    // -1 esli NotFound, snachala massiv potom element
    	static int najtiElementVMassive(Object massiv,Object element){
    		if(massiv instanceof int[]) {
    			for(int i=0; i<((int[])massiv).length; ++i)
    				if(((int[])massiv)[i]==(int)element)
    					return i;
    		} else if(massiv instanceof byte[]) {
    			for(int i=0; i<((byte[])massiv).length; ++i)
    				if(((byte[])massiv)[i]==(byte)element)
    					return i;
    		} else if(massiv instanceof boolean[]) {
    			for(int i=0; i<((boolean[])massiv).length; ++i)
    				if(((boolean[])massiv)[i]==(boolean)element)
    					return i;
    		} else if(massiv instanceof char[]) {
    			for(int i=0; i<((char[])massiv).length; ++i)
    				if(((char[])massiv)[i]==(char)element)
    					return i;
    		} else if(massiv instanceof float[]) {
    			for(int i=0; i<((float[])massiv).length; ++i)
    				if(((float[])massiv)[i]==(float)element)
    					return i;
    		} else if(massiv instanceof double[]) {
    			for(int i=0; i<((double[])massiv).length; ++i)
    				if(((double[])massiv)[i]==(double)element)
    					return i;
    		} else if(massiv instanceof short[]) {
    			for(int i=0; i<((short[])massiv).length; ++i)
    				if(((short[])massiv)[i]==(short)element)
    					return i;
    		} else if(massiv instanceof long[]) {
    			for(int i=0; i<((long[])massiv).length; ++i)
    				if(((long[])massiv)[i]==(long)element)
    					return i;
    		} else {
    			try {
    				for(int i=0; i<((Object[])massiv).length; ++i)
    					if(sravnitMassivi(((Object[])massiv)[i],element))
    						return i;
    			} catch (Exception e) {
    				for(int i=0; i<((Object[])massiv).length; ++i)
    					if((((Object[])massiv)[i]).equals(element))
    						return i;
    			}
    		}
    		
    		return -1;
    	}
    	
    	
    	static boolean sravnitMassivi(Object massiv1,Object massiv2) {
    		try {
    			if((((Object[])massiv1)).length!=(((Object[])massiv2)).length) return false;
    			boolean ravni=true;
    			for(int i=0; i<(((Object[])massiv1)).length; ++i) 
    				ravni=ravni&&sravnitMassivi((((Object[])massiv1))[i],(((Object[])massiv2))[i]);
    			return ravni;
    		} catch (Exception e) {
    			if(massiv1 instanceof int[]) {
    				return Arrays.equals((int[])massiv1,(int[])massiv2);
    			} else if(massiv1 instanceof byte[]) {
    				return Arrays.equals((byte[])massiv1,(byte[])massiv2);
    			} else if(massiv1 instanceof boolean[]) {
    				return Arrays.equals((boolean[])massiv1,(boolean[])massiv2);
    			} else if(massiv1 instanceof char[]) {
    				return Arrays.equals((char[])massiv1,(char[])massiv2);
    			} else if(massiv1 instanceof float[]) {
    				return Arrays.equals((float[])massiv1,(float[])massiv2);
    			} else if(massiv1 instanceof double[]) {
    				return Arrays.equals((double[])massiv1,(double[])massiv2);
    			} else if(massiv1 instanceof short[]) {
    				return Arrays.equals((short[])massiv1,(short[])massiv2);
    			} else if(massiv1 instanceof long[]) {
    				return Arrays.equals((long[])massiv1,(long[])massiv2);
    			} else {
    				return massiv1.equals(massiv2);
    			}
    		}
    	}

    поиск элемента в массиве
    http://ideone.com/iqNA7l

    GovnoGovno, 03 Апреля 2014

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

    +150

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public function responsive()
     {
      $month = array("1" => "Responsive", "2" => "Unresponsive");
      for ($i = 1; $i <= 2; $i++)
      {
       $data[] = array('text' => $month[$i], 'value' => $i);
      }
      echo json_encode($data);
     }

    Мне кажеться индусы пишут лучше

    texnikru, 12 Марта 2014

    Комментарии (17)
  7. Java / Говнокод #14523

    +74

    1. 1
    JSONObject jonReady = props.getObject(MessageType.Keys.onReady);

    Who is John Ready?

    myzone, 07 Февраля 2014

    Комментарии (17)
  8. Java / Говнокод #14494

    +69

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public List<ImportException> importFiles() {
        Collection<ImportException> exceptions = new ArrayList<ImportException>();
        /* весь метод exceptions ссылается на этот список */
        return (List<ImportException>) exceptions;
    }

    Полиморфизм ёпт

    evg_ever, 04 Февраля 2014

    Комментарии (17)
  9. PHP / Говнокод #14457

    +161

    1. 1
    if ($pathRelative && $relativePath) {

    Взято из либы Google DFP

    Lowezar, 31 Января 2014

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

    +79

    1. 1
    2. 2
    3. 3
    4. 4
    if(VovaJSONparser.ParseText(d, text))
    {
    	return d;
    }

    Вова, фас!

    arbuzz, 16 Января 2014

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function get_the_fucking_first_image_from_the_fucking_content_DUDE_is_this_really_so_hard($content)
    {
       preg_match_all('/(<img .*? src=\"\/images.*?\">?)/', $content, $result);
       return $result[0][0];
    }

    мне кажется, коллега задолбался

    russling, 08 Января 2014

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