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

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

    −112.9

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    NSString *s_diskUsage = [NSString localizedStringWithFormat:@"Unavailable"];;
    float f_vaultUsage = 0;
      
    if (inData == NULL || inData.loggedIn != 0)
    {
        [s_diskUsage release];
        s_diskUsage = [NSString localizedStringWithFormat:@"Unavailable"];
        f_vaultUsage = (float)0;
    }

    Продолжение эпопеи с проектом на Objective-C. Я не знаю, может это стандарт кодирования такой, когда нужно как можно чаще переинициализировать переменные одними и теми же значениями... на случай если им надоест и они самоуничтожатся...

    Highlander, 13 Февраля 2010

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

    +77.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
    /**
     * todo не самый лучший способ обработки завершения диалогов
     * 
     * @author roman
     */
    public final class MyBoolean
    {
        private boolean value = false;
        public boolean getValue()
        {
            return value;
        }
        public void setValue(
            boolean value )
        {
            this.value = value;
        }
    }

    ctepx, 09 Февраля 2010

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

    +144.2

    1. 1
    2. 2
    $yii=dirname(__FILE__).'/protected/yii/framework/yiilite.php';
        //$yii=dirname(__FILE__).'/protected/yii/framework/yiilite.php';

    user654321, 05 Февраля 2010

    Комментарии (6)
  5. Куча / Говнокод #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)
  6. 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)
  7. 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)
  8. 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)
  9. PHP / Говнокод #2376

    +157.7

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

    ryurik, 06 Января 2010

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

    +184.4

    1. 1
    $happy = new Year();

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

    miami, 31 Декабря 2009

    Комментарии (6)
  11. 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)