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

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

    −859

    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
    "SELECT c.type AS type, 
                                      ELT(c.type, g.genre_id, l.label_id, f.film_id, a.actor_id, s.show_id, ch.channel_id,aw.award_id) AS id,
    				  ELT(c.type, g.value, l.value, f.real_name, a.real_name, s.real_name, ch.name, aw.description) AS real_name,
    				  ELT(c.type, NULL, NULL, f.name, a.name, s.name, NULL, NULL) AS name
    				  FROM connector AS c
    				  LEFT JOIN genres AS g ON (c.second = g.genre_id)
                                      LEFT JOIN labels AS l ON (c.second = l.label_id)
                                      LEFT JOIN films AS f ON (c.second = f.film_id)
                                      LEFT JOIN actors AS a ON (c.second = a.actor_id)
                                      LEFT JOIN shows AS s ON (c.second = s.show_id)
                                      LEFT JOIN channels AS ch ON (c.second = ch.channel_id)
                                      LEFT JOIN awards AS aw ON (c.second = aw.award_id)
                                      WHERE c.first = ".$_SESSION['user_id']

    Вот как это делается!

    Elfet, 14 Января 2011

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

    +145

    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
    public String readMessage(String subject) throws Exception {
        String messageString = null;
        try {
          for (final Message message : Arrays.asList(this.inbox.getMessages())) {
            if (subject.equals(message.getSubject())) {
              messageString = "To: " + Arrays.asList(message.getAllRecipients()) + "n" + "From: " + Arrays.asList(message.getFrom()) + "n" + "Sent: "
                + message.getSentDate() + "n" + "Subject: " + message.getSubject() + "n" + "Text: " + message.getContent();
              break;
            }
          }
        } catch (final MessagingException me) {
          throw new Exception("Error reading Inbox", me);
        } catch (final IOException e) {/* Not using streams, only plain text */
        }
        return messageString;
      }

    тестовый javamail клиент(отправка тест-письма,поиск его и удаление). В методе ищем письмо с нужной темой, возвращаем текстовое представление.

    говно, кроме очевидных ляпов, в том, что мы лазием по всем сообщениям, сверяя тему, а получение письма занимает около секунды. Надо ли говорить, что в современном ящике писем тысячи...
    для сравнения:
    если заменить в 4 строчке конструкцию

    Arrays.asList(this.inbox.getMessages())
    на
    new SubjectTerm(subject)
    , то время выполнения сокращается с (неизвестно,точно более времени чаепития) до пары секунд = )

    Lure Of Chaos, 14 Января 2011

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

    +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
    public IQueryable<AuditEntry> ViewAudit()
    {
    	var items = _operationEntities.AuditItems.AsQueryable();
    
    	return items.Select((item) => new AuditEntry()
    	{
    		OperationID = item.Id,
    		CreationTime = item.CreationTime,
             
    		Description = item.AuditItemType.StringFormat.Replace(
    			"{0}", item.InsertionStrings.Where((x) => x.StringId == 0).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{1}", item.InsertionStrings.Where((x) => x.StringId == 1).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{2}", item.InsertionStrings.Where((x) => x.StringId == 2).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{3}", item.InsertionStrings.Where((x) => x.StringId == 3).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{4}", item.InsertionStrings.Where((x) => x.StringId == 4).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{5}", item.InsertionStrings.Where((x) => x.StringId == 5).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{6}", item.InsertionStrings.Where((x) => x.StringId == 6).Select((x) => x.String).FirstOrDefault() ?? String.Empty).Replace(
    			"{7}", item.InsertionStrings.Where((x) => x.StringId == 7).Select((x) => x.String).FirstOrDefault() ?? String.Empty),
                    
    		CreatedBy = item.CreatedBy,
    		OperationType = item.AuditItemType.MessageType.Name,
    		OperationCategory = item.AuditItemType.AuditCategory.Name,
    	});
    }

    Паровозик. Реализация string.Format() в виде linq-запроса

    _volt, 13 Января 2011

    Комментарии (2)
  5. Python / Говнокод #5253

    −97

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    import string
    k=input()
    a=range(1000)
    if k==1:
            a[0]=input()
    else:
            t = string.replace(str(raw_input()), ' ', ', ')
            a=eval('('+t+')')

    4
    2 3 4 5
    ----
    Не знаю я питон :(
    По другому не смог быстро написать..

    Tanger, 13 Января 2011

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

    −116

    1. 1
    2. 2
    3. 3
    4. 4
    $answer=~ s/\\/\\\\/g;                                                                                                                                                      
    $answer=~ s/\'/\\\'/g;
    # ...
    $dbh->do("INSERT INTO docflow_rules (type_,state1,state2,p,entity,subj_require,comm_require) VALUES ($doctype,$from_,$to_,'$answer',$entity,$subj_r,$comm_r)");

    Еще от неизменного автора.

    SanityIO, 12 Января 2011

    Комментарии (2)
  7. Perl / Говнокод #5230

    −118

    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
    if(
        ( $session_begin ge $tariff_ref->{date} ) &&
        ( !$tariff_ref->{date_end} || $session_begin le $tariff_ref->{date_end} ) &&
        ( !$tariff_ref->{nas_id} || $tariff_ref->{nas_id} eq $nas_id) &&
        ( !$tariff_ref->{ppp_type} || $tariff_ref->{ppp_type} eq $ppp_type) &&
        ( $notariffzone || !$tariff_ref->{tariff_zone} ||
                        $tariff_ref->{tariff_zone} eq $tariff_zone) &&
        ( !$tariff_ref->{client_type} || $tariff_ref->{client_type} eq $client_type) &&
        ( !$tariff_ref->{day_type} || $tariff_ref->{day_type} eq
                        &common::type_of_day($oper_id,$session_begin) ) &&
    
        (
                (!$divide_by_time_zone &&
                        (!$tariff_ref->{time_from} || !$tariff_ref->{time_to}  ||
                                &common::check_time_zone(
                                $session_begin,
                                $tariff_ref->{time_from},
                                $tariff_ref->{time_to}
                                )
                        )
                ) ||
                ($divide_by_time_zone &&
                        (!$tariff_ref->{time_from} || !$tariff_ref->{time_to}  ||
    
                                &common::check_time_zone(
                                $session_begin,
                                $tariff_ref->{time_from},
                                $tariff_ref->{time_to}
                                ) ||
    
                                &common::check_time_zone(
                                $session_end,
                                $tariff_ref->{time_from},
                                $tariff_ref->{time_to}
                                ) ||
    
                                &common::check_time_zone(
                                $tariff_ref->{time_from},
                                common::get_time_from_str($session_begin),
                                common::get_time_from_str($session_end),
                                )
                        )
    
    
                    )
        ) &&
    
        (
                (!$divide_by_counter &&
                        (!defined($tariff_ref->{counter1_from}) || !defined($tariff_ref->{counter1_to})
    
                                || ($tariff_ref->{counter1_from} <= $resource_begin &&
                                $resource_begin < $tariff_ref->{counter1_to} )
                        )
                ) ||
                ($divide_by_counter &&
                            (!defined($tariff_ref->{counter1_from}) || !defined($tariff_ref->{counter1_to})
                                || ($tariff_ref->{counter1_from} <= $resource_begin &&
                                $resource_begin < $tariff_ref->{counter1_to} )
    
                                || ($tariff_ref->{counter1_from} <= $resource_end  &&
                                $resource_end < $tariff_ref->{counter1_to} )
    
                                || ($resource_begin <= $tariff_ref->{counter1_from} &&
                                $tariff_ref->{counter1_from} < $resource_end)
                        )
    
                )
    
    
        )
    
    
    ) {

    Один if от создателя :) Еще (с) Руслан Залата

    SanityIO, 12 Января 2011

    Комментарии (2)
  8. JavaScript / Говнокод #5215

    +159

    1. 1
    2. 2
    3. 3
    for (i = 1; i < <?php echo count($prog[1])?>; i++){
         if (document.getElementById('module'+i).checked)
            	module_tmp= Math.abs($('#module'+i).val())+module_tmp;

    1_and_0, 11 Января 2011

    Комментарии (2)
  9. Куча / Говнокод #5195

    +132

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <select name="select" id="planeSel" onChange="javascript:self.location.href=this.value;">
    			 <option disabled selected>Выберите карту</option>
                 <option value="http://172.23.67.36/ingeo/index.asp?db=Address">Адресный план</option>
                 <option value="http://172.23.67.36/ingeo/index.asp?db=GenPlan">Генеральный план</option>
                 <option value="http://172.23.67.36/ingeo/index.asp?db=PZZ">Правила землепользования</option>
                 <option value="http://172.23.67.36/ingeo/index.asp?db=Building">Новое строительство</option>
            </select>

    www.eguar.ru/ingeo/index.asp?db=Building

    Dummy, 10 Января 2011

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

    +123

    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
    //********henry+ disable battery command after select disable battery, 2010.8.5 add bypass more command when EC FW update
    if (iflag_disabel_battery==1 
            && pRequest->RequestType == NvEcRequestResponseType_Battery
            && pRequest->RequestType == NvEcRequestResponseType_System
            && pRequest->RequestType == NvEcRequestResponseType_Gpio
            && pRequest->RequestType == NvEcRequestResponseType_Sleep
            && pRequest->RequestType == NvEcRequestResponseType_Keyboard
            && pRequest->RequestType == NvEcRequestResponseType_AuxDevice){
            //NvOsDebugPrintf("Henry: disable Battery command request! \n");
            //return NvSuccess-1;
            return NvSuccess; //2010.6.29 fix EC TimeOut
    }
    //***********************************************************************************************

    Генри хуйни не сделает!

    muromec, 06 Января 2011

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

    +145

    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
    #-------------------------------------------------
    #
    # Project created by QtCreator 2011-01-06T13:54:57
    #
    #-------------------------------------------------
    
    QT       += core gui
    
    TARGET = RSelector
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            qrselector.cpp
    
    HEADERS  += qrselector.h
    
    FORMS    += qrselector.ui

    qrselector.pro

    Resager, 06 Января 2011

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