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

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

    −125

    1. 1
    2. 2
    3. 3
    if [ $count > 0 ]; then
        ...
    fi

    bormand, 18 Апреля 2014

    Комментарии (18)
  3. PHP / Говнокод #15762

    +155

    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
    switch ( count($args) )
    		{
    			case 0:
    				return $obj->$method( );
    			case 1:
    				return $obj->$method( $args[0] );
    			case 2:
    				return $obj->$method( $args[0], $args[1] );
    			case 3:
    				return $obj->$method( $args[0], $args[1], $args[2] );
    			case 4:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3] );
    			case 5:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4] );
    			case 6:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] );
    			case 7:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] );
    			case 8:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7] );			
    			case 9:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8] );			
    			case 10:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9] );			
    			case 11:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10] );			
    			case 12:
    				return $obj->$method( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6], $args[7], $args[8], $args[9], $args[10], $args[11]   );			
    		}
    		throw new MWException( __CLASS__.": too many arguments to method called in ".__METHOD__ );

    thekiba, 16 Апреля 2014

    Комментарии (18)
  4. Java / Говнокод #15549

    +68

    1. 1
    2. 2
    3. 3
    boolean isCyrillic(char c) {
        return Character.UnicodeBlock.CYRILLIC.equals(Character.UnicodeBlock.of(c));
    }

    Краткость - сестра таланта

    evg_ever, 21 Марта 2014

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

    +46

    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
    //В хедере
        QVector<double> stateStack;
    //Сохраняем
        stateStack.push_back((double)renderInclusionsAs3DMeshSpheres);
        stateStack.push_back((double)transparencyForClosestSidePolies);
        stateStack.push_back((double)renderFEMGrid);
        stateStack.push_back((double)NEST_results_detail_per_unit);
        stateStack.push_back((double)sourceLineActive);
        stateStack.push_back((double)renderScale);
        stateStack.push_back((double)c2DZoom1To1);
        stateStack.push_back((double)render2DInclusions);
        stateStack.push_back((double)render3DInclusions);
        stateStack.push_back((double)renderNESTResults);
        stateStack.push_back((double)renderFEAResults);
        stateStack.push_back((double)NEST_anumTime);
        stateStack.push_back((double)isAnimRun);
        stateStack.push_back((double)NEST_timeIterToRender);
        stateStack.push_back((double)NEST_RenderResultsIn3D);
        stateStack.push_back((double)NEST_renderTestPoints);
        stateStack.push_back((double)nestNewResults);
        stateStack.push_back((double)fibers_renderFormedRegions);
        stateStack.push_back((double)sourceLineStarted);
        stateStack.push_back((double)renderSourceLine);
        stateStack.push_back((double)heatQuadsModifyMode);
        stateStack.push_back((double)renderTopHeats);
        stateStack.push_back((double)sliceModifyMode);
        stateStack.push_back((double)useSlicePlane);
        stateStack.push_back((double)showSlicedPart);
        stateStack.push_back((double)cRenderMenuOpended);
        stateStack.push_back((double)cForbidRenderResultsOverLayers);
        stateStack.push_back((double)renderCoordLines);
        stateStack.push_back((double)renderDimensions);
        stateStack.push_back((double)renderLimits);
        stateStack.push_back((double)cResTransparency);
        stateStack.push_back((double)cRenderResultsOverLayers);
        stateStack.push_back((double)cActiveLayer);
        stateStack.push_back((double)renderMiniMapAtTop);
        stateStack.push_back((double)subCompositeMode);
        stateStack.push_back((double)subCompositeMapRendering);
        stateStack.push_back((double)fibersRenderable);
        stateStack.push_back((double)renderFibersAsMesh);
        stateStack.push_back((double)droplets_detailedSpheres);
        stateStack.push_back((double)cViewType);
    //Загружаем
     renderInclusionsAs3DMeshSpheres   =(bool)stateStack[0];
        transparencyForClosestSidePolies=        stateStack[1];
        renderFEMGrid=(bool)                     stateStack[2];
        NEST_results_detail_per_unit=            stateStack[3];
        sourceLineActive=(bool)                  stateStack[4];
        renderScale=(bool)                       stateStack[5];
        c2DZoom1To1=(bool)                       stateStack[6];
        render2DInclusions=(bool)                stateStack[7];
        render3DInclusions=(bool)                stateStack[8];
        renderNESTResults=(bool)                 stateStack[9];
        renderFEAResults=(bool)                  stateStack[10];
        NEST_anumTime=                           stateStack[11];
        isAnimRun=(bool)                         stateStack[12];
        NEST_timeIterToRender=                   stateStack[13];
        NEST_RenderResultsIn3D=(bool)            stateStack[14];
        NEST_renderTestPoints=(bool)             stateStack[15];
        nestNewResults=(bool)                    stateStack[16];
        fibers_renderFormedRegions=(bool)        stateStack[17];
        sourceLineStarted=(bool)                 stateStack[18];
        renderSourceLine=(bool)                  stateStack[19];
        heatQuadsModifyMode=(bool)               stateStack[20];
        renderTopHeats=(bool)                    stateStack[21];
        sliceModifyMode=(bool)                   stateStack[22];
        useSlicePlane=(bool)                     stateStack[23];
        showSlicedPart=(bool)                    stateStack[24];
        cRenderMenuOpended=(bool)                stateStack[25];
        cForbidRenderResultsOverLayers=(bool)    stateStack[26];
        renderCoordLines=                        stateStack[27];
        renderDimensions=(bool)                  stateStack[28];
        renderLimits=                            stateStack[29];
        cResTransparency=                        stateStack[30];
        cRenderResultsOverLayers=(bool)          stateStack[31];
        cActiveLayer=                            stateStack[32];
        renderMiniMapAtTop       =(bool)         stateStack[33];
        subCompositeMode         =(bool)         stateStack[34];
        subCompositeMapRendering =(bool)         stateStack[35];
        fibersRenderable=(bool)                  stateStack[36];
        renderFibersAsMesh=(bool)                stateStack[37];
        droplets_detailedSpheres=                stateStack[38];
        cViewType=                               stateStack[39];

    Структуры для педиков.

    Abbath, 25 Февраля 2014

    Комментарии (18)
  6. Си / Говнокод #14511

    +137

    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
    #define SPLICE(a,b) SPLICE_1(a,b)
    #define SPLICE_1(a,b) SPLICE_2(a,b)
    #define SPLICE_2(a,b) a##b
     
     
    #define PP_ARG_N( \
              _1,  _2,  _3,  _4,  _5,  _6,  _7,  _8,  _9, _10, \
             _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
             _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \
             _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \
             _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
             _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \
             _61, _62, _63, N, ...) N
     
    /* Note 63 is removed */
    #define PP_RSEQ_N()                                        \
             62, 61, 60,                                       \
             59, 58, 57, 56, 55, 54, 53, 52, 51, 50,           \
             49, 48, 47, 46, 45, 44, 43, 42, 41, 40,           \
             39, 38, 37, 36, 35, 34, 33, 32, 31, 30,           \
             29, 28, 27, 26, 25, 24, 23, 22, 21, 20,           \
             19, 18, 17, 16, 15, 14, 13, 12, 11, 10,           \
              9,  8,  7,  6,  5,  4,  3,  2,  1,  0
     
    #define PP_NARG_(...)    PP_ARG_N(__VA_ARGS__)    
     
    /* Note dummy first argument _ and ##__VA_ARGS__ instead of __VA_ARGS__ */
    #define PP_NARG(...)     PP_NARG_(_, ##__VA_ARGS__, PP_RSEQ_N())
     
    #define NARG(...)     func(PP_NARG(__VA_ARGS__), __VA_ARGS__)
     
    #define INCR 20
     
    #define FIELD_0(...)
     
    #define FIELD_1(field, ...) \
      INCR+field
     
    #define FIELD_2(field, ...) \
      INCR+field, FIELD_1(__VA_ARGS__)
     
    #define FIELD_3(field, ...) \
      INCR+field, FIELD_2(__VA_ARGS__)
     
    #define FIELD_4(field, ...) \
      INCR+field, FIELD_3(__VA_ARGS__)
     
    #define FIELD_5(field, ...) \
      INCR+field, FIELD_4(__VA_ARGS__)
     
    #define FIELD_5(field, ...) \
      INCR+field, FIELD_4(__VA_ARGS__)
     
    #define FIELD_6(field, ...) \
      INCR+field, FIELD_5(__VA_ARGS__)
     
    #define FIELD_7(field, ...) \
      INCR+field, FIELD_6(__VA_ARGS__)
     
    #define FIELD_8(field, ...) \
      INCR+field, FIELD_7(__VA_ARGS__)
     
    #define FIELD_9(field, ...) \
      INCR+field, FIELD_8(__VA_ARGS__)
     
    #define FIELD_10(field, ...) \
      INCR+field, FIELD_9(__VA_ARGS__)
     
    #define FIELD_11(field, ...) \
      INCR+field, FIELD_10(__VA_ARGS__)
    //..... дальше лень ...
     
    #define FIELDS_(N, ...) \
      SPLICE(FIELD_, N)(__VA_ARGS__)
     
    #define FIELDS(...) \
      FIELDS_(PP_NARG(__VA_ARGS__), __VA_ARGS__)
     
     
    a = { FIELDS('p', 'a', 's', 's', 'w', 'o', 'r', 'd') }

    Примитивное компил-тайм шифрование строки через сишный препроцессор. На выходе получаем

    a = { 20 +'p', 20 +'a', 20 +'s', 20 +'s', 20 +'w', 20 +'o', 20 +'r', 20 +'d' };

    Базируется на http://smackerelofopinion.blogspot.com/2011/10/determining-number-of-arguments-in-c.html

    j123123, 06 Февраля 2014

    Комментарии (18)
  7. JavaScript / Говнокод #14463

    +154

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function login()
    	{
    	$.ajax({
    		type:'post',
    		url:'index.php/main/login',
    		data:{x:1},
    	 success:function(data){
                   $("body").html(data);
                }
              });
         }

    Функция из single page приложения

    devalentino, 01 Февраля 2014

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

    +71

    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
    app_preferences = PreferenceManager.getDefaultSharedPreferences(context);
    			
    	        mApplication = (MyApplication)context;
    if(mApplication.nomgor == 0 ){
                  mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID", "0"));
    		      mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID","");//в работе
                  }
                if(mApplication.nomgor == 1 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID1", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID1","");//в работе
                  }
                if(mApplication.nomgor == 2 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID2", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID2","");//в работе
                   }
                if(mApplication.nomgor == 3 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID3", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID3","");//в работе
                   }
                if(mApplication.nomgor == 4 ){
                  mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID4", "0"));
                  mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID4","");//в работе
                  }
                if(mApplication.nomgor == 5 ){
                  mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID5", "0"));
                  mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID5","");//в работе
                  }
                if(mApplication.nomgor == 6 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID6", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID6","");//в работе
                   }
                if(mApplication.nomgor == 7 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID7", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID7","");//в работе
                   }
                if(mApplication.nomgor == 8 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID8", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID8","");//в работе
                   }
                if(mApplication.nomgor == 9 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID9", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID9","");//в работе
                   }
                if(mApplication.nomgor == 10 ){
                  mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID10", "0"));
                  mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID10","");//в работе
                  }
                if(mApplication.nomgor == 11 ){
                  mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID11", "0"));
                  mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID11","");//в работе
                  }
                if(mApplication.nomgor == 12 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID12", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID12","");//в работе
                   }
                if(mApplication.nomgor == 13 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID13", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID13","");//в работе
                  }
                if(mApplication.nomgor == 14 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID14", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID14","");//в работе
                   }
                if(mApplication.nomgor == 15 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID15", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID15","");//в работе
                   }
                if(mApplication.nomgor == 16 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID16", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID16","");//в работе
                   }
                if(mApplication.nomgor == 17 ){
                   mApplication.MyPacket.id = Integer.parseInt(app_preferences.getString("ID17", "0"));
                   mApplication.MyPacket.Pass = app_preferences.getString("PASS_ID17","");//в работе
                   }

    кто-то с детства привык копипастить

    grampe, 09 Октября 2013

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

    +136

    1. 1
    2. 2
    3. 3
    if (ds2.Rows[l]["MIMETYPE"].ToString().Length >= 5 && ds2.Rows[l]["MIMETYPE"].ToString().Substring(0, 5).ToLower() == "image"){
     //  кучка гуана
    }

    Наверное определяется тип вложения.
    Path для лохов

    bars, 09 Октября 2013

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

    +11

    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
    AbstractMessageFrame * DataLength = create_frame(
    		make_condition_reader(this,
    			fnc_ext::bind(
    				fnc_ext::compose1(
    					fnc_ext::compose2(std::logical_or<bool>(),
    									  std::bind2nd(std::equal_to<byte>(), PC5000FlashFeatures::MARKER_SYMBOL),
    									  std::bind2nd(std::equal_to<byte>(), PC5000FlashFeatures::SPACE_SYMBOL)),
    					fnc_ext::mem_fun<const ByteBuffer, const byte&>(&ByteBuffer::back) ),
    				&_receivedBuffer),
    			fnc_ext::bind(
    				fnc_ext::compose2(std::logical_or<bool>(),
    								  fnc_ext::compose1(std::bind2nd(std::greater<WORD>(),
    																 PC5000FlashFeatures::LENGTH_HEADER +
    																 _maxCommandFieldLength +
    																 PC5000FlashFeatures::LENGTH_MARKER +
    																 PC5000FlashFeatures::LENGTH_OF_LENGTH),
    													fnc_ext::mem_fun(&ByteBuffer::length)),
    								  fnc_ext::compose1(fnc_ext::compose2(std::logical_and<bool>(),
    																	  std::not1(std::ptr_fun<const char, bool>((SymbolCheckFunc)isDigit)),
    																	  std::not1(std::ptr_fun<const char, bool>((SymbolCheckFunc)isEnglishLetter))),
    													fnc_ext::mem_fun<const abstractBuffer<unsigned char>, const byte&>(&ByteBuffer::back)) ),
    				&_receivedBuffer) ),
    		fnc_ext::bind(std::mem_fun(&ThisClass::setDataLength), this),
    		"Data Length");

    Композиции, частичные применения, функторы? Больше тотальной функциональщины! Вложенность продолжает расти с развитием проекта.

    laMer007, 17 Сентября 2013

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

    +140

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    var x = 43;
    var y = 34;
    var z = x++ + --y;
    console.log(z);
    console.log(y);
    console.log(x);

    %D

    Stealth, 11 Сентября 2013

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