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

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

    +163.2

    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
    $t_total_rows = 100;
    		$t_row_ids = array();
    
    		// Check total profile rows.
    		for($i = 1; $i <= $t_total_rows; $i++)
    		{
    				$result = $database -> database_query("SELECT `profilevalue_$i` FROM `se_profilevalues`");
    
    				if($result != FALSE)
    				{
    						$t_row_ids[] = $i;
    				}
    		}

    Нашел еще один кусок кода :)))
    Оригинальный подход для подсчета полей :))

    Rain, 16 Апреля 2010

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

    +107.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    DirectoryEntry en = this.InitDirectoryEntry(ADObject);
    
    try
    {                   
         en.Parent.Children.Remove(en);
    }
    catch (Exception ex)
    {
               //??????????????????????????????
    }

    Удаление объекта в каталоге Active Directory

    dens, 08 Апреля 2010

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

    +142.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    using System;
    
    
    unsafe struct program
    {
    	static void Main()
    	{
    		program obj1 = new program();
    		program* p = &obj1;
    		p->Main();
    	}
    }

    попытка обратиться к члену структуры

    sergylens, 08 Апреля 2010

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

    +144.4

    1. 1
    2. 2
    3. 3
    preview = {};
    preview = function () {/*code*/}
    preview.type1 = function () {/*code*/}

    Когда только начинал писать на JS, делал наследование именно так. =)

    fuckyounoob, 07 Апреля 2010

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

    +92.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    void Read_Ri( int hARINC,unsigned short int *Data ,int *i16,int *i15,int *i14,
    	int *i13,int *i12,int *i11,int *i10,int *i9,int *i8,int *i7,int *i6,int *i5,int *i4,int *i3,int *i2,int *i1)
    {
    		ioctl(hARINC,IOCTL_GET_RI,Data);
       		*i16=Data[0x1104]>>15&1; *i15=Data[0x1104]>>14&1; *i14=Data[0x1104]>>13&1;
    		*i13=Data[0x1104]>>12&1; *i12=Data[0x1104]>>11&1; *i11=Data[0x1104]>>10&1;
    		*i10=Data[0x1104]>>9&1; *i9=Data[0x1104]>>8&1; *i8=Data[0x1104]>>7&1;
    		*i7=Data[0x1104]>>6&1; *i6=Data[0x1104]>>5&1; *i5=Data[0x1104]>>4&1;
    		*i4=Data[0x1104]>>3&1; *i3=Data[0x1104]>>2&1; *i2=Data[0x1104]>>1&1; *i1=Data[0x1104]&1;
    }

    Фирма "Элкус" порадовала. Хорошо, что у их платы не 32-разрядные регистры :)

    whiskey, 05 Апреля 2010

    Комментарии (6)
  7. Pascal / Говнокод #2903

    +143.6

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    for i:=1 to 10000000 do
    begin
    {...}
    if m=0 then break;
    end;

    kozzztya, 31 Марта 2010

    Комментарии (6)
  8. Куча / Говнокод #2833

    +144.6

    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
    program stroki;
    
    uses
      crt;
    
    var
      S, ns: string[80];
      t, f, f1, kc, ks, d, i: byte;
    
    const
      n = '1234567890';
      a = 'abcdefghijklmnopqrstuvwxyz';
    
    begin
      kc := 0;
      ks := 0;
      
      clrscr;
      read(S);
      d := length(S);
      for i := 1 to d do
     begin
        t := pos(S[i], n);
        if t > 0 then
        begin
          ns := ns + S[i];
          f := 1;
        end
        else 
        begin
          if f = 1 then
            kc := kc + 1;
          f := 0;
          delete(ns, 1, length(ns));
        end
        end;
     
      
      f := 0;
      delete(ns, 1, length(ns));
      for i := 1 to d do
      begin
        t := pos(S[i], a);
        if t > 0 then
        begin
          ns := ns + S[i];
          f := 1;
        end
        else
        begin
          if f = 1 then
            ks := ks + 1;
          f := 0;
          delete(ns, 1, length(ns));
        end
      end;
      if (kc = 0) and (ks = 0) then
      begin
        clrscr;
        write('no symbols and digets');
        readkey;
      end; 
      if kc > ks then
      begin
        clrscr;
        write('a lot of digets');
        readkey;  
      end
      else
      begin
        clrscr;
        write('a lot of symbols');
        readkey;
      end;
      if kc = ks then
      begin
        clrscr;
        write('они равны');
        readkey;
      end
      
      
      
    end.

    Funkie444, 21 Марта 2010

    Комментарии (6)
  9. bash / Говнокод #2827

    −131

    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
    #! /bin/bash
    
    # файл имоты или коначана
    srcfile=$1
    # файл санкаки или данборы
    dubfile=$2
    echo Lines:
    echo -n Before:
    wc -l $dubfile
    a=`pcregrep -o -e '[a-f0-9]{32}' $srcfile|head -n 1`
    for i in `pcregrep -o -e '[a-f0-9]{32}' $srcfile`
    do
    a=$a\|$i
    done;
    cat $dubfile|grep -v -E -e $a > out.$dubfile
    echo -n After:
    wc -l out.$dubfile

    Поиск дублей

    Radjah, 19 Марта 2010

    Комментарии (6)
  10. Java / Говнокод #2817

    +75

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    private static byte[] getByteArrayFromInt(int number) {
    	ByteArrayOutputStream out = new ByteArrayOutputStream();
    	DataOutputStream o = new DataOutputStream(out);
    	try {
    		o.writeInt(number);
    	} catch (IOException e) {
    		e.printStackTrace();
    	}
    	return out.toByteArray();
    }

    Интересный способ переводить Int в массив байт )

    Logarithm, 18 Марта 2010

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

    +159.7

    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
    $q = "SELECT product_id FROM jos_vm_product WHERE product_parent_id=$prodid";
        $res = mysql_query($q);
        if(!$res) die('Error 3: ' . mysql_error());
        
        $td_str=' ';
        $pos_atrribs=array();
        $row=0;
        $sort_by=0;
        $subrows=0;
        $show_cells=0;
        
        while($pos=mysql_fetch_array($res))
        {
          $posid=$pos['product_id'];
          $q1 = "SELECT attribute_value,attribute_name  FROM jos_vm_product_attribute WHERE product_id=$posid ORDER BY attribute_name DESC";
          $res1 = mysql_query($q1);
          if(!$res1) die('Error 4: ' . mysql_error());
          
          $col=0;
          while($posattrib=mysql_fetch_array($res1))
          {
            if($posattrib['attribute_name']=='Код фитинга' || $posattrib['attribute_name']=='Код' || $posattrib['attribute_name']=='Кодфитинга' || $posattrib['attribute_name']=='Ordering code')
            {
              $sort_by=$posattrib['attribute_name'];
            }
            $pos_atrribs[$row][$posattrib['attribute_name']]=$posattrib['attribute_value'];
            $col++;
          }
          
          $q1 = "SELECT product_in_stock FROM jos_vm_product WHERE product_id=$posid";
          $res1 = mysql_query($q1);
          if(!$res1) die('Error 4: ' . mysql_error());
          $stock=mysql_fetch_array($res1);
          
          $pos_atrribs[$row]['Склад']=$stock['product_in_stock'];
          
          $q1 = "SELECT product_price FROM jos_vm_product_price WHERE product_id=$posid";
          $res1 = mysql_query($q1);
          if(!$res1) die('Error 4: ' . mysql_error());
          $price=mysql_fetch_array($res1);
          
          $pos_atrribs[$row]['Цена EUR']=$price['product_price'];
          $pos_atrribs[$row]['posid']=$posid;
          $row++;
        }
    
    function columnSort($sorted, $column) {
            for ($i=0; $i < sizeof($sorted)-1; $i++) 
            {
              for ($j=0; $j<sizeof($sorted)-1-$i; $j++)
                if ($sorted[$j][$column] > $sorted[$j+1][$column]) 
                {
                  $tmp = $sorted[$j];
                  $sorted[$j] = $sorted[$j+1];
                  $sorted[$j+1] = $tmp;
              }
            }
            return $sorted;
        }    
        $sorted = columnSort($pos_atrribs, $sort_by);
        unset($pos_atrribs);
        
        $new_attribs=array();
        $num=0;
        $matches=0;
        for ($i=0; $i < sizeof($sorted); $i++) 
        {
          if(substr($sorted[$i][$sort_by],-2)!='.1' && substr($sorted[$i][$sort_by],-2)!='.4')
          {
            $fs=(int)substr($sorted[$i][$sort_by],0,3);
            $fe=(int)substr($sorted[$i][$sort_by],-3);
            
            for ($j=0; $j<sizeof($sorted); $j++)
            { 
              $ss=(int)substr($sorted[$j][$sort_by],0,3);
              $se=(int)substr($sorted[$j][$sort_by],-3);
              
              if ($fe==$se && $fs<$ss) 
              {
                $new_attribs[$num]=array($sorted[$i],$sorted[$j]);
                $num++;
                $matches++;
              }
            }
          }
        }

    Джомло проект, в ходе запросов(11-46 строки) получает 250+ запросов к БД, и время выполнения только этого куска 40+ секунд. Далее сортировка тоже не слабая.

    kein, 11 Марта 2010

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