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

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

    +66

    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
    if ($dt && $eventtype != 5 && $eventtype != 7) {
        $sql_cond = " and b.datefrom='$dt'";
    }
    
    if ($eventtype == 5 || $eventtype == 7) {
    
        if (!$dt || $dt == "0") {
    
            $w = date("w");
    
            $mon_dl = 7 - $w;
    
            for ($j = 0; $j <= (7 - $w); $j++) {
                $d = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $j, date("Y")));
                $dates .= ($dates ? "," . $d : $d);
            }
    
            if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
        }
    
        if ($dt == "1") {
            $w = date("w");
            if ($w == 0) {
                $monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
            } else {
                $monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + (7 - $w) + 1, date("Y")));
            }
    
    
            for ($j = 0; $j <= 6; $j++) {
                $d = date("Ymd", mktime(0, 0, 0, substr($monday, 4, 2), substr($monday, 6, 2) + $j, substr($monday, 0, 4)));
                $dates .= ($dates ? "," . $d : $d);
            }
    
            if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
        }
    
        if ($dt == "2") {
    
            $w = date("w");
            if ($w == 0) {
                $monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
            } else {
                $monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + (7 - $w) + 1, date("Y")));
            }
    
            for ($j = 7; $j <= 13; $j++) {
                $d = date("Ymd", mktime(0, 0, 0, substr($monday, 4, 2), substr($monday, 6, 2) + $j, substr($monday, 0, 4)));
                $dates .= ($dates ? "," . $d : $d);
            }
    
            if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
        }
    }

    я потерял сон.

    shmaltorhbooks, 29 Мая 2012

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

    +119

    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
    /**
     * crane looks like this: ("----" - fork, "ssss" - stand, "xxx" - crane rail)
     * 
     * ----- .pos2 __/0/ ----- | sssss | sssss | xxx | ----- distance between stands .pos1 __|/distance/ ----- sssss
     * sssss xxx xxx xxx xxx xxx xxx
     * 
     * so if pos2 defined - it will be the second fork; BUT! if the flag "draw second stand" defined - that will draw or
     * not draw the stand for pos1...
     * 
     * if there is just one fork but two TUs to handle is possible:
     * 
     * xxx ________ .pos1 .pos2 ________ sssss sssss xxx xxx xxx
     */

    someone, 29 Мая 2012

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

    −104

    1. 1
    2. 2
    3. 3
    4. 4
    + (NSArray *)findAll {
    	return [self findWithPredicate: [NSPredicate predicateWithFormat:@"1 = 1"]
    							 limit: 0];
    }

    Таки да, все объекты.

    farcaller, 24 Мая 2012

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

    +58

    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
    <?php if ( $poll ) : ?>
    	<h2>Опрос: <?php echo $poll->getTitle(); ?></h2>
    	
    	<?php $count = $poll->votes->count(); ?>
    	
    	<div>Всего ответивших: <?php echo $count; ?></div>
    	
    	<?php if ( $sf_user->isAuthenticated() ) : ?>
    		
    		<?php if ( !$poll->isVote( $sf_user->getGuardUser()->getId() ) ) : ?>
    			
    			<?php foreach ( $poll->answers as $answer ) : ?>
    				<div><?php echo link_to( $answer->getTitle(), 'poll_vote', array( 'poll' => $poll->getId(), 'answer' => $answer->getId() ) ); ?></div>
    			<?php endforeach; ?>
    			
    		<?php else : ?>
    			
    			<?php foreach ( $poll->answers as $answer ) : ?>
    				<div><?php echo $answer->getTitle(); ?> ($count / <?php echo $answer->getPercent( $count ); ?>%)</div>
    			<?php endforeach; ?>
    			
    		<?php endif; ?>
    		
    	<?php else : ?>
    		
    		<?php foreach ( $poll->answers as $answer ) : ?>
    			<div><?php echo $answer->getTitle(); ?></div>
    		<?php endforeach; ?>
    		
    		<div>Что бы выбрать вариант ответа, необходимо войти.</div>
    		
    	<?php endif; ?>
    	
    <?php endif; ?>

    Пал выбор, делать проверку, голосовал пользователь или нет в цикле и выводить соответствующую инфу или сделать проверку и использовать два разных цикла в разных ветках

    psycho-coder, 24 Мая 2012

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

    +90

    1. 1
    public string Материал_Clean { get; set; }

    :[

    nolka4, 24 Мая 2012

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

    +96

    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
    string AutoWait;
    int AutoStop;
    
    /*...*/
    
    RegistryKey sKey = Registry.LocalMachine.OpenSubKey("Platform\\Settings"); 
    AutoStop=(int)Key.GetValue("AutoStop");
    
    if (AutoStop == 1) { AutoWait = "yes"; wait.Enabled = false; } else { AutoWait = "no"; }
    
    /*...*/
    
                    if ((km4<=2)&(onTheWay)&(AutoWait=="yes"))
                    {
                        Waiting=true;
                        label3.BackColor = Color.Red;
                        label4.BackColor = Color.Black;
                    }else
                    if ((km4 > 2) & (onTheWay))
    
    /*...*/

    Классика жанра - использование переменной String в качестве bool. Про ООП автор вообще не слышал, весь код оформлен одной большой портянкой с кучей повторений сброса/установки подобных "флажков".

    ybinzu, 22 Мая 2012

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

    −103

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    - (void)updateTableHeaderOfOrangeColor:(BOOL)reallyOrange andTitle:(NSString *)title
    {
        table.tableHeaderView = reallyOrange ? orangeTableHeaderView : marineTableHeaderView;
        (reallyOrange ? orangeTableHeaderLabel : marineTableHeaderLabel).text = title;
    
        UIImage *tileImage = [UIImage imageNamed:(reallyOrange ? @"tapeWideTile.png" : @"tapeWideTileBlue.png")];
        table.backgroundColor = [UIColor colorWithPatternImage:tileImage];
    }

    причем оранжевый на самом деле красный в интерфейсе

    Venomous, 19 Мая 2012

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

    −23

    1. 1
    2. 2
    std::bad_alloc e;
    throw std::move(e);

    Написал один новичок. Говорит это особая сильно ускоряющая оптимизация.

    Говногость, 18 Мая 2012

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

    −151

    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
    private function chopCompleteHandler(e : DataEvent):void
    		{			
    			if (e.getData().toString() != "false")//что за чудесные преобразования? ////так надо, по другому не хочет
    			{
    				_player.animLift();
    				if (!e.getData().energy)
    				{
    					targetSquare.fieldObject.lifes = uint(e.getData().lifes);
    					if (e.getData().lifes == 0)
    						targetSquare.destroyFieldObject();
    					if (e.getData().bonus)
    						scatterBunuses(e.getData().bonus);
    					Model.instance.requestData(ModelEnum.SERVICE_USER, ModelEnum.METHOD_GETINFO, true, GameCanvas.instance.userID);
    				}
    				else
    					Alert.show("Нужно еще " + e.getData().energy+".", "Недостаточно энергии");
    			}
    		}

    KirAmp, 17 Мая 2012

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

    +79

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if ($type['my_event']) {
        $select->where('1=1)))');
    } else {
        $select->where('1=1))');				
    }

    Индусы..

    anycolor, 17 Мая 2012

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