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

    В номинации:
    За время:
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
  7. JavaScript / Говнокод #5680

    +172

    1. 1
    var rus_rl = ('А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я-а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я').split('-');

    vugluskr, 15 Февраля 2011

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

    +166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if(VisabilityOnOff==true){
    	   document.SearchForm.searchoption[0].disabled=true;
    	   document.SearchForm.searchoption[1].disabled=true;
    }else if(VisabilityOnOff==false){
    	   document.SearchForm.searchoption[0].disabled=false;
    	   document.SearchForm.searchoption[1].disabled=false;
    }

    kuku, 09 Февраля 2011

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

    +154

    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
    //построение суффиксного массива
    vector <int> getarr(string s) 
    {
      //s - исходная строка
      //суффиксный массив
      vector <int> arr;
      arr.resize(s.size());
      //массив цветов
      vector <int> col;
      col.resize(s.size());
      //массив для временных данных
      vector <int> buf;
      buf.resize(s.size());
      //массив для карманов сортировки
      vector <int> buck;
      buck.resize(max(L, (int) s.size()));
      //Шаг первый - начальная сортировка
      //мы хотим отсортировать буквы строки
      //посчитаем количество всех букв
      for (int i = 0; i < (int) s.size(); i++) 
        buck[s[i]]++;
      //преобразуем массив так, чтобы каждый элемент указывал на положение в массиве первой данной буквы
      int sum = 0; 
      for (int i = 0; i < L; i++) 
      {
        sum += buck[i];
    	buck[i] = sum - buck[i];
      }
      //теперь заполним массив arr: Теперь в нем суффиксы отсортированы по первой букве
      for (int i = 0; i < (int) s.size(); i++) 
        arr[buck[s[i]]++] = i;
      //теперь проставляем цвета: цвет увеличивается на 1 если следующая буква - другая
      col[arr[0]] = 0; 
      for (int i = 1; i < (int) s.size(); i++) 
        col[arr[i]] = col[arr[i-1]] + (s[arr[i]] != s[arr[i-1]]); 
      int cn = col[arr[s.size() - 1]] + 1;
      //Шаг второй - постепенное расширение подстрок
      //в начале цикла отсортированы подстроки длины l, а в конце - длины 2l
      for (int l = 1; l < (int) s.size(); l *= 2) 
      {
        //обнуляем массив buck  и заполняем для сортировки по col
        for (int i = 0; i < (int) s.size(); i++) 
          buck[i] = 0; 
        for (int i = 0; i < (int) s.size(); i++) 
          buck[col[i]]++; sum = 0; 
        for (int i = 0; i < cn; i++) 
          sum += buck[i], buck[i] = sum - buck[i];
        //строим новый массив в buf (не забываем сдвинуть указатель по модулю на l влево), затем копируем его в arr
        for (int i = 0; i < (int) s.size(); i++) 
          buf[buck[col[(arr[i] - l + s.size()) % s.size()]]++]=(arr[i] - l + s.size()) % s.size(); 
        arr = buf;
        //теперь перекрашиваем массив col: заполняем массив buf, увеличиваем цвет на единицу если один из цветов отличается, затем копируем
        buf[arr[0]] = 0; 
        for (int i = 1; i < (int) s.size(); i++) 
          buf[arr[i]] = buf[arr[i - 1]] + (col[arr[i]] != col[arr[i - 1]] || col[(arr[i] + l) % s.size()] != col[(arr[i - 1] + l) % s.size()]); 
        cn = buf[arr[s.size() - 1]] + 1; 
        col = buf;
      }
      //возвращаем результат
      return arr;
    }

    Это просто жуть

    chexov, 09 Февраля 2011

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

    +133

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    /* тыц */
    /*wbr:after { content: '\00200B'; }*/
    /* they say it's better */
    wbr {
      width: 0px;
      display: inline-block;
      overflow: hidden;
    }

    Вконтакте.
    http://vkontakte.ru/css/rustyle.css?104
    Привет тем, кто сказал Пашке Дурову, что костыль - это не очень хорошо.

    7ion, 21 Января 2011

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

    +158

    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
    $mazovia[18];
    	$iso[18];
    
    	$mazovia[0]  = chr(134);$iso[0]=chr(177);		//a~
    	$mazovia[1]  = chr(143);$iso[1]=chr(161);		//A~
    	$mazovia[2]  = chr(141);$iso[2]=chr(230);		//c~
    	$mazovia[3]  = chr(149);$iso[3]=chr(198);		//C~
    	$mazovia[4]  = chr(145);$iso[4]=chr(234);		//e~
    	$mazovia[5]  = chr(144);$iso[5]=chr(202);		//E~
    	$mazovia[6]  = chr(146);$iso[6]=chr(179);		//l~
    	$mazovia[7]  = chr(156);$iso[7]=chr(163);		//L~
    	$mazovia[8]  = chr(164);$iso[8]=chr(241);		//n~
    	$mazovia[9]  = chr(165);$iso[9]=chr(209);		//N~
    	$mazovia[10] = chr(162);$iso[10]=chr(243);		//o~
    	$mazovia[11] = chr(163);$iso[11]=chr(211);		//O~
    	$mazovia[12] = chr(158);$iso[12]=chr(182);		//s~
    	$mazovia[13] = chr(152);$iso[13]=chr(166);		//S~
    	$mazovia[14] = chr(166);$iso[14]=chr(188);		//z~
    	$mazovia[15] = chr(160);$iso[15]=chr(172);		//Z~
    	$mazovia[16] = chr(167);$iso[16]=chr(191);		//z|
    	$mazovia[17] = chr(161);$iso[17]=chr(175);		//Z|
           
            $strmazovia="";
    	$strIso="";
    	for ($i=0;$i<=17;$i++){
    		$strmazovia=$strmazovia."\\".$mazovia[$i];
    		$strIso= $strIso."\\".$iso[$i];
    	}
    
    
    	function convert($str){
    		global $strmazovia;
    		global $strIso;
    	        return StrTr($str,$strmazovia,$strIso);
    	}

    xaoc, 28 Декабря 2010

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