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

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

    −122

    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
    var daytoday:String;
    var today = new Date();
    var monthtoday;
    var year = today.getFullYear(); 
    var timer:Timer = new Timer(1000);
    timer.addEventListener(TimerEvent.TIMER, clock);
    timer.start();
    function clock(e:TimerEvent):void {
       var datetoday:Date=new Date();
       switch (datetoday.day) {
           case 0:
           daytoday="ВОСКРЕСЕНЬЕ";
           break;
           case 1:
           daytoday="ПОНЕДЕЛЬНИК";
           break;
           case 2:
           daytoday="ВТОРНИК";
           break;
           case 3:
           daytoday="СРЕДА";
           break;
           case 4:
           daytoday="ЧЕТВЕРГ";
           break;
           case 5:
           daytoday="ПЯТНИЦА";
           break;
           case 6:
           daytoday="СУББОТА";
           break;
       }
       дэй_оф_вик.text=String(daytoday);
     
       switch (datetoday.month) {
           case 0:
           monthtoday="Января";
           break;
           case 1:
           monthtoday="Февраля";
           break;
           case 2:
           monthtoday="Марта";
           break;
           case 3:
           monthtoday="Апреля";
           break;
           case 4:
           monthtoday="Мая";  
           break;  
           case 5:  
           monthtoday="Июня";
           break;
           case 6:
           monthtoday="Июля";
           break;
           case 7:
           monthtoday="Августа";
           break;
           case 8:
           monthtoday="Сентября";
           break;
           case 9:
           monthtoday="Октября";
           break;
           case 10:
           monthtoday="Ноября";
           break;
           case 11:
           monthtoday="Декабря";
           break;
       }
       month.text=String(monthtoday);  
       day.text=String(datetoday.date);
       data_txt.text = year;
    }

    Мне больше всего нравится 33 строка...

    kyzi007, 18 Марта 2012

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

    +994

    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
    int main()
    {   
       //выводит на экран среднее арифметическое чисел 1, 3, 5
       std::cout << Mean + 1 + 3 + 5 << std::endl;
       //выводит на экран среднее геометрическое чисел 2, 4, 8
       std::cout << Mean * 2 * 4 * 8 << std::endl;
    }
    
    //реализация
    
    class CMean
    {
       mutable double out;
       mutable size_t cnt;
       mutable size_t type;
    public:
       CMean(): out(0), cnt(0), type(-1)  {}
       CMean& operator + (double n)
       {
          return type = 0, out+= n, ++cnt, *this;   
       }
       CMean& operator * (double n)
       {   
          return (type == (size_t)-1 ? type = 1, out = 1 : 0), out*= n, ++cnt, *this;   
       }
       size_t reset() const {return type = -1, out = cnt = 0;};
       friend std::ostream& operator << (std::ostream&, const CMean&);   
    } Mean;
    
    std::ostream& operator << (std::ostream& _os, const CMean& _arith)
    {
       return _os << (!_arith.type ? _arith.out / _arith.cnt : std::pow(_arith.out, 1.0 / _arith.cnt)) + _arith.reset();
    }

    Вывод на экран арифметической и геометрической прогрессии.

    gooseim, 15 Марта 2012

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

    +78

    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
    Drawable d = getResources().getDrawable(R.drawable.screen_width);
            int width = d.getMinimumWidth();
            switch (width) {
                case 1024:
                    CAMERA_WIDTH = 1024;
                    CAMERA_HEIGHT = 600;
                    break;
                case 800:
                    CAMERA_WIDTH = 800;
                    CAMERA_HEIGHT = 480;
                    break;
                case 480:
                    CAMERA_WIDTH = 480;
                    CAMERA_HEIGHT = 320;
                    break;
                case 320:
                    CAMERA_WIDTH = 320;
                    CAMERA_HEIGHT = 240;
                    break;
                default:
                    CAMERA_WIDTH = 800;
                    CAMERA_HEIGHT = 480;
                    break;
            }

    Вот так автор определял размер экрана в Android...по размеру загруженной картинки в ресурсах
    Про getResources().getConfiguration().screen Layout наверное он не знал...

    TeknoMatik, 05 Марта 2012

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

    +997

    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
    static std::string printFloatNumber(float num,bool friendly=false)
    {
    	std::ostringstream out ;
    
    	if(friendly)
    	{
    		char tmp[100] ;
    		std::string units[4] = { "B/s","KB/s","MB/s","GB/s" } ;
    
    		int k=0 ;
    		while(num >= 800.0f && k<5)
    			num /= 1024.0f,++k;
    
    		sprintf(tmp,"%3.2f %s",num,units[k].c_str()) ;
    		return std::string(tmp) ;
    	}
    	else
    	{
    		out << num ;
    		return out.str() ;
    	}
    }

    Исходники RetroShare - это просто шедевр!

    rat4, 04 Марта 2012

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

    +121

    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
    case 64:
    						{
    							this.RA.Value = this.memory.getValue(this.CCR.Value);
    							HideRegister expr_555 = this.CCR;
    							expr_555.Value += 1;
    							break;
    						}
    					case 65:
    						{
    							this.RB.Value = this.memory.getValue(this.CCR.Value);
    							HideRegister expr_58F = this.CCR;
    							expr_58F.Value += 1;
    							break;
    						}
    					case 66:
    						{
    							this.RC.Value = this.memory.getValue(this.CCR.Value);
    							HideRegister expr_5C9 = this.CCR;
    							expr_5C9.Value += 1;
    							break;
    						}
    					case 67:
    						{
    							this.RD.Value = this.memory.getValue(this.CCR.Value);
    							HideRegister expr_603 = this.CCR;
    							expr_603.Value += 1;
    							break;
    						}
    					default:
    						if (command != 129)
    						{
    							switch (command)
    							{
    							case 192:
    								if (this.getBit(this.FR.Value, 0))
    								{
    									this.CCR.Value = this.memory.getValue(this.CCR.Value);
    								}
    								else
    								{
    									HideRegister expr_67C = this.CCR;
    									expr_67C.Value += 1;
    								}
    								break;
    							case 193:
    								if (!this.getBit(this.FR.Value, 0))
    								{
    									this.CCR.Value = this.memory.getValue(this.CCR.Value);
    								}
    								else
    								{
    									HideRegister expr_6CF = this.CCR;
    									expr_6CF.Value += 1;
    								}
    								break;
    							case 194:
    								if (this.getBit(this.FR.Value, 1))
    								{
    									this.CCR.Value = this.memory.getValue(this.CCR.Value);
    								}
    								else
    								{
    									HideRegister expr_71F = this.CCR;
    									expr_71F.Value += 1;
    								}
    								break;
    							case 195:
    								if (!this.getBit(this.FR.Value, 1))
    								{
    									this.CCR.Value = this.memory.getValue(this.CCR.Value);
    								}
    								else
    								{
    									HideRegister expr_76C = this.CCR;
    									expr_76C.Value += 1;
    								}
    								break;
    							}
    						}
    						else
    						{
    							this.CCR.Value = this.memory.getValue(this.CCR.Value);
    						}
    						break;
    					}
    				}
    			}
    			this.FR.Value = value;
    		}

    Элсы,свечи,ифы и просто хороший код №3
    (продолжение следует)
    годная реализация того что можно было написать в 10 строчек

    budlokoder_steb_dm, 03 Марта 2012

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

    +162

    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
    function include_wp_head($src)
    {
        $paths = array(
            ".",
            "..",
            "../..",
            "../../..",
            "../../../..",
            "../../../../..",
            "../../../../../..",
            "../../../../../../.."
        );
       
        foreach ($paths as $path) {
            if(file_exists($path . '/' . $src)) {
                return $path . '/' . $src;
            }
        }
    }

    WordPress Form Manager

    ddavydov, 01 Марта 2012

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

    +159

    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
    <?
    $a = array("second","third","first");
    usort($a,"tes");
    function tes($c, $d, $data){
    if ($c == "third" && $d == "second") return -1;
    if ($c == "third" && $d == "first") return -1;
    if ($c == "first" && $d == "second") return 1;
    if ($c == "second" && $d == "third") return 1;
    if ($c == "first" && $d == "third") return 1;
    if ($c==$d==$data) return 0;
    }
    print_r($a);
    ?>

    В тестах задание, сортировать $a до вида ([1]=>"third",[2]=>"second",[3]=>"first").
    Один из вариантов ответа(остальные ответы аналогичны, отличаются синтаксисом).

    truedizzy, 21 Февраля 2012

    Комментарии (11)
  9. Java / Говнокод #9489

    +86

    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
    @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
    
            Sdbankpd sdbankpd = (Sdbankpd) o;
    
            if (bjbank != null ? !bjbank.equals(sdbankpd.bjbank) : sdbankpd.bjbank != null) return false;
            if (bjbvpd != null ? !bjbvpd.equals(sdbankpd.bjbvpd) : sdbankpd.bjbvpd != null) return false;
            if (bjcncd != null ? !bjcncd.equals(sdbankpd.bjcncd) : sdbankpd.bjcncd != null) return false;
            if (bjcust != null ? !bjcust.equals(sdbankpd.bjcust) : sdbankpd.bjcust != null) return false;
            if (bjcycd != null ? !bjcycd.equals(sdbankpd.bjcycd) : sdbankpd.bjcycd != null) return false;
            if (bjdfin != null ? !bjdfin.equals(sdbankpd.bjdfin) : sdbankpd.bjdfin != null) return false;
            if (bjdnwd != null ? !bjdnwd.equals(sdbankpd.bjdnwd) : sdbankpd.bjdnwd != null) return false;
            if (bjefmt != null ? !bjefmt.equals(sdbankpd.bjefmt) : sdbankpd.bjefmt != null) return false;
            if (bjeyd != null ? !bjeyd.equals(sdbankpd.bjeyd) : sdbankpd.bjeyd != null) return false;
            if (bjhocy != null ? !bjhocy.equals(sdbankpd.bjhocy) : sdbankpd.bjhocy != null) return false;
            if (bjlccy != null ? !bjlccy.equals(sdbankpd.bjlccy) : sdbankpd.bjlccy != null) return false;
            if (bjlcd != null ? !bjlcd.equals(sdbankpd.bjlcd) : sdbankpd.bjlcd != null) return false;
            if (bjmdel != null ? !bjmdel.equals(sdbankpd.bjmdel) : sdbankpd.bjmdel != null) return false;
            if (bjmodt != null ? !bjmodt.equals(sdbankpd.bjmodt) : sdbankpd.bjmodt != null) return false;
            if (bjmrdt != null ? !bjmrdt.equals(sdbankpd.bjmrdt) : sdbankpd.bjmrdt != null) return false;
            if (bjpcfq != null ? !bjpcfq.equals(sdbankpd.bjpcfq) : sdbankpd.bjpcfq != null) return false;
            if (bjpcfu != null ? !bjpcfu.equals(sdbankpd.bjpcfu) : sdbankpd.bjpcfu != null) return false;
            if (bjpeyd != null ? !bjpeyd.equals(sdbankpd.bjpeyd) : sdbankpd.bjpeyd != null) return false;
            if (bjrdnb != null ? !bjrdnb.equals(sdbankpd.bjrdnb) : sdbankpd.bjrdnb != null) return false;
            if (bjsbrc != null ? !bjsbrc.equals(sdbankpd.bjsbrc) : sdbankpd.bjsbrc != null) return false;
            if (bjslcd != null ? !bjslcd.equals(sdbankpd.bjslcd) : sdbankpd.bjslcd != null) return false;
            if (bjsuc != null ? !bjsuc.equals(sdbankpd.bjsuc) : sdbankpd.bjsuc != null) return false;
            if (bjtylc != null ? !bjtylc.equals(sdbankpd.bjtylc) : sdbankpd.bjtylc != null) return false;
            if (bjurpt != null ? !bjurpt.equals(sdbankpd.bjurpt) : sdbankpd.bjurpt != null) return false;
            if (bjzone != null ? !bjzone.equals(sdbankpd.bjzone) : sdbankpd.bjzone != null) return false;
    
            return true;
        }

    Обработка резальтов селекта

    timmson666, 20 Февраля 2012

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

    +163

    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
    var img = new Array(6);
    			img[0]="for_index.jpg";
    			img[1]="img1.jpg";
    			img[2]="img2.jpg";
    			img[3]="img3.jpg";
    			img[4]="img4.jpg";
    			img[5]="img5.jpg";
    			img[6]="img6.jpg";
    			img[7]="img7.jpg";
    			img[8]="img7.1.jpg";
    			img[9]="img7.2.jpg";
    			img[10]="img7_.jpg";
    			img[11]="img8.jpg";
    			img[12]="img9.jpg";
    			img[13]="img9.1.jpg";
    			img[14]="img9.2.jpg";
    			img[15]="img9.3.jpg";
    			img[16]="img9.4.jpg";
    			img[17]="img9.5.jpg";
    			img[18]="img9.6.jpg";
    			img[19]="img9.7.jpg";
    			img[20]="img9.8.jpg";
    			img[21]="img9.9.jpg";
    			img[22]="img9.10.jpg";
    			img[23]="img9.11.jpg";
    			img[24]="img9.12.jpg";
    			img[25]="img10.jpg";
    			img[26]="img10.1.jpg";
    			img[27]="img11.jpg";
    			img[28]="img11.3.jpg";
    			img[29]="img11.4.jpg";
    			img[30]="img11.5.jpg";
    			img[31]="img11.6.jpg";
    			img[32]="img12.jpg";
    			img[33]="img12.5.jpg";
    			img[34]="img12.6.jpg";
    			img[35]="img12.7.jpg";
    			img[36]="img12.8.jpg";
    			img[37]="img12.9.jpg";
    			img[38]="img12.10.jpg";
    			img[39]="img12.11.jpg";
    			img[40]="img12.12.jpg";
    			img[41]="img13.jpg";
    			img[42]="img14.jpg";
    			img[43]="img14.1.jpg";
    			img[44]="img14.2.jpg";
    			img[45]="img14.3.jpg";
    			img[46]="img14.4.jpg";
    			img[47]="img14.5.jpg";
    			img[48]="img14.6.jpg";
    			img[49]="img15.jpg";
    			img[50]="img15.1.jpg";
    			img[51]="img15.2.jpg";
    			img[52]="img15.3.jpg";
    			img[53]="img15.5.jpg";
    			img[54]="img16.jpg";
    			img[55]="img16.1.jpg";
    			img[56]="img16.3.jpg";
    			img[57]="img16.4.jpg";
    			img[58]="img16.5.jpg";
    			var currentImage=0;
    			function next() {
    				currentImage++;
    				if (currentImage == img.length){
    					currentImage=0;
    				};
    				document.getElementById("pic").src="images/photos/elka2009/big/"+img[currentImage];
    			}
    			function prev() {
    				currentImage--;
    				if (currentImage == -1){
    					currentImage=img.length-1;
    				};
    				document.getElementById("pic").src="images/photos/elka2009/big/"+img[currentImage];
    			}

    madfriend, 16 Февраля 2012

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    $(".left_links li ul li.current_menu_item").parent().show();
    	$(".left_links li ul li ul li.current_menu_item").parent().parent().parent().show();
    	$(".left_links li ul li ul li ul li.current_menu_item").parent().parent().parent().parent().parent().show();
    	$(".left_links li ul li ul li ul li.current_menu_item").parent().parent().parent().parent().parent().parent().parent().show();

    Боковое меню с 5 уровней. Чудо задача показать выбранный пользователем пункт этого меню . Глупейший способ js представлен выше.

    Doodlez, 13 Февраля 2012

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