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

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

    +97

    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
    Program zadacha; 
    var 
       i,chislo,x,y,m,n:integer; 
    begin 
       while i<1 do begin 
       for x:=0 to chislo do begin 
       for y:=0 to chislo do begin 
       for m:=0 to chislo do begin 
       for n:=0 to chislo do begin 
       if (chislo=x*x*x+y*y*y) and (chislo=m*m*m+n*n*n) and (x<>m) and (x<>y) and (y<>m) and (y<>n) then i:=1 else chislo:=chislo+1; 
       end; 
       end; 
       end; 
       end; 
       end; 
       Writeln(chislo); 
    end.

    Вот так находят "минимальное натуральное число представимое двумя различными способами в виде суммы кубов двух натуральных чисел"

    kolhoz, 20 Октября 2010

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

    +172

    1. 1
    <td><?="ID"?>:</td>

    Пример из документации Bitrix
    http://dev.1c-bitrix.ru/api_help/main/general/admin.section/classes/cadminfilter

    Rpsl, 18 Октября 2010

    Комментарии (18)
  4. Java / Говнокод #4354

    +122

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    List<String> el=parseList();
    		Theme th=new Theme(id);
    
    		th.setScore=Integer.parseInt(el.get(1));
    		th.setComments=Integer.parseInt(el.get(2));
    		th.setAuthor=el.get(3);
    		th.setVisitors=Integer.parseInt(el.get(4));
    		th.setVisitorsLastWeek=Integer.parseInt(el.get(5));
    		th.eMail=el.get(5);
    		return th;

    3.14159265, 12 Октября 2010

    Комментарии (18)
  5. Куча / Говнокод #4247

    +134

    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
    <p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>
    	<p class="MsoNormal" align="center" style="text-align: center; margin-left: 10px; margin-right: 5px; margin-top: 0; margin-bottom: 0">&nbsp;</p>

    Гиппер текст! :)
    http://www.uae-embassy.ru/rco01.htm.
    посольство то же...

    Alfred, 14 Сентября 2010

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

    −128

    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
    CREATE TABLE IF NOT EXISTS `ls_user` (
      `user_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
      `user_login` varchar(30) NOT NULL,
      `user_password` varchar(50) NOT NULL,
      `user_mail` varchar(50) NOT NULL,
      `user_skill` float(9,3) unsigned NOT NULL DEFAULT '0.000',
      `user_date_register` datetime NOT NULL,
      `user_date_activate` datetime DEFAULT NULL,
      `user_date_comment_last` datetime DEFAULT NULL,
      `user_ip_register` varchar(20) NOT NULL,
      `user_rating` float(9,3) NOT NULL DEFAULT '0.000',
      `user_count_vote` int(11) unsigned NOT NULL DEFAULT '0',
      `user_activate` tinyint(1) unsigned NOT NULL DEFAULT '0',
      `user_activate_key` varchar(32) DEFAULT NULL,
      `user_profile_name` varchar(50) DEFAULT NULL,
      `user_profile_sex` enum('man','woman','other') NOT NULL DEFAULT 'other',
      `user_profile_country` varchar(30) DEFAULT NULL,
      `user_profile_region` varchar(30) DEFAULT NULL,
      `user_profile_city` varchar(30) DEFAULT NULL,
      `user_profile_birthday` datetime DEFAULT NULL,
      `user_profile_site` varchar(200) DEFAULT NULL,
      `user_profile_site_name` varchar(50) DEFAULT NULL,
      `user_profile_icq` bigint(20) unsigned DEFAULT NULL,
      `user_profile_about` text,
      `user_profile_date` datetime DEFAULT NULL,
      `user_profile_avatar` varchar(250) DEFAULT NULL,
      `user_profile_foto` varchar(250) DEFAULT NULL,
      `user_settings_notice_new_topic` tinyint(1) NOT NULL DEFAULT '1',
      `user_settings_notice_new_comment` tinyint(1) NOT NULL DEFAULT '1',
      `user_settings_notice_new_talk` tinyint(1) NOT NULL DEFAULT '1',
      `user_settings_notice_reply_comment` tinyint(1) NOT NULL DEFAULT '1',
      `user_settings_notice_new_friend` tinyint(1) NOT NULL DEFAULT '1',
      PRIMARY KEY (`user_id`),
      UNIQUE KEY `user_login` (`user_login`),
      UNIQUE KEY `user_mail` (`user_mail`),
      KEY `user_activate_key` (`user_activate_key`),
      KEY `user_activate` (`user_activate`),
      KEY `user_rating` (`user_rating`),
      KEY `user_profile_sex` (`user_profile_sex`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
    [/code]
    очень актуально смотрится эта таблица с приведённой выше. очень умно сделать таблицу "топик-стартер" и не выделить отдельно профиль пользователя. что чаще используется в выборке? =)
    про миллионы пользователей и лайвстрит - не смешите, не верю (с)
    загнётся до прихода в БД

    дополнение к http://govnokod.ru/4203
    выделил отдельным гауно-кодом из-за того, что комично смотрится вместе с указанной выше таблицей. ну и ограничение длины комментов есть. ярые искатели оптимизаций видимо идут мимо. очень актуально смотрится эта таблица с приведённой выше. очень умно сделать таблицу админов в один колумн и не выделить отдельно профиль пользователя. что чаще используется в выборке? =)

    hybroid, 09 Сентября 2010

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

    +144

    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
    <?php
    
    class Event {
        private static $_instance = NULL;
        protected $_events_pool = array();
    
        public static function getInstance() {
            if (self::$_instance === NULL) {
                $class = __CLASS__;
                self::$_instance = new $class;
            }
            
            return self::$_instance;
        }
    
        private function __construct() { }
    
        public function connect($event, $callback, array $params = null) {
            $this->_events_pool[$event] = array(
                'callback'	=>	$callback,
                'params'	=>	$params,
            );
            
            return $this;
        }
    
        public function clear($event = NULL) {
            if ($event === NULL) {
                $this->_events_pool = array();
            } else {
                foreach ($this->_events_pool as $id => $_event) {
                     if ($_event['event'] === $event) {
                        $this->_events_pool[$id] = NULL;
                     }
                }
            }
        }
    
        public function emit($events = NULL) {
            if ($events === NULL) {
                $events = array_keys($this->_events_pool);
            } else {
                $events = (is_array($events)) ? $events : array($events);
            }
            
            foreach ($events as $event) {
                foreach ($this->_events_pool as $id => $item) {
                     if ($id === $event) {
                        $this->call($this->_events_pool[$id]['callback']);
                     }
                }
            }
        }
    
        protected function call($class_name, $method_name = NULL, array $params = array(), array $class_params = array()) {	
            $_method = ($method_name === NULL) ? $class_name : array($class_name, $method_name);
            call_user_func_array($_method, $params);
        }
    }

    nergal, 26 Августа 2010

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

    +175

    1. 1
    2. 2
    sleep(10);
    header('Location: http://example.com');

    Называется "Редирект через 10 секунд".
    Собственно автору требовалось это: <meta http-equiv="refresh" content="10; url=index.php">.

    Uchkuma, 23 Августа 2010

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

    +134

    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
    TestIssue = new Issue(Id, ProjectId, ProjectName, Code, Title,  
        Description, CategoryId, CategoryName, PriorityId,
        PriorityName,PriorityImageUrl, StatusId, StatusName, 
        StatusImageUrl, IssueTypeId, IssueTypeName,IssueTypeImageUrl,
        ResolutionId, ResolutionName,ResolutionImageUrl, 
        AssignedDisplayName, AssignedUsername, AssignedUserId,
        CreatorDisplayName, CreatorUsername, CreatorUserId, 
        OwnerDisplayName, OwnerUsername, OwnerUserId, DueDate, 
        MilestoneId, MilestoneName, MilestoneImageUrl, 
        MilestoneDueDate, AffectedMilestoneId, AffectedMilestoneName, 
        AffectedMilestoneImageUrl, Visibility, TimeLogged, Estimation, 
        DateCreated, LastUpdate, LastUpdateUsername, 
        LastUpdateDisplayName, Progress, Disabled, Votes);

    В конструкторе класса Issue 47 аргументов (http://codehelper.ru/questions/156).

    admax, 18 Августа 2010

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

    +171

    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
    <?if ($tip1[1]=="avi"){?>class="lnk-avi"<?}
      elseif ($tip1[1]=="djv"){?>class="lnk-djv"<?}
      elseif ($tip1[1]=="doc"){?>class="lnk-doc"<?}
      elseif ($tip1[1]=="flv"){?>class="lnk-flv"<?}
        elseif ($tip1[1]=="pdf"){?>class="lnk-pdf"<?}
      elseif ($tip1[1]=="jpeg"){?>class="lnk-jpeg"<?}
        elseif ($tip1[1]=="jpg"){?>class="lnk-jpeg"<?}
    	  elseif ($tip1[1]=="JPEG"){?>class="lnk-jpeg"<?}
    	    elseif ($tip1[1]=="JPG"){?>class="lnk-jpeg"<?}
      elseif ($tip1[1]=="pdf"){?>class="lnk-pdf"<?}
      elseif ($tip1[1]=="png"){?>class="lnk-png"<?}
      elseif ($tip1[1]=="swf"){?>class="lnk-swf"<?} 
        elseif ($tip1[1]=="gif"){?>class="lnk-gif"<?}
      elseif ($tip1[1]=="xls"){?>class="lnk-xls"<?}?>
      ><?=$VALUESIO[$i]?></a>, <?=$tip1[1];?>, <?=$size1;?>Мб

    case придумали дураки)

    нашол в проекте, который сейчас доделываю)

    kudin, 16 Августа 2010

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

    +113

    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
    double x, y;
    
    void InitializeComponent()
    {
        this.MouseClick += new MouseEventHandler(Form1_Click);
        this.Paint += new PaintEventHandler(Form1_Paint);
    }
    
    void Form1_Paint(object sender, PaintEventArgs e)
    {
        PointF p = new PointF(0, 0);
        PointF pp = new PointF((float)x, (float)y);
        e.Graphics.DrawPolygon(new Pen(Color.Black, 3), new PointF[2] { p, pp });
    }
    
    void Form1_Click(object sender, MouseEventArgs e)
    {
        x = e.X;
        y = e.Y;
    
        AsyncDraw(ref x, ref y);
    }
    
    void AsyncDraw(ref double x, ref double y)
    {
        x = x;
        y = y;
    }

    sergylens, 14 Августа 2010

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