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

    В номинации:
    За время:
  2. 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)
  3. C# / Говнокод #16683

    +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
    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
    if(GUI.Button(Rect(100,50,50,50),NewTexture[0])) 
    { Change = true; Clicks += 1; GridNumber = 0;   }
    if(GUI.Button(Rect(150,50,50,50),NewTexture[1])) 
    { Change = true; Clicks += 1; GridNumber = 1;   }
    if(GUI.Button(Rect(200,50,50,50),NewTexture[2])) 
    { Change = true; Clicks += 1; GridNumber = 2;   }
    if(GUI.Button(Rect(250,50,50,50),NewTexture[3])) 
    { Change = true; Clicks += 1; GridNumber = 3;   }
    if(GUI.Button(Rect(300,50,50,50),NewTexture[4])) 
    { Change = true; Clicks += 1; GridNumber = 4;   }
    if(GUI.Button(Rect(350,50,50,50),NewTexture[5])) 
    { Change = true; Clicks += 1; GridNumber = 5;   }
    if(GUI.Button(Rect(400,50,50,50),NewTexture[6])) 
    { Change = true; Clicks += 1; GridNumber = 6;   }
    if(GUI.Button(Rect(100,100,50,50),NewTexture[7])) 
    { Change = true; Clicks += 1; GridNumber = 7;   }
    if(GUI.Button(Rect(150,100,50,50),NewTexture[8])) 
    { Change = true; Clicks += 1; GridNumber = 8;   }
    if(GUI.Button(Rect(200,100,50,50),NewTexture[9])) 
    { Change = true; Clicks += 1; GridNumber = 9;   }
    if(GUI.Button(Rect(250,100,50,50),NewTexture[10])) 
    { Change = true; Clicks += 1; GridNumber = 10;  }
    if(GUI.Button(Rect(300,100,50,50),NewTexture[11])) 
    { Change = true; Clicks += 1; GridNumber = 11;  }
    if(GUI.Button(Rect(350,100,50,50),NewTexture[12])) 
    { Change = true; Clicks += 1; GridNumber = 12;  }
    if(GUI.Button(Rect(400,100,50,50),NewTexture[13])) 
    { Change = true; Clicks += 1; GridNumber = 13;  }
    if(GUI.Button(Rect(100,150,50,50),NewTexture[14])) 
    { Change = true; Clicks += 1; GridNumber = 14;  }
    if(GUI.Button(Rect(150,150,50,50),NewTexture[15])) 
    { Change = true; Clicks += 1; GridNumber = 15;  }
    if(GUI.Button(Rect(200,150,50,50),NewTexture[16])) 
    { Change = true; Clicks += 1; GridNumber = 16;  }
    if(GUI.Button(Rect(250,150,50,50),NewTexture[17])) 
    { Change = true; Clicks += 1; GridNumber = 17;  }
    if(GUI.Button(Rect(300,150,50,50),NewTexture[18])) 
    { Change = true; Clicks += 1; GridNumber = 18;  }
    if(GUI.Button(Rect(350,150,50,50),NewTexture[19])) 
    { Change = true; Clicks += 1; GridNumber = 19;  }
    if(GUI.Button(Rect(400,150,50,50),NewTexture[20])) 
    { Change = true; Clicks += 1; GridNumber = 20;  }
    if(GUI.Button(Rect(100,200,50,50),NewTexture[21])) 
    { Change = true; Clicks += 1; GridNumber = 21;  }
    if(GUI.Button(Rect(150,200,50,50),NewTexture[22])) 
    { Change = true; Clicks += 1; GridNumber = 22;  }
    if(GUI.Button(Rect(200,200,50,50),NewTexture[23])) 
    { Change = true; Clicks += 1; GridNumber = 23;  }
    if(GUI.Button(Rect(250,200,50,50),NewTexture[24])) 
    { Change = true; Clicks += 1; GridNumber = 24;  }
    if(GUI.Button(Rect(300,200,50,50),NewTexture[25])) 
    { Change = true; Clicks += 1; GridNumber = 25;  }
    if(GUI.Button(Rect(350,200,50,50),NewTexture[26])) 
    { Change = true; Clicks += 1; GridNumber = 26;  }
    if(GUI.Button(Rect(400,200,50,50),NewTexture[27])) 
    { Change = true; Clicks += 1; GridNumber = 27;  }
    if(GUI.Button(Rect(100,250,50,50),NewTexture[28])) 
    { Change = true; Clicks += 1; GridNumber = 28;  }
    if(GUI.Button(Rect(150,250,50,50),NewTexture[29])) 
    { Change = true; Clicks += 1; GridNumber = 29;  }
    if(GUI.Button(Rect(200,250,50,50),NewTexture[30])) 
    { Change = true; Clicks += 1; GridNumber = 30;  }
    if(GUI.Button(Rect(250,250,50,50),NewTexture[31])) 
    { Change = true; Clicks += 1; GridNumber = 31;  }
    if(GUI.Button(Rect(300,250,50,50),NewTexture[32])) 
    { Change = true; Clicks += 1; GridNumber = 32;  }
    if(GUI.Button(Rect(350,250,50,50),NewTexture[33])) 
    { Change = true; Clicks += 1; GridNumber = 33;  }
    if(GUI.Button(Rect(400,250,50,50),NewTexture[34])) 
    { Change = true; Clicks += 1; GridNumber = 34;  }
    if(GUI.Button(Rect(400,350,50,50),NewTexture[40])) 
    { Change = true; Clicks += 1; GridNumber = 40;  }
    if(GUI.Button(Rect(450,350,50,50),NewTexture[41])) 
    { Change = true; Clicks += 1; GridNumber = 41;  }
    if(GUI.Button(Rect(500,350,50,50),NewTexture[42])) 
    { Change = true; Clicks += 1; GridNumber = 42;  }
    ...
    if(GUI.Button(Rect(100,550,65,65),NewTexture[35])) 
    { Change = true; Clicks += 1; GridNumber = 35; }
    if(GUI.Button(Rect(165,550,65,65),NewTexture[36])) 
    { Change = true; Clicks += 1; GridNumber = 36; }
    if(GUI.Button(Rect(230,550,65,65),NewTexture[37])) 
    { Change = true; Clicks += 1; GridNumber = 37; }
    if(GUI.Button(Rect(295,550,65,65),NewTexture[38])) 
    { Change = true; Clicks += 1; GridNumber = 38; }
    if(GUI.Button(Rect(360,550,65,65),NewTexture[39])) 
    { Change = true; Clicks += 1; GridNumber = 39; }

    http://answers.unity3d.com/questions/691870/gui-button-not-showing-up.html

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

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

    −402

    1. 1
    2. 2
    3. 3
    4. 4
    UIDevice* thisDevice = [UIDevice currentDevice];
        char cfunktion[] = {'u', 'n', 'i', 'q', 'u', 'e', 'I', 'd', 'e', 'n', 't', 'i', 'f', 'i', 'e', 'r',0};
        SEL udid = NSSelectorFromString([NSString stringWithUTF8String:cfunktion]);
        id identifier =[thisDevice performSelector:udid];

    Безпалевно вызываем скрытые апи.

    Psionic, 09 Сентября 2014

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

    +73

    1. 1
    Class <? extends Object> currentClass = Class.forName( clazz )

    Продолжаем разговор...

    sakkath, 05 Сентября 2014

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

    +144

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    for (conn_vector::iterator i = m_connections.begin(); i != m_connections.end(); ++i) {
        if (*i == conn) {
            toDelete = *i;
            m_connections.erase(i);
            break;
        }
    }

    Да, С++98. Да, в std::find не умеем. Да, сегфолт. Да, моё.

    Elvenfighter, 27 Августа 2014

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

    +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
    try
    {
    	HttpWebRequest httpWebReq = (HttpWebRequest)WebRequest.Create(this.OURURL);
    	httpWebReq.Timeout = 2000;
    	httpWebReq.Method = "POST";
    
    	string Response = ResponseStreamReader.ReadToEnd();
    	
    	// bla-bla-bla ...
    
    	httpWebReq.GetResponse().Close();
    	httpWebReq = null;
    	Response = null;
    }

    Smekalisty, 19 Августа 2014

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

    +164

    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
    .error(function(error) {
                                                                    sendResult(500, "ERROR. " + error);
                                                                })
                                                        })
                                                        .error(function(error) {
                                                            sendResult(500, "ERROR. " + error);
                                                        })
                                                })
                                                .error(function(error) {
                                                    sendResult(500, "ERROR. " + error);
                                                })
                                        })
                                        .error(function(error) {
                                            sendResult(500, "ERROR. " + error);
                                        });
                                })
                                .error(function(error) {
                                    sendResult(500, "ERROR. " + error);
                                });
                        })
                        .error(function(error) {
                            sendResult(500, "ERROR. " + error);
                        });
                })
                .error(function(error) {
                    sendResult(500, "ERROR. " + error);
                });

    strax, 31 Июля 2014

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

    +154

    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
    function parseString($str) {
         $op = array();
        $pairs = explode("&", $str);
        foreach ($pairs as $pair) {
            list($k, $v) = array_map("urldecode", explode("=", trim($pair)));
            $op[$k] = $v;
        }
        return $op;
    }
    
    if (!isset($HTTP_RAW_POST_DATA))
    {
            $HTTP_RAW_POST_DATA = file_get_contents("php://input");
    }

    И это уже не в первый раз. А когда надо отправить форму, то php-шники делают это через raw socket.

    cottonzoom, 30 Июля 2014

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    jQuery(document).ready(function($) {
    	var url=document.location.href;
    	$.each($(".menu a"),function(){
    	if(this.href==url){$(this).addClass('activetopmenu');};
    	});
    	});

    И это при том, что для генерации страниц используется php...

    mkramer, 23 Июля 2014

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

    +154

    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
    /*
         * BANERS
         */
        $IMG="<div class=\"tovMain\" id=\"bnList1_imgBlock\"></div>
              <script type=\"text/javascript\">
                var bnList1_images=[";
        $banerId=$res->show1Var("s_rzd","page='".PAGE_BANER."'","id");
        $imgPreRes=$res->showTabAsPage("s_cnt","rzdId='".$banerId."' AND image>'' AND `show`='Y'","image","id",0);
        foreach($imgPreRes as $imgRes){
            $IMG.="'{ROOTPATH}images/".$imgRes["image"]."',";
        }
        $IMG=substr($IMG,0,-1);
        $IMG.="];
                var bnList1_old_image='';
                var bnList1_x=10;
                var bnList1_y=3;
                var bnList1_mercaniy=2;
                var bnList1_speed=500;
                var bnList1_speed1=800;
                var bnList1_w=Math.round(document.getElementById(\"bnList1_imgBlock\").offsetWidth/bnList1_x);
                var bnList1_h=Math.round(document.getElementById(\"bnList1_imgBlock\").offsetHeight/bnList1_y);
            
                var tek=0;
                bnList1Listing(bnList1_images[tek]);
                setInterval(\"tek=(bnList1_images.length>(tek+1)?tek+1:0);bnList1Listing(bnList1_images[tek]);\",5000);
                
                for(var i=1;i<=bnList1_x;i++){
                    for(var j=1;j<=bnList1_y;j++){
                        bnList1CreateBlocks(\"bnList1_block_\"+i+\"_\"+j+\"_1\",bnList1_w,bnList1_h,bnList1_w*(i-1),bnList1_h*(j-1));
                        bnList1CreateBlocks(\"bnList1_block_\"+i+\"_\"+j+\"_2\",bnList1_w,bnList1_h,bnList1_w*(i-1),bnList1_h*(j-1));
                    }
                }
            </script>";
        /*$rndBanerId=array_rand($imgPreRes);
        $img=$imgPreRes[$rndBanerId]["image"];
        $IMG="<div class=\"tovMain\" id=\"slideshow\">
                <img src=\"{ROOTPATH}images/empty.gif\" alt=\"\" />
                <img src=\"{ROOTPATH}img.php?image=".$img."&w=656&h=189\" alt=\"\" />
              </div>"; // Простая сквозная картинка
        //$HD_IMG="<div class=\"tovMain\">".($cntRes->hdImg())."</div>"; // Сменяющиеся картинки
         * s
         */
        $BANER=$cntRes->site_simpleStr(PAGE_BANER,"text");
            $content=str_replace("{BANER}",$BANER,$content);
            $content=str_replace("{IMG}",$IMG,$content);
        
        /*
         * IMAG
         */
        $TOVMAIN=$imagRes->showAsTovList("main");
            $content=str_replace("{TOVMAIN}",$TOVMAIN,$content);
        unset($TOVMAIN);
            
        /*
         * CONTENT
         */
        
        $NAV_ROW=$cntRes->site_nav();
        $STR=$cntRes->site_pageHd();
        $STR.=$cntRes->site_imagFilter();
        $STR.=$cntRes->site_cont();
        $SUB_STR=$cntRes->commonStr();
            $content=str_replace("{NAV_ROW}",$NAV_ROW,$content);
            $content=str_replace("{STR}",$STR,$content);
            $content=str_replace("{SUB_STR}",$SUB_STR,$content);
        unset($STR,$SUB_STR);
    
                $content=str_replace("{BACK}",BACK,$content);
                $content=str_replace("{UP}",UP,$content);
                $content=str_replace("{SEND}",SEND,$content);
                $content=str_replace("{FORM_SEND_ZAG}",FORM_SEND_ZAG,$content);
                $content=str_replace("{FORM_NAME}",FORM_NAME,$content);
                $content=str_replace("{FORM_POSTADDR}",FORM_POSTADDR,$content);
                $content=str_replace("{FORM_PHONE}",FORM_PHONE,$content);
                $content=str_replace("{FORM_EML}",FORM_EML,$content);
                $content=str_replace("{FORM_MSG}",FORM_MSG,$content);
                $content=str_replace("{FORM_SEND_SUCCESS}",FORM_SEND_SUCCESS,$content);
                $content=str_replace("{FORM_SEND_ERROR}",FORM_SEND_ERROR,$content);
                $content=str_replace("{REQUIRED_FIELDS}",REQUIRED_FIELDS,$content);
                $content=str_replace("{MAIN}",MAIN,$content);
      if(__lang=="en"){
        $content=str_replace("logo.png","logo_en.png",$content);
      }

    templates/default/template.php
    Знакомьтесь, "DEFAULT SITE TEMPLATE" (Кусок 2-й) ;)

    RuJack, 21 Июля 2014

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