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

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

    +137.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
    <div id="spoiler">
    <div>
    <p style="text-align: center;"><input style="margin: 10px; padding: 0px; width: 150px; font-size: 12px; background-color: #fdeaa8;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display = ''; this.parentNode.parentNode.getElementsByTagName('div')['hide'].style.display = 'none'; this.innerText = ''; this.value = 'Спрятать спойлер'; } else { this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display = 'none'; this.parentNode.parentNode.getElementsByTagName('div')['hide'].style.display = ''; this.innerText = ''; this.value = 'Еще раз показать?'; }" type="button" value="УП Элайя" /></p>
    
    <div>
    <div id="show" style="border-style: solid; border-width: 1px; margin: 0px; padding: 4px; display: none; background-color: transparent; width: 98%;">
    
    <span style="font-size: small;"><span style="color: #000000;">УП «Элайя» всегда готово к любому сотрудничеству и радует своих клиентов превосходным качеством и приемлемой ценой на женскую одежду. Для УП «Элайя» крайне важно поддерживать высокое качество производимой продукции. Предприятие использует только новейшее высокотехнологичное швейное оборудование производства Италии и Японии. </span></span>
    
    </div>
    <div id="spoiler">
    <div>
    <p style="text-align: center;"><input style="margin: 10px; padding: 0px; width: 150px; font-size: 12px; background-color: #fdeaa8;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display = ''; this.parentNode.parentNode.getElementsByTagName('div')['hide'].style.display = 'none'; this.innerText = ''; this.value = 'Спрятать спойлер'; } else { this.parentNode.parentNode.getElementsByTagName('div')['show'].style.display = 'none'; this.parentNode.parentNode.getElementsByTagName('div')['hide'].style.display = ''; this.innerText = ''; this.value = 'Еще раз показать?'; }" type="button" value="УП АссольМода" /></p>
    
    <div id="show" style="border-style: solid; border-width: 1px; margin: 0px; padding: 4px; display: none; background-color: transparent; width: 98%;">
    
    <span style="color: #000000;"><span style="font-size: small;">Компания "АссольМода" существует на рынке c 2003 года, и все это время уверенно и динамично развивается, расширяет круг постоянных клиентов, увеличиваем ассортимент выпускаемой продукции. </span></span>

    Доброго времени! Ребята, я в этом деле полный нуб. Ситуация тут следующая:
    Как видите здесь 2 спойлера. В Firefox'e пашут оба, в IE 8 не пашет верхняя, а в Google Chrome не пашет нижняя... Я заметил разницу в наличии у верхней одного тега <div> перед вот этими строками:
    <div id="show" style="border-style: solid; border-width: 1px; margin: 0px; padding: 4px; display: none; background-color: transparent; width: 98%;">
    И отсутствие этого тега у нижних таких же строк второй кнопки. Если я добавляю этот тег к нижней, то на странице наступает хаос, сайдбар, футер и шапка сразу разъезжаются, если убираю этот же тег из верхней опять-таки хаос. Не знаю че делать. Помогите пожалуйста найти ошибку. Спасибо.

    civko, 05 Февраля 2010

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

    −181.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    def explode(self,xx,y,t) :
                    #sometimes xx is -1. It's a bug we workaround here
                    if xx == -1 :
                            x = size_x - 1
                    else :
                            x = xx

    Нашел в одной игрушке, пытаясь найти и иправить досадный баг

    nexeuse, 01 Февраля 2010

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

    +153.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
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    function event_form_alter($form_id, &$form) {
      global $user;
    
      $node = isset($form['#node']) ? $form['#node'] : NULL;
    
      switch ($form_id) {
        // node settings form
        case 'node_type_form':
          $type = (isset($form['old_type']) && isset($form['old_type']['#value'])) ? $form['old_type']['#value'] : NULL;
          $form['workflow']['event_nodeapi'] = array(
            '#type' => 'radios',
            '#title' => t('Show in event calendar'),
            '#default_value' => variable_get('event_nodeapi_'. $type, 'never'),
            '#options' => array('all' => t('All views'), 'solo' => t('Only in views for this type'), 'never' => t('Never')),
            '#description' => t('All views: This content type will be available for display on all calendar views, including with other events.<br />Only in views for this type: This content type will only appear in calendar views specific to this type and never with other events.<br />Never: This content type will not be associated with the events calendar.')
          );
          break;
    #...
     }
    }

    vectoroc, 09 Января 2010

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

    +160.8

    1. 1
    2. 2
    3. 3
    //...
    if(preg_match("/[0-9]{1,2,3,4,5,6}/",$_GET['id'],$reg))
    //...

    регулярное 'выражение'

    xXx_totalwar, 07 Января 2010

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

    +157.7

    1. 1
    $has_url = ($categories->pageID>0 || strlen(trim($categories->caturl))>0) ? true : false;

    ryurik, 06 Января 2010

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

    +184.4

    1. 1
    $happy = new Year();

    C наступающим ;)

    miami, 31 Декабря 2009

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

    +67.4

    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
    // die elemente aufbauen
    // wasserstoff (gruppe 1, Nichtmetalle)
    Element* wasserstoff = new Element(this);
    wasserstoff->setObjectName("wasserstoff");
    wasserstoff->setze_element_namen(tr("Hydrogen"));
    wasserstoff->setze_atomzahl(1);
    wasserstoff->setze_symbol("H");
    wasserstoff->setze_masse("1,00794 u");
    wasserstoff->setze_exakte_masse("1.007825032");
    wasserstoff->setze_ionisation("13,5984 kJ/mol");
    wasserstoff->setze_elektronenaffinitaet("1.007825032");
    wasserstoff->setze_elektronen_negativitaet("2,2");
    wasserstoff->setze_kovalenter("37 pm");
    wasserstoff->setze_van_der_waals_radius("120 pm");
    wasserstoff->setze_schmelzpunkt("13.81");
    wasserstoff->setze_siedepunkt("20.28");
    wasserstoff->setze_familie(tr("nonmetal"));
    wasserstoff->setze_gruppenfarbe(gruppenfarben.at(1));
    wasserstoff->setze_entdeckungsjahr(1766);
    wasserstoff->setze_position(0, 1);
    elementliste.insert(wasserstoff->atomzahl(), wasserstoff);
    wasserstoff->registriere_agrgatzustandsfarben(agregatzustandsfarben);
    wasserstoff->fuege_elektronen_hinzu(1, 1);
    
    // helium (gruppe 18, Edelgase)
    Element* helium = new Element(this);
    helium->setObjectName("helium");
    helium->setze_element_namen(tr("Helium"));
    helium->setze_atomzahl(2);
    helium->setze_symbol("He");
    helium->setze_masse("4,0026 u");
    helium->setze_exakte_masse("4.002603254");
    helium->setze_ionisation("24,5874 kJ/mol");
    helium->setze_elektronenaffinitaet("4.002603254");
    helium->setze_elektronen_negativitaet("-1");
    helium->setze_kovalenter("32 pm");
    helium->setze_van_der_waals_radius("140 pm");
    helium->setze_schmelzpunkt("0.95");
    helium->setze_siedepunkt("4.216");
    helium->setze_familie(tr("noble gases"));
    helium->setze_gruppenfarbe(gruppenfarben.at(18));
    helium->setze_entdeckungsjahr(1868);
    helium->setze_position(17, 1);
    elementliste.insert(helium->atomzahl(), helium);
    helium->fuege_elektronen_hinzu(1, 2);
    
    // lithium (gruppe 1, Alkalimetalle)
    Element* lithium = new Element(this);
    
    
    ...
    
    
    // ununhexium (gruppe 16, Metalle)
    Element* ununhexium = new Element(this);
    ununhexium->setObjectName("ununhexium");
    ununhexium->setze_element_namen(tr("Ununhexium"));
    ununhexium->setze_atomzahl(116);
    ununhexium->setze_symbol("Uuh");
    ununhexium->setze_masse("292 u");
    ununhexium->setze_exakte_masse("292.19979");
    ununhexium->setze_ionisation("-1");
    ununhexium->setze_elektronenaffinitaet("292.19979");
    ununhexium->setze_elektronen_negativitaet("-1");
    ununhexium->setze_kovalenter("-1");
    ununhexium->setze_van_der_waals_radius("-1");
    ununhexium->setze_schmelzpunkt(QString::number(INT_MAX));
    ununhexium->setze_siedepunkt(QString::number(INT_MAX));
    ununhexium->setze_familie(tr("other metal"));
    ununhexium->setze_gruppenfarbe(gruppenfarben.at(16));
    ununhexium->setze_entdeckungsjahr(2000);
    ununhexium->setze_position(15, 7);
    elementliste.insert(ununhexium->atomzahl(), ununhexium);
    ununhexium->fuege_elektronen_hinzu(1, 2);
    ununhexium->fuege_elektronen_hinzu(2, 8);
    ununhexium->fuege_elektronen_hinzu(3, 18);
    ununhexium->fuege_elektronen_hinzu(4, 32);
    ununhexium->fuege_elektronen_hinzu(5, 32);
    ununhexium->fuege_elektronen_hinzu(6, 18);
    ununhexium->fuege_elektronen_hinzu(7, 6);
    
    ЗЫ: итого порядка 3000 строк кода

    http://sourceforge.net/projects/qperiodictable

    3dEyes**, 31 Декабря 2009

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

    −352.1

    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
    #!/usr/bin/perl
    while ($colresults = $rez->fetchrow_hashref()) {
    		$hour = $colresults->{'TIME'};
    		if ($hour == '00') {$value0 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '01') {$value1 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '02') {$value2 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '03') {$value3 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '04') {$value4 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '05') {$value5 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '06') {$value6 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '07') {$value7 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '08') {$value8 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '09') {$value9 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '10') {$value10 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '11') {$value11 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '12') {$value12 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '13') {$value13 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '14') {$value14 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '15') {$value15 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '16') {$value16 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '17') {$value17 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '18') {$value18 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '19') {$value19 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '20') {$value20 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '21') {$value21 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '22') {$value22 = $colresults->{'VALUE_NUM'}};
    		if ($hour == '23') {$value23 = $colresults->{'VALUE_NUM'}};
    	if ($d_name ne $colresults->{'DNAME'}) {
    		unless ($first) {
    			push @result, {
    				N => $n_name,
    				C => $c_name,
    				D => $d_name,
    				TIME0 => get_temp($value0),
    				TIME1 => get_temp($value1),
    				TIME2 => get_temp($value2),
    				TIME3 => get_temp($value3),
    				TIME4 => get_temp($value4),
    				TIME5 => get_temp($value5),
    				TIME6 => get_temp($value6),
    				TIME7 => get_temp($value7),
    				TIME8 => get_temp($value8),
    				TIME9 => get_temp($value9),
    				TIME10 => get_temp($value10),
    				TIME11 => get_temp($value11),
    				TIME12 => get_temp($value12),
    				TIME13 => get_temp($value13),
    				TIME14 => get_temp($value14),
    				TIME15 => get_temp($value15),
    				TIME16 => get_temp($value16),
    				TIME17 => get_temp($value17),
    				TIME18 => get_temp($value18),
    				TIME19 => get_temp($value19),
    				TIME20 => get_temp($value20),
    				TIME21 => get_temp($value21),
    				TIME22 => get_temp($value22),
    				TIME23 => get_temp($value23),
    			};
    			$value0 = undef;
    			$value1 = undef;
    			$value2 = undef;
    			$value3 = undef;
    			$value4 = undef;
    			$value5 = undef;
    			$value6 = undef;
    			$value7 = undef;
    			$value8 = undef;
    			$value9 = undef;
    			$value10 = undef;
    			$value11 = undef;
    			$value12 = undef;
    			$value13 = undef;
    			$value14 = undef;
    			$value15 = undef;
    			$value16 = undef;
    			$value17 = undef;
    			$value18 = undef;
    			$value19 = undef;
    			$value20 = undef;
    			$value21 = undef;
    			$value22 = undef;
    			$value23 = undef;
    		}
    		
    		...
    	}
    
    }
    .... # продолжение не менее захватывающее

    Феерический код из одной не малоизвестной организации :)

    SoulSeeker, 25 Декабря 2009

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

    +128.8

    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
    #define MAX_FILE_LENGHT PAGE_SIZE                                                
    #define TYPE(dev) ( MINOR(dev) >> 4)                                             
    #define NUM(dev)  ( MINOR(dev) & 0xf )                                           
    #define IRQ_NUM 1                                                                
    #define DEV_NAME "keyboard"                                                      
    #define MAX_DEV_COUNT 5                                                          
    #define PORT_START 0xff30                                                        
    int devno,err;
    int mj,min;   
    struct cdev *mydev;
    static char *devbuff;
    struct dev_state{               
    int dev_open;   
    ssize_t dev_read;
    ssize_t dev_write;
    };                
    int mydev_ioctl(struct inode *in,struct file *filp,unsigned int ioctl,unsigned long param);                                                                                                     
    int mydev_open(struct inode *in,struct file* filp);                                                                                                                                                                                                   
    ssize_t mydev_read(struct file *filp,char *buff,ssize_t len,loff_t pos);                                                                                                                        
    ssize_t mydev_write(struct file *filp, const char *buff, ssize_t len,loff_t pos);                                                                                                               
    loff_t mydev_llseek(struct file *filp,loff_t pos, int dist);                                                                                                                                    
    int mydev_close(struct inode *in , struct file *filp);                                                                                                                                          
    static struct dev_state STATE[MAX_DEV_COUNT+1];                                                                                                                               
    struct resource *my_res;                                                                                                                                                                        
    struct file_operations fop_s={
      .owner = THIS_MODULE,       
      .open = mydev_open,         
      .release = mydev_close,     
      .read = mydev_read,         
      .write = mydev_write,       
      .ioctl = mydev_ioctl,       
      .llseek = mydev_llseek,     
    };                            
    static int module3_init(void){                            
      mj=1;                      
      min=1;                     
      my_res->start=0xff30;      
      my_res->name="myres";      
      my_res->flags=IORESOURCE_IO | IORESOURCE_IO_FIXED;
      my_res->parent=NULL;                              
      my_res->sibling=NULL;                             
      my_res->child=NULL;                               
      struct resource *myres=request_region(200,300,"myreg");
      devbuff=(char*)vmalloc(MAX_FILE_LENGHT);               
      memset(devbuff,0x20,sizeof(devbuff));                  
      devno=MKDEV(mj,min);                                   
      mydev=cdev_alloc();                                    
      mydev->owner=THIS_MODULE;                                                              
      cdev_init(mydev,&fop_s);                               
      err=cdev_add(mydev,devno,1);                           
      if(err){                                                      
        printk(KERN_INFO"Invaid devno %d\n",devno);          
        return -EFAULT;                                      
      };                                                     
      printk(KERN_INFO"Device"DEV_NAME"was created\n");      
      return 0;                                              
    };

    Alice, 25 Декабря 2009

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

    −863.1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    FOR v_word IN 
            SELECT word FROM list                     
            AS word                              
        LOOP
        	UPDATE list SET pos=strpos(v_text, v_word) WHERE word=v_word;
        END LOOP;

    nomad, 23 Декабря 2009

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