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

    В номинации:
    За время:
  2. Куча / Говнокод #6546

    +68

    1. 1
    2. 2
    3. 3
    #KPACHblu {COLOR:#FF0000 !IMPORTANT;}
    #KPACHblu .CuHuu {COLOR:BLUE;COLOR:BLUE;COLOR:BLUE;COLOR:BLUE;COLOR:BLUE;}
    #KPACHblu .3EJlEHblu {COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;COLOR:GREEN;}

    stuffort, 04 Мая 2011

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

    +156

    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
    //было:
    	function query($sque){
    		$sque = mysql_real_escape_string($sque,$this->hdb);
    		$res = mysql_query($sque,$this->hdb);
    		if(!$res){
    			echo 'Invalid query: '.mysql_error().'; ';
    			return 0;
    		}
    		return $res;
    	}
    //добавил:
    //так как предыдущая функция иногда косячила запрос
    	function sensiblequery($sque,$arr){
    		for($i = 0; $i<count($arr); ++$i){
    			$arr[$i] = mysql_real_escape_string($arr[$i],$this->hdb);
    			$pattern = "/{var$i}/";
    			$sque = preg_replace($pattern, $arr[$i], $sque);	
    		}
    		$res = mysql_query($sque,$this->hdb);
    		if(!$res){
    			echo 'Invalid query: '.mysql_error().'; ';
    			return 0;
    		}
    		return $res;
    	}

    Такое ощущение что написал говно. Если это так подскажите как адекватней сделать...

    greshnik, 23 Апреля 2011

    Комментарии (24)
  4. bash / Говнокод #6457

    −139

    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
    #!/bin/bash
    
    export cpx=0
    export cpy=0
    cf=0
    export xf=0
    export yf=0
    while :
    do
      tput reset
      xp=`cat /tmp/X.txt`
      yp=`cat /tmp/Y.txt` 
    echo "xp $xp yp $yp"
    clear
    if [ $cpx -eq $xp ]
    then
      echo "x coincided"
      xf=1
    elif [ $cpx -gt $xp ]
    then
      let cpx--
    else
      let cpx++
    fi
    
    if [ $cpy -eq $yp ]
    then
      echo "y coincided"
      yf=1
    elif [ $cpy -gt $yp ]
    then
      let cpy--
    else
      let cpy++
    fi
    tput cup 45 130
    echo px $xp py $yp
    tput cup 46 130
    echo x $cpx y $cpy
    tput cup $cpx $cpy
    sleep 0.5s
    if [ $xf -eq 1 ]
    then
      if [ $yf -eq 1 ]
      then
        echo "Point coincide"
        exit
      fi
    fi
    done

    Move cursor in right place.

    AliceGoth, 22 Апреля 2011

    Комментарии (24)
  5. Куча / Говнокод #6326

    +127

    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
    '8, :.
                                                  `""`oooob."T,.
                                                ,-`".)O;8:doob.'-.
                                         ,..`'.'' -dP()d8O8Yo8:,..`,
                                       -o8b-     ,..)doOO8:':o; `Y8.`,
                                      ,..bo.,.....)OOO888o' :oO.  ".  `-.
                                    , "`"d....88OOOOO8O88o  :O8o;.    ;;,b
                                   ,dOOOOO""""""""O88888o:  :O88Oo.;:o888d
                                   ""888Ob...,-- :o88O88o:. :o'"""""""Y8OP
                                   d8888.....,.. :o8OO888:: ::
                                     ,dd8".  ,-)do8O8o:"""; :::
                                     -"",`(;O"KdOo::        :::
                                        .doo:::"""::  :.    'o:
            ,..            .;ooooooo..o:"""""     ::;. ::;.  'o.
       ,, "'    ` ..   .d;o:"""'                  ::o:;::o::  :;
       d,         , ..ooo::;                      ::oo:;::o"'.:o
      ,d'.       :OOOOO8Oo::" '.. .               ::o8Ooo:;  ;o:
      ,8:   o::oO` 88888OOo:::  o8O8Oo:::;;     ,;:oO88OOo;  '
     ,YP  , :;:O:  *888o::::  :8888Ooo::::::::::oo888888o;. ,
     dPY:  :o8O     (|)888O:O:;  O8888888888OOOO888"" Y8o:O88o; ,
    ,' O:  'ob`      "8888888Oo;;o8888888888888'"'     `8OO:.`OOb .
    '  Y:  ,:o:       `8O88888OOoo"""""""""""'           `OOob`Y8b`
       ::  ';o:        `8O88o:oOoP                       `8Oo `YO.
       `:   Oo:         `888O::oP                         88O  :OY
        :o; 8oP         :888o::P                          do:  8O:
       ,ooO:8O'       ,d8888o:O'                         dOo   ;:.
       ;O8odo'        88888O:o'                          do::  oo.:
     ''-'`"            d:O8oK  -hrr-                   dOOo'  :o":
                       `8O:;7b,.                       `"8'     Y:
                         `Oo; 8:.
                            Y8bod.

    Ву-гу-гу! Поне! Не забыли ещё?

    Govnocoder#0xFF, 12 Апреля 2011

    Комментарии (24)
  6. SQL / Говнокод #6234

    −864

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    SELECT COUNT(*) FROM apteka.cache_offers WHERE ORG_ID = '21963' AND `subject_id` IN (35,30052,20262,20263,20001,30488,30776,22099,22044,21982,21938,21823,
    (еще триста чисел),
    26313,26358,26478,23381,27430,26367,26418,23433,23404,23372,23289,23321,23285,23315,23282,23406,23287,
    26356,23429,23263,23349,23399,23356,23291,23346,23351,23250,23198,23194,23319,23238,23296,23259,23167,23268,23130,23052,23119,22430,23146,22315,23069,23083,23
    127,23189,23023,23014,23059,22988,23020,23007,22989,22949,22937,22939,22941,22979,22786,22842,22849,22758,22913,22919,22833,22718,22753,22779,22724,22857,2276
    8,22761,22733,22823,22759,22764,22658,22681,22674,22706,22599,22698,22667,22627,22776,22654,22655,22601,22619,22598,22694,22696,22603,22541,22570,22469,22534,
    22515,22676,22516,22477,22491,22677,22513,22421,22537,22451,22507,22482,22440,22353,22523,22422,22510,22397,22473,22348,22383,22424,22333,22380,22359,22508,22
    486,22456,22330);

    Стандартный запрос. При формировании страницы конструкция встречается многократно (>10 раз)

    deadwire, 05 Апреля 2011

    Комментарии (24)
  7. Си / Говнокод #5997

    +105

    1. 1
    int c = ((i-(i%(int)pow(10,p)))/(int)pow(10,p))%10;

    Выделение из числа I цифры, стоящей на месте P с конца.
    =>
    i = 1234, p = 2, c => 2

    danilissimus, 16 Марта 2011

    Комментарии (24)
  8. C# / Говнокод #5884

    +120

    1. 1
    2. 2
    3. 3
    4. 4
    string tmpS;
    //идут всякие монипуляции с этой строкой
    //. . .
    tmpS.Remove(0, tmpS.Length);

    Реальный код из коммерческого продукта.

    inser, 04 Марта 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?php
     $Options = file("OPTIONS.txt");
     foreach ($Options as $opt)
            {
            $opt = trim($opt);
            eval("$".$opt.";");
            }

    qbasic, 28 Февраля 2011

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

    +165

    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
    function get_sel_values(index){
                    var test = eval('typeof opt_val'+index);
                    if ( test != 'undefined' ){
                      eval('var sel_values = opt_val'+index);
                      return sel_values;
                    }
        else { return false; }
    }
    //**************************************************************
    function get_sel_text(index){
                    var test = eval('typeof opt_text'+index); 
                    if ( test != 'undefined' ){
                      eval('var sel_text = opt_text'+index);
                      return sel_text;
                    }
        else { return false; }              
    }
    //**************************************************************
    function show_select(index, lev, dv){
        if ( dv == 'jdc1'){ var tr = "jdc2";}
        if ( dv == 'jdc2'){ var tr = "jdc3";}
        if ( dv == 'jdc3'){ var tr = "jdc4";}
        var curr_sel_text = get_sel_text(index);
        var curr_sel_value = get_sel_values(index);
                    if ( curr_sel_value != false && curr_sel_text != false ){
          if ( dv == 'jdc1'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "hidden";
            document.getElementById('jdc3').style.visibility = "hidden";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc2'].length = 0;
                              document.forms["form1"].elements['cc3'].length = 0;
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          if ( dv == 'jdc2'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "visible";
            document.getElementById('jdc3').style.visibility = "hidden";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc3'].length = 0;
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          if ( dv == 'jdc3'){
            document.getElementById('jdc1').style.visibility = "visible";
            document.getElementById('jdc2').style.visibility = "visible";
            document.getElementById('jdc3').style.visibility = "visible";
            document.getElementById('jdc4').style.visibility = "hidden";
                              document.forms["form1"].elements['cc4'].length = 0;
                      }
          var count_values = curr_sel_value.length;
          var category_list = document.forms["form1"].elements[lev];
          var count_category_list = category_list.options.length;
          category_list.length = 0; 
          for (i = 0; i < count_values; i++){
            if (document.createElement){
                var newCategoryListOption = document.createElement("OPTION");
                newCategoryListOption.text = curr_sel_text[i];
                newCategoryListOption.value = curr_sel_value[i];
                (category_list.options.add) ? category_list.options.add(newCategoryListOption) : category_list.add(newCategoryListOption);
            }else{
                category_list.options[i] = new Option(curr_sel_text[i], curr_sel_value[i], false, false);
            }
          }
          document.getElementById(tr).style.visibility = "visible";
              }
                    else{
          document.getElementById(tr).style.visibility = "hidden";
                    }
      }
    //-->

    qbasic, 23 Февраля 2011

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

    +146

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    class GridPanel extends JPanel {
    
      protected Point myLocation;
    
      @Override
      public Point location() {
        return this.myLocation;
      }
    
      }

    убивал бы за такое.

    Lure Of Chaos, 07 Февраля 2011

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