1. Java / Говнокод #16718

    +76

    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
    function returnUserId() {
        if (document.getElementById('userstap') != null )  {
            var obj = document.getElementById('userstap');
            <% if ((sUserIdForPrint != null) && !sUserIdForPrint.equals("")) {%>
            if (obj.options[obj.selectedIndex].value == 0) {
                return "<%=sUserIdForPrint%>";
            <% } %>
            <% if (((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")) && ((sUserIdForPrint != null) && !sUserIdForPrint.equals(""))) {%>
            } else if (obj.options[obj.selectedIndex].value == 1 ) {
                return "<%=sAccGrpUserIdForPrint%>";
            <% } else if ((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")){%>
            if (obj.options[obj.selectedIndex].value == 1 ) {
                return "<%=sAccGrpUserIdForPrint%>";
            <% } %>
            <% if (((sAccGrpUserIdForPrint != null) && !sAccGrpUserIdForPrint.equals("")) || ((sUserIdForPrint != null) && !sUserIdForPrint.equals(""))) {%>
            } else if (obj.options[obj.selectedIndex].value == 2) {
                return "<%=userId%>";
            }
            <% } else {%>
            if (obj.options[obj.selectedIndex].value == 2) {
                return "<%=userId%>";
            }
            <% } %>
        } else {
            return "<%=userId%>";
        }
    }

    Любите ли вы JSP так, как люблю его я?

    codingHorror, 18 Сентября 2014

    Комментарии (14)
  2. PHP / Говнокод #16717

    +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
    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
    <?php
    
    /**
     * Get category tree.
     * 
     * @param db $db
     * @return array
     */
    function getCategoryTree ($db) {
    	$query = $db->query('SELECT * FROM dle_category ORDER BY posi');
    	
    	if ($query->num_rows <= 0) {
    		return FALSE;
    	}
    	
    	$categories = $query->fetch_all(MYSQLI_ASSOC);
    	
    	$tree = array();
    	
    	foreach ($categories as $cat) {
    		if ($cat['parentid'] == '0') {
    			$tree[$cat['id']] = $cat;
    		}
    		else {
    			$tree[$cat['parentid']]['subcategories'][] = $cat;
    		}
    	}
    	
    	return $tree;
    }
    
    /**
     * Display categories.
     * Sorry for my french 'echo'.
     * 
     * @param array $category
     */
    function displayCategory ($category) {
    	$html = '';
    	
    	foreach ($category as $cat) {
    		$html .= '<li class="lonely "><a href="/">' . $cat['name'] . '</a>';
    		
    		if ($cat['subcategories']) {
    			$html .= '<span class="accordion"></span><ul>';
    			$html .= displayCategory ($cat['subcategories']);
    			$html .= '</ul>';
    		}
    		
    		$html .= '</li>';
    	}
    	
    	return $html;
    }
    
    // Getting categories
    $categories = getCategoryTree($db);
    
    if ($categories) {
    	echo displayCategory ($categories);
    }
    else {
    	echo '<li>Нету категорий</li>';
    }

    Мой говно модуль для DLE для отображения дерева категорий в меню.
    Почему DLE разработчики не могли это из коробки сделать? И почему там куча говнокода внутри? (на Англ. комментарии потому что привык)

    volter9, 17 Сентября 2014

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

    +140

    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
    @foreach (var groupTest in Model.Select(t => t.TestType).Distinct())
    {
        <div class="form-column form-column2">
            <div class="static-height">
                <p class="content-subblock-title left upper-text">
                    <label>
                        @if (@groupTest.GetEnumDescription().Length < 34)
                        {
                            <text>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text>
                        }
                        @groupTest.GetEnumDescription()
                    </label>
                </p>
                @foreach (var item in Model.Where(t => t.TestType == groupTest).OrderBy(t => t.Order))
                {
                    <div class="donation-row">
                        <label>@item.TestName</label>
                        <span class="@item.TestClass blood-test-value-don">
                            @item.TestValue
                        </span>
                    </div>
                }
    
            </div>
        </div>
    }

    Я пялюсь на этот кусок вот уже полчаса...

    amatenkov, 17 Сентября 2014

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

    +135

    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
    if ((Mathf.Abs(_mouseOverX) > 0.2f || Mathf.Abs(_mouseOverY) > 0.2f))
         {
    
    
            switch (selecetedItemIndex)
         {
                case -1 :
                    var a = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a += angle / 2.0f;
                    if (a < 0) a = a + 360.0f;
    
                    index = (int)(a / angle);
             break;
                case 0:
                    var a0 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a0 += angle / 2.0f;
                    if (a0 < 0) a0 = a0 + 360.0f;
    
                    index = (int)(a0 / angle);
    
                 switch (index)
                 {
                     case 5 :
                         index = 7;
                         break;
                        case 6:
                            index = 7;
                            break;
                        case 4 :
                         index = -1;
                         break;
                        case 3:
                            index = 1;
                            break;
                        case 2:
                            index = 1;
                            break;
                 }
                 break;
                case 1:
                    var a1 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a1 += angle / 2.0f;
                    if (a1 < 0) a1 = a1 + 360.0f;
    
                    index = (int)(a1 / angle);
    
                 switch (index)
                 {
                     case 0 :
                         index = 0;
                         break;
                        case 7:
                            index = 0;
                            break;
                        case 6 :
                         index = -1;
                         break;
                        case 5:
                            index = -1;
                            break;
                        case 4:
                            index = 3;
                            break;
                        case 3:
                            index = 3;
                            break;
                        case 2:
                            index = 2;
                            break;
                 }
                 break;
                case 2:
                    var a2 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a2 += angle / 2.0f;
                    if (a2 < 0) a2 = a2 + 360.0f;
    
                    index = (int)(a2 / angle);
    
                    switch (index)
                    {
                        case 0: index = 1; break;
                        case 7: index = 1; break;
                        case 6: index = -1; break;
                        case 5: index = 3; break;
                        case 4: index = 3; break;
                    }
                    break;
                case 3:
                    var a3 = Mathf.Atan2(_mouseOverX, _mouseOverY) * Mathf.Rad2Deg;
                    a3 += angle / 2.0f;
                    if (a3 < 0) a3 = a3 + 360.0f;
    
                    index = (int)(a3 / angle);
    
                    switch (index)

    Radial menu govnokod style

    noshitleft, 17 Сентября 2014

    Комментарии (2)
  5. JavaScript / Говнокод #16714

    +135

    1. 1
    function e(id){ return document.getElementById(id); }

    Бредогенерации тред.

    3.14159265, 17 Сентября 2014

    Комментарии (585)
  6. C++ / Говнокод #16713

    +53

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    // quick render params menu actions
        if(pe->buttons()&Qt::LeftButton || pe->buttons()&Qt::RightButton){
            //
            if(cRenderMenuOpended){//
                if((p.x()+p.y())<18){//   - -
                    cRenderMenuOpended=!cRenderMenuOpended;
                    repaint();
                    return;
                }
                else if(p.x()>5 && p.y()>5 && p.x()<145 && p.y()<cRenderMenuHeight){// actions rectangle
                    //
                    //sliceModifyMode=true; // show slice plane and can be modified
                    //useSlicePlane=true;   // build geometry with slice plane
                    if(cViewType==0){// 2D
                        if(p.x()>10 && p.y()>22 && p.x()<140 && p.y()<38){
                            // reset zoom
                            if(c2DZoom1To1){
                                cPanFor2DX1to1=0;
                                cPanFor2D=0;
                                cPanFor2DX=0;
                                cZoomFor2D=1;
    
                                if(cViewType==0 && c2DZoom1To1 && renderLimits){
                                    auto testSizeX=cVieportXSize;
                                    auto testSizeY=cVieportYSize;
    
                                    BoundaryConditionsOfComposite *cond=NULL;
                                    cond=AbstractContainer::getInstance()->getBoundaryCondition(0);
                                    if(cond->isHeatFlux_multiple()){
                                        cPanFor2D+=15;
                                        testSizeY-=20;
                                    }
                                    if(cond->isHeatFlux_multiple() || cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
                                        cPanFor2D+=20;
                                        testSizeY-=25;
                                    }
    
                                    cond=AbstractContainer::getInstance()->getBoundaryCondition(3);
                                    if(cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
                                        testSizeX-=35;
                                        cPanFor2DX1to1+=30;
                                    }
                                    cond=AbstractContainer::getInstance()->getBoundaryCondition(1);
                                    if(cond->isHeatFlux() || cond->isHeatPower() || cond->isConvection() || cond->isInsulated() || cond->isTemperature()){
                                        testSizeX-=35;
                                    }
    
                                    if(cWidth>cThikness){
                                        cZoomFor2D=(double(testSizeX)-50.0)/(zoomed2DX(width_sub_start)-zoomed2DX(width_sub_end));
                                    }
                                    else{
                                        cZoomFor2D=(double(testSizeY)-50.0)/(zoomed2DY(thickness_sub_start)-zoomed2DY(thickness_sub_end));
                                    }
                                }
                            }
                            else{
                                cZoomFor2D=1;
                                cPanFor2D=0;
                                cPanFor2DX=0;
                            }
    
                            repaint();
                            return;
                        }
                        else if(p.x()>10 && p.y()>42 && p.x()<140 && p.y()<58){
                            cForbidRenderResultsOverLayers=!cForbidRenderResultsOverLayers;
                            repaint();
                            return;
                        }
                        else if(p.x()>10 && p.y()>62 && p.x()<140 && p.y()<78){
                            renderLimits++;
                            if(renderLimits>1){
                                renderLimits=0;
                            }
                            repaint();
                            return;
                        }
                        else if(p.x()>10 && p.y()>82 && p.x()<140 && p.y()<98){
                            SLOT_swap2DMode11AndScaled();
                            return;
                        }
                        else if(p.x()>106 && p.y()>92 && p.x()<122 && p.y()<118){
                            cResTransparency-=0.1;
                            if(cResTransparency<0){cResTransparency=0;}
                            repaint();
                            return;
                        }
                        else if(p.x()>124 && p.y()>92 && p.x()<140 && p.y()<118){
                            cResTransparency+=0.1;
                            if(cResTransparency>1){cResTransparency=1;}
                            repaint();
                            return;
                        }
                    }
                    else{//3D
                        if(p.x()>10 && p.y()>22 && p.x()<140 && p.y()<38){
                            slot_swapCoordiantes();
                            return;
                        }
                        else if(p.x()>10 && p.y()>42 && p.x()<140 && p.y()<58){

    Магия чисел в построении GUI

    Abbath, 17 Сентября 2014

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

    +51

    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
    QVector<double*>*** ElemBoundCond = tbc->getElementsBC();
        QVector<double*>* preNodalVals = tbc->getPreNodalValues();
        QVector<double*>* nodalForces = tbc->getNodalForces();
    
        long elems = grid->getElemsNumber();
        long nodes = grid->getNodesNumber();
        long** Elements = grid->getElems();
        double** Nodes = grid->getNodes();
        long* ElemMaters = grid->getElemsMaterials();
        long NBW = grid->getBandWidth();
    
        emit signal_addLineToCalculationProtocol(">>> Solve heat problem ");
    
        long    NS[4],//+numbers of 4 nodes
                NCL = 1,//number or unknown values per node (1 for thermal analysis)
                ni, nj, nk,//face nodes
                gnN, dN;
        double  ESM[4][4],//+element stiffness matrix
                EF[4],//+element force matrix
                **C,//matrix conteins X, Y, Z coordinates, rows like |1 Xi Yi Zi|
                **CA,//conteins columns like |ai bi ci di|
                //*GF,//band matrix, pointers to Global Force and Global Sriffness Matrices in A
                V36,//+hexa and 36 element volume
                S_3,//face area div 3
                hS_3, hS_6, hS_12,//h * face area div 6 and div 12
                hST_3,//h * face area * T / 3
                qS_3;//q * face area / 3
        QVector<double*>* fcond;
        MaterialsDatabase* matdb = MaterialsDatabase::getInstance();
        double  Kxx, Kyy, Kzz;//thermal condactivities in X, Y and Z axes

    И снова фортранщина.

    Abbath, 17 Сентября 2014

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

    +79

    1. 1
    2. 2
    // Number a, Number b
    return new Double(a.doubleValue() - numericTolerance).compareTo(b.doubleValue()) < 0

    В продолжение #16698, после рефакторинга. Видимо, диагноз: ООП головного мозга.

    Actine, 17 Сентября 2014

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

    +129

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    class Class1
    {
        ...
        public bool checkErrors(){...}
        public void DrawNumber(){...}
        public void PDF_Resize(){...}
        ...
    }

    http://vk.com/feed?z=photo-30666517_340773889%2Fb5a138e78eb1b23380

    dzzpchelka, 17 Сентября 2014

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

    +57

    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
    void NestMathematica::DATABS(){
      int ks1 = 0;
      int ns1=0;
      int ns=0;
      ia=-1;
      ia=ia+1;
      b[ia]=-ak[0];
      ia=ia+1;
      b[ia]=alfa;
      mud=1;
      mld=1;
      if(ks!=1){
        ia=ia+1;
        b[ia]=0.;
        ks1=ks-1;
        for(int i=0; i<ks1; i++){
          ns1=ns;
          ns=ns+1;
          if(ns!=1){
            ia=ia+1;
            b[ia]=0.;
          }
          ia=ia+1;
          b[ia]=ak[ns1];
          ia=ia+1;
          b[ia]=0.;
          ia=ia+1;
          b[ia]=-ak[ns];
          ia=ia+1;
          b[ia]=0.;
          ia=ia+1;
          b[ia]=h[ns1];
          ia=ia+1;
          b[ia]=1.;
          ia=ia+1;
          b[ia]=0.;
          ia=ia+1;
          b[ia]=-1.;
          if(ns!=ks){
            ia=ia+1;
            b[ia]=0.;
          }
        }
        mud=2;
        mld=2;
        ia=ia+1;
        b[ia]=0.;
      }	//10
      if(beta<0){
        ia=ia+1;
        b[ia]=h[ks-1];
        ia=ia+1;
        b[ia]=1.;
      }else{
        ia=ia+1;
        b[ia]=ak[ks]+beta*h[ks];
        ia=ia+1;
        b[ia]=beta;
      }
      return;
    }

    Программист на фортране может программировать на любом языке... как на фортране.

    Abbath, 16 Сентября 2014

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