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

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

    +78

    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
    for (JButton button : buttons) {
        if(buttons.length>0&&button==buttons[0]){
            if (canCreate()||button.getName().equals(BTN_EDIT_CONTRACT)) {
                UiUtils.setEnabled(button, true, canCreate()|| button.getName().equals(BTN_EDIT_CONTRACT));
            } else {
                UiUtils.setEnabled(button, false, canCreate()|| button.getName().equals(BTN_EDIT_CONTRACT));
            }
        }
        if(buttons.length>1&&button==buttons[1]){
            if (canEdit()||canView()||button.getName().equals(BTN_EDIT_CONTRACT)) {
                UiUtils.setEnabled(button, true, canEdit()||canView()|| button.getName().equals(BTN_EDIT_CONTRACT));
            } else {
                UiUtils.setEnabled(button, false, canEdit()||canView() || button.getName().equals(BTN_EDIT_CONTRACT));
            }
        }
        if(buttons.length>2&&button==buttons[2]){
            if (canDelete()||button.getName().equals(BTN_EDIT_CONTRACT)) {
                UiUtils.setEnabled(button, true, canDelete()|| button.getName().equals(BTN_EDIT_CONTRACT));
            } else {
                UiUtils.setEnabled(button, false, canDelete() || button.getName().equals(BTN_EDIT_CONTRACT));
            }
        }
        if(buttons.length>3&&button==buttons[3]){
            if (canEdit()||canView()||button.getName().equals(BTN_EDIT_CONTRACT)) {
                UiUtils.setEnabled(button, true, canEdit()||canView()|| button.getName().equals(BTN_EDIT_CONTRACT));
            } else {
                UiUtils.setEnabled(button, false, canEdit()||canView() || button.getName().equals(BTN_EDIT_CONTRACT));
            }
        }
        if(buttons.length>4&&button==buttons[4]){
            if (canEdit()||canView()||button.getName().equals(BTN_EDIT_CONTRACT)) {
                UiUtils.setEnabled(button, true, canEdit()||canView()|| button.getName().equals(BTN_EDIT_CONTRACT));
            } else {
                UiUtils.setEnabled(button, false, canEdit()||canView() || button.getName().equals(BTN_EDIT_CONTRACT));
            }
        }
    }

    borka, 15 Июля 2010

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

    +157

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    for ($i = 0; $i < $count; $i++) {
     if ($links_array['is'][$i]) {
      $link_text .= '[url='.$links_array['href'][$i].']'.$links_array['new_name'][$i].'c ('.link_domain($links_array['href'][$i]).')[/url]';
      if ($links_array['mirror'][$i] != '') {
       $link_text .= "\n".'[url='.$links_array['mirror'][$i].']'.$links_array['new_name'][$i].'c ('.link_domain($links_array['mirror'][$i]).')[/url]'
      }
      $link_text .= ($i + 1 != $count ? "\n" : '');
     }
    }

    dmOx, 01 Июля 2010

    Комментарии (3)
  4. ActionScript / Говнокод #3607

    −91

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    public function clearGrid():void
    {
    	if(clearGrid != null)
    	{
    		if (selectedChild is AbstractIssueGrid)
    		{
    			(selectedChild["setGridDataProvider"] as Function) (new ArrayCollection());
    		}
    	}
    }

    Держите меня семеро Х_х

    dimas_art, 30 Июня 2010

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

    −151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    try:
       if respond[0] == 'command':
           self.servercommands.append(respond)
       else:
           raise KeyError('Invalid type')
    except (TypeError, IndexError, KeyError):
       self.responds.append(respond)

    roku, 29 Июня 2010

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

    +75

    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
    String message = myObj.getMessage();
    
    if (!message.equals("")) {
        if (showDialog(s)) {
            method1();
            method2();
            method3();
        } 
    } else {
        method1();
        method2();
        method3();
    }

    Пособие для не ленивых.

    lotik, 29 Июня 2010

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

    +72

    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
    String.format(
            "<b>%s:%s %s %s %d</b>",
            setDisplayFromNumber(calendar.get(GregorianCalendar.HOUR_OF_DAY)), 
            setDisplayFromNumber(calendar.get(GregorianCalendar.MINUTE)),
            setDisplayFromNumber(calendar.get(GregorianCalendar.DAY_OF_MONTH)),
            getMonthNameFromNumber(calendar.get(GregorianCalendar.MONTH)),
            calendar.get(GregorianCalendar.YEAR)
    );
    
    private String setDisplayFromNumber(Integer number) {
        if(number < 10) {
            return String.format("0%d", number);
        }
        else {
            return number.toString();
        }
    }

    yvu, 24 Июня 2010

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

    +167

    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
    /*
      `id` int(10) NOT NULL auto_increment,
      `time_s` timestamp NOT NULL default CURRENT_TIMESTAMP,
      `event` varchar(10) NOT NULL,
      `member` int(4) NOT NULL,
      PRIMARY KEY  (`id`)
    */
    $min = 0;
    $result=mysql_query('select * from `stat_prohod`.`events`');
    while ( $row = mysql_fetch_assoc ( $result ) ) {
    	if ($row ["id"] > $min) {
    		$last = $row;
    		$min = $row ["id"];
    	}
    }

    выборка последней записи.
    табла заполняется
    $query1="INSERT INTO `stat_prohod`.`events` (`event` ,`member` )VALUES ('".$action."', '".$id."');";

    nur, 17 Июня 2010

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

    +69

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    private String setArticleHTML() {
        // ...
    }
    
    ...
    
    mArticleView.loadDataWithBaseURL(mBaseUrl, setArticleHTML(), "text/html", "UTF-8", "");

    yvu, 15 Июня 2010

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

    +148

    1. 1
    2. 2
    3. 3
    if (browser.opera && browser.version < 10.50) {
              parent.innerHTML = parent.innerHTML;
            }

    http://vkontakte.ru/js/player.js?10 (c)

    Back, 13 Июня 2010

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

    +111

    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
    try
                {
                    Int16 y = 0, m = 0, d = 0, hh = 0, mm = 0, ss = 0, ms = 0, zn = 0;
                    if (Value.IndexOf("T") > 0)
                    {
                        Int16.TryParse(Value.Substring(0, 4), out y);
                        Int16.TryParse(Value.Substring(4, 2), out m);
                        Int16.TryParse(Value.Substring(6, 2), out d);
                        Int16.TryParse(Value.Substring(9, 2), out hh);
                        Int16.TryParse(Value.Substring(11, 2), out mm);
                        Int16.TryParse(Value.Substring(13, 2), out ss);
                        Int16.TryParse(Value.Substring(16, 2), out ms);
                        Int16.TryParse(Value.Substring(18, 3), out zn);
                        dt = new DateTime(y, m, d, hh, mm, ss, ms, DateTimeKind.Utc);
                    }
                    if (Value.IndexOf("T") == 0)
                    {
                        Int16.TryParse(Value.Substring(0, 2), out hh);
                        Int16.TryParse(Value.Substring(2, 2), out mm);
                        Int16.TryParse(Value.Substring(4, 2), out ss);
                        Int16.TryParse(Value.Substring(7, 2), out ms);
                        dt = dt.AddHours(hh).AddMinutes(mm).AddSeconds(ss).AddMilliseconds(ms);
                    }
    
                    dt.AddHours(-zn);
    
                catch (Exception ex)
                {
                    Console.Write(this.Value + "\r\n" + ex.ToString());
                }
    
              return dt;

    Разбор модифицированного iso 8601 формата даты и времени (без "-").
    не учитавается наличие/отсуствие даты или времени, длинная тайм зона, то что если нет T то это не время а дата. Естественно все обернуто в try/catch что бы никто не догадался.

    Так сказать особой утонченности придает строка dt.AddHours(-zn);
    (сколько уйдет у кого секунд что бы понять что с ней не так?)

    eval_2009, 10 Июня 2010

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