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

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

    +234

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    00614A77  |.  8BF0          MOV ESI,EAX
    00614A79  |.  BB 01000000   MOV EBX,1
    00614A7E  |.  EB 01         JMP SHORT 00614A81
    00614A80  |>  43            /INC EBX
    00614A81  |>  3BF3           CMP ESI,EBX
    00614A83  |.  7C 07         |JL SHORT 00614A8C
    00614A85  |.  807C1F FF 20  |CMP BYTE PTR DS:[EDI+EBX-1],20
    00614A8A  |.^ 76 F4         \JBE SHORT 00614A80

    Оптимизация компилятора

    Xekep, 22 Апреля 2011

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public function setAmbiguityIdentity($flag)
        {
            if (is_integer($flag)) {
                $this->_ambiguityIdentity = (1 === $flag ? true : false);
            } elseif (is_bool($flag)) {
                $this->_ambiguityIdentity = $flag;
            }
            return $this;
        }

    Zend Framework компонент Zend_Auth_Adapter_DbTable. (Слегка смутила строка 4)

    sonic, 21 Апреля 2011

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

    +126

    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
    g.Graphics.DrawLine( p, this.pb.Width / 2 + 126, this.pb.Height / 2 + 176, this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20 );
                        g.Graphics.DrawLine( p, this.pb.Width / 2 - 126, this.pb.Height / 2 + 176, this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 - 126 + 8, this.pb.Height / 2 + 176 + 15 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 - 126 + 8, this.pb.Height / 2 + 176 + 25 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 + 126 - 8, this.pb.Height / 2 + 176 + 15 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 + 126 - 8, this.pb.Height / 2 + 176 + 25 );
                        g.Graphics.FillRectangle( Brushes.White, this.pb.Width / 2 - 25, this.pb.Height / 2 + 176 + 10, 50, 20 );
                        g.Graphics.DrawString( this.textBox1.Text + " mm", new Font( "Arial", 8 ), new SolidBrush( Color.Black ), this.pb.Width / 2 - 21, this.pb.Height / 2 + 176 + 12 );
    
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 + (int)paint_nozh_fill / 2, this.pb.Height / 2 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 - (int)paint_nozh_fill / 2 + 8, this.pb.Height / 2 - 5 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 - (int)paint_nozh_fill / 2 + 8, this.pb.Height / 2 + 5 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 + (int)paint_nozh_fill / 2 - 8, this.pb.Height / 2 - 5 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 + (int)paint_nozh_fill / 2 - 8, this.pb.Height / 2 + 5 );
                        g.Graphics.FillRectangle( Brushes.White, this.pb.Width / 2 - 25, this.pb.Height / 2 - 10, 50, 20 );
                        g.Graphics.DrawString( this.getNozhFill( ).ToString( ) + " mm", new Font( "Arial", 8 ), new SolidBrush( Color.Black ), this.pb.Width / 2 - 21, this.pb.Height / 2 - 8 );

    Человек похоже перепутал визул студию с фотошопом, но закрывать не стал )) Этот код рисует чертеж - примем со стрелочками, с откосами и даже(!) с отбрасывает тень. Понятия не имею как преписывать

    glilya, 16 Апреля 2011

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

    +167

    1. 1
    Перейти на страницу <span onmouseover="this.className='menu_over'" onmouseout="this.className='menu'" class="menu" onClick="window.location='<?echo $arItem["DETAIL_PAGE_URL"]?>'">--></span>

    тег "a" видимо был незнаком.

    Fisher, 30 Марта 2011

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    __int64 timestamp;
    
    	// Get nanoseconds since 1601
    	timestamp = rand() + (((__int64)rand()) << 32);
    	timestamp /= 100;

    очень вольная работа со временем...

    kubrinsky, 16 Марта 2011

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

    +126

    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
    Type window = core.getTypeCreationWindowFromType( this.currentType );
                if (window != null)
                {
                    var cr_window = Activator.CreateInstance( window );
                    if (window == typeof( forms.showWindow ))
                    {
                        ((forms.showWindow)cr_window).setTitle( "Добавить новую позицию" );
                        ((forms.showWindow)cr_window).setType( this.chldrenType );
                        ((forms.showWindow)cr_window).fill( );
                        ((forms.showWindow)cr_window).setSelectionMode( );
                        if (this.isExlusivePositionResolve == true) 
                        {
                            // var new_item = Activator.CreateInstance( this.chldrenType );
                            //new_item = (types.ICovertiablePersist<this.chldrenType>)core.instance().ge
    
                            ((forms.showWindow)cr_window).selectedItem += ( forms.showWindow form ) =>
                            {
                                var new_item = Activator.CreateInstance( this.chldrenType );
                                ///new_item = core.instance().getObject(this, form.selected_id);
    
                                int parent_object_id = -1; // Это номер связанного с 
                                                           //выриьбаемым обектом объекта, 
                                                           //тоесть если окно выбора было 
                                                           //кастомизированна и тип выбираемы 
                                                           //х щзначений другой нежели целевой 
                                                           //то мы ищем звязь между обектом ородите и дитя !!!
                                FieldInfo[] fields = this.chldrenType.GetFields( );
                                
                                int id = ((types.persistent)new_item).id;
                                bool isExists = false;
                                for (int i = 0; i < this.dgv_grid.RowCount; i++) 
                                {
                                    int id_s;
                                    int.TryParse( this.dgv_grid.Rows[i].Cells["id"].Value.ToString( ),out id_s );
                                    if (id_s == id) 
                                    {
                                        int count;
                                        int.TryParse( this.dgv_grid.Rows[i].Cells["count"].Value.ToString( ), out count );
                                        this.dgv_grid.Rows[i].Cells["count"].Value = count++;
                                        isExists = true;
                                    }
                                }
                                if (isExists == false) 
                                {
                                    this.addOnePosition( new_item );
                                }
                            };
                        }
                    }
                    else 
                    {
                        ((Form)cr_window).FormClosed += ( object sender, FormClosedEventArgs e ) => {
                            this.fill( );
                        };                   
                    }
                    ((System.Windows.Forms.Form)cr_window).Show( );
                }
                else
                {
                    MessageBox.Show( "Объекты такого типа создавать запрещено" );
                }

    Нашел его миленкого. Переписываю ))) А коменн то комент

    glilya, 15 Марта 2011

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

    +175

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    //из какого то мануала
    
    Switch($_POST['ingame'])
    {
          case $_POST['ingame']:{
          //тут какая то ебень
         }
    
    }

    Судя по всему - мануал реально удался.. и там в скобках реально какая то ебень!

    Aios, 08 Марта 2011

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

    +157

    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
    template <typename T>
    class Animate : public internal::interval_action
    {
    public:        
    
    	Animate(render::Sprite* target, bool restore_frame, bool repeat, T* animation)
            : m_target(target)
            , m_animation(animation)
            , m_restore(restore_frame)
            , m_time(0.0f)
            , m_current_frame(0)
            , m_done(false)
            , m_frames_count(animation->frames_count())
            , interval_action(animation->delay * m_frames_count)    
        {
    	...
        }
    };

    Это как раз тот случай, когда "one facepalm is not enough". (c)

    Kirinyale, 28 Февраля 2011

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

    +160

    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
    <?php
    //дата и время.
    $date1 = date('d.m.Y');
    $date2 = date('H:i:s');
    //$i - счётчик пользователей, $cnt - то, что будем выводить (в завершении)
    //$uall - Ссылки на пользователей онлайн
    $i = 0;
    $cnt = NULL;
    $uall = NULL;
    $db->query = "SELECT id, nick, timeof, online FROM ".$GLOBALS['pref']."users";
    $qonl = $db->query();
    $cnt .= "Всего участников ";
    
    while ($usronl = $db->farray($qonl)) {
    if ($usronl['online'] == TRUE) {
    $ar = explode("|:|", $usronl['timeof']);
    
    //Если сегодняшняя дата
    if ($ar[0] === $date1) {
    
    $est = explode(":", $ar[1]);
    $tm = explode(":", $date2);
    $m4 = $est[0] - $tm[0];
    $m5 = $tm[1] - $est[1];
    $m6 = "$m5";
    if (($est[0] === $tm[0]) && (($m5 <= 15))) {
    if ($i > 0) { $p = ","; } else { $p = NULL; }
    if ($i == 1) { $s = ","; } else { $s = NULL; }
    $i++;
    $uall .= $s."<a href=\"http://".$GLOBALS['url']."/users/
    profile/".$usronl['id']."/\" title=\"Посмотреть профиль\">".$usronl['nick']."<
    /a>".$p." ";
    
     } elseif (($m4 == -1) && ($m6{0} === "-" && $m5 <= -45)) {
    if ($i > 0) { $p = ","; } else { $p = NULL; }
    if ($i == 1) { $s = ","; } else { $s = NULL; }
    $i++;
    $uall .= $s."<a href=\"http://".$GLOBALS['url']."/users/
    profile/".$usronl['id']."/\" title=\"Посмотреть профиль\">".$usronl['nick']."<
    /a>".$p." ";
     }
      }
       } 
    	} //end while
    if ($i == 0) {
    $uall .= "никого";
    } else {
    
    $co = strlen($uall);
    $uall = substr($uall, 0, $co - 7);
    $uall .= ".";
    }
    $cnt .= "(".$i."):<BR>".$uall;
    
    ?>

    Писал вывод онлайн посетителей на сайте в 2009 году.

    Furry, 21 Февраля 2011

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

    +157

    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
    struct Event
    {
       int priority;
       bool operator<(Event e) const
       {
          return e.priority>priority;
       }
       
       virtual void operator() () = 0;
    };
    
    priority_queue<Event*, deque<Event*> > eventQueue;
    
    template <typename T, void (T::*g)()>
    struct  TEvent : Event
    { 
       T* parent;
       virtual void operator() () 
       {
          (parent->*g)();
       }
       TEvent (T* _parent) : parent(_parent){}
    };
    
    struct Entity
    {
       int foo;
       void AFunc() 
       {
          cout<<foo;
       }
    
       void BFunc() 
       {
          cout<<"Ololo";
       }
               
       typedef TEvent<Entity,&Entity::AFunc> someEvent;
       Entity(int _foo): foo(_foo){}
             
       void addEvent()
       {
          eventQueue.push(new someEvent(this));
       }
    };
    
    int main()
    {
       Entity foo(10);
       foo.addEvent();
       (*eventQueue.top())();
       return 0;
    }

    Один из самых сложных и неочевидных способов вывести в консоль число 10.
    (Этот код - проверка, будет ли работать прототип велосипедного делегата)

    CHayT, 15 Февраля 2011

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