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

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

    +73.5

    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
    //...                            
                                           }
    
                                        }
                                      }
                                      if(found) break;
                                    }
                                  }
                                  aStr=wcstok(NULL,m_cmdSEP);
                                }
                              }
                            }
                          }
                        }
                      }
                      else NoDeviceErrorActive(1);
                    }
                  }
                }
                else NoDeviceErrorActive(1);
              }
            }
          }
        }
      }
    //...

    Кусочек функции, сегодня наткнулся, сама функция занимает 540 строк, все методы класса -- 8000 =). И форматирование оригинальное -- не табами, а двумя пробелами =) . Мне нужно было просто посмотреть, как этот класс одну штуку делает, и я теперь сижу счастливый и думаю, как хорошо, что не мне этот код поддерживать =)

    ISith, 03 Марта 2010

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

    +166.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function  trim(text) {
      if (text.length == 0) {
        return text;
      }
      if (text.charAt(0) == ' ') {
        return '';
      }
      if (text.charAt(text.length-1) == ' ') {
        text = text.substring(0, text.length-1);
      }
      return text;
    }

    суровый китайский trim...

    ClintEastwood, 02 Марта 2010

    Комментарии (17)
  4. Си / Говнокод #2691

    +133.6

    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
    char *errdesc;
    
    [...]
    
                switch errno
                {
                    case EACCES: errdesc="For Unix domain sockets, which are identified by pathname: Write permission is denied on the socket file, or search permission is denied for one of the directories in the path prefix. (See also path_resolution(2).) " ;break;
                    case EPERM: errdesc="The user tried to connect to a broadcast address without having the socket broadcast flag enabled or the connection request failed because of a local firewall rule. ";break;
                    case EADDRINUSE: errdesc="Local address is already in use. ";break;
                    case EAFNOSUPPORT: errdesc="The passed address didn't have the correct address family in its sa_family field. ";break;
                    case EAGAIN: errdesc="No more free local ports or insufficient entries in the routing cache. For PF_INET see the net.ipv4.ip_local_port_range sysctl in ip(7) on how to increase the number of local ports. ";break;
                    case EALREADY: errdesc="The socket is non-blocking and a previous connection attempt has not yet been completed. ";break;
                    case EBADF: errdesc="The file descriptor is not a valid index in the descriptor table. ";break;
                    case ECONNREFUSED: errdesc="No one listening on the remote address. ";break;
                    case EFAULT: errdesc="The socket structure address is outside the user's address space. ";break;
                    case EINPROGRESS: errdesc="The socket is non-blocking and the connection cannot be completed immediately. It is possible to select(2) or poll(2) for completion by selecting the socket for writing. After select(2) indicates writability, use getsockopt(2) to read the SO_ERROR option at level SOL_SOCKET to determine whether connect() completed successfully (SO_ERROR is zero) or unsuccessfully (SO_ERROR is one of the usual error codes listed here, explaining the reason for the failure). ";break;
                    case EINTR: errdesc="The system call was interrupted by a signal that was caught. ";break;
                    case EISCONN: errdesc="The socket is already connected. ";break;
                    case ENETUNREACH: errdesc="Network is unreachable. ";break;
                    case ENOTSOCK: errdesc="The file descriptor is not associated with a socket. ";break;
                    case ETIMEDOUT: errdesc="Timeout while attempting connection. The server may be too busy to accept new connections. Note that for IP sockets the timeout may be very long when syncookies are enabled on the server.";break;
                    case EADDRNOTAVAIL: errdesc="EADDRNOTAVAIL";break;
                    case EPROTOTYPE: errdesc="EPROTOTYPE";break;
                    case EINVAL: errdesc="Invalid argument passed.";break;
                    case ENOMEM: errdesc="Could not allocate memory for recvmsg().";break;
                    case ENOTCONN: errdesc="The socket is associated with a connection-oriented protocol and has not been connected (see connect(2) and accept(2)).";break;
                    default: errdesc="Unknown error";break;
                }

    Мдя, просматривать код писанный мной же, когда я ещё только-только начинал писать на Си стыдновато. :)

    xaionaro, 28 Февраля 2010

    Комментарии (17)
  5. C++ / Говнокод #2591

    +68.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    // I'VE SO FUCKED CONVERTING THOSE FUCKING TYPES OF STUPID DATA
    		// TAKE IT, FUCKING STRAUSTRUP AND K&R!!!!!!!!!!!
    		if (text[i]=='1') (intarray[i]=1);
    		if (text[i]=='2') (intarray[i]=2);
    		if (text[i]=='3') (intarray[i]=3);
    		if (text[i]=='4') (intarray[i]=4);
    		if (text[i]=='5') (intarray[i]=5);
    		if (text[i]=='6') (intarray[i]=6);
    		if (text[i]=='7') (intarray[i]=7);
    		if (text[i]=='8') (intarray[i]=8);
    		if (text[i]=='9') (intarray[i]=9);
    		if (text[i]=='0') (intarray[i]=0);

    i0ngunn3r, 11 Февраля 2010

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

    +142.6

    1. 1
    myDataSet.Tables[0].DataSet.GetXml();

    need XML Data Source from XML for making dynamic ASP:Menu
    This code makes DataSource as a Parent element and elements from sql as a Children
    I need Parent Elements only from my sql. To make it like a Horizontal TabSet . . .

    Nemerle, 10 Февраля 2010

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

    +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
    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
    $sql=mysql_query("select * from orders1 where sname='$user' and rang='1'");
    $cd1=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders1 where sname='$user' and rang='2'");
    $cd2=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders1 where sname='$user' and rang='3'");
    $cd3=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders1 where sname='$user' and rang='4'");
    $cd4=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders1 where sname='$user' and rang='5'");
    $cd5=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders1 where sname='$user' and rang='6'");
    $cd6=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders1 where sname='$user' and rang='7'");
    $cd7=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders2 where sname='$user' and rang='1'");
    $cord1=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders2 where sname='$user' and rang='2'");
    $cord2=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders2 where sname='$user' and rang='3'");
    $cord3=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders2 where sname='$user' and rang='4'");
    $cord4=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders2 where sname='$user' and rang='5'");
    $cord5=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders2 where sname='$user' and rang='6'");
    $cord6=mysql_num_rows($sql);
    $sql=mysql_query("select*from orders2 where sname='$user' and rang='7'");
    $cord7=mysql_num_rows($sql);
    while($row=mysql_fetch_array($sql)){
    if(($cord1 >1 and $stat==1) or ($cord2 >1 and $stat==2) or ($cord3 >2 and $stat==3) or ($cord4 >2 and $stat==4) or ($cord5 >1 and $stat==5) or ($cord6 >1 and $stat==6) or ($cord7 >1 and $stat==7) or ($cd1 >1 and $stat==1) or ($cd2 >2 and $stat==2) or ($cd3 >2 and $stat==3) or ($cd4 >2 and $stat==4) or ($cd5 >1 and $stat==5) or ($cd6 >1 and $stat==6) or ($cd7 >1 and $stat==7)){
    ?>
     <TABLE  width=100% border="1" align="center">
    ...
    ...
    ...

    С проекта Otvet.mail попросили помощи с тем, что не выводиться какая то таблица, после того как прислали файл, увидел 500 строк кода, без единой функции, все было написано в этом же духе. *Жуть*, и после того как спросил, от какого запроса работает этот цикл, мне прислали $sql=mysql_query("select*from orders1 where sname='$user' and rang IN(1,2,3,4,5,6,7)"); который находиться где-тов начале файла, переменная под который была 100 раз переопределена!)))

    1_and_0, 04 Февраля 2010

    Комментарии (17)
  8. 1C / Говнокод #2539

    −114.9

    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
    запрос = новый запрос("ВЫБРАТЬ
    |	ЗаказыПокупателейОбороты.ЗаказПокупателя,
    |	ЗаказыПокупателейОбороты.Номенклатура,
    |	СУММА(ЗаказыПокупателейОбороты.КоличествоПриход) КАК КоличествоВЗаказе,
    |	СУММА(ВложенныйЗапрос.ОстатокПоЗаказу) КАК ОстатокПоЗаказу,
    |	СУММА(ВложенныйЗапрос.ОстатокВРезерве) КАК ОстатокВРезерве
    |ИЗ
    |	РегистрНакопления.ЗаказыПокупателей.Обороты(, , , ) КАК ЗаказыПокупателейОбороты
    |		ЛЕВОЕ СОЕДИНЕНИЕ (ВЫБРАТЬ
    |			ЗаказыПокупателейОстатки.ЗаказПокупателя КАК ЗаказПокупателя,
    |			ЗаказыПокупателейОстатки.Номенклатура КАК Номенклатура,
    |			СУММА(ЗаказыПокупателейОстатки.КоличествоОстаток) КАК ОстатокПоЗаказу,
    |			СУММА(0) КАК ОстатокВРезерве
    |		ИЗ
    |			РегистрНакопления.ЗаказыПокупателей.Остатки КАК ЗаказыПокупателейОстатки
    |		ГДЕ
    |			ЗаказыПокупателейОстатки.ЗаказПокупателя = &Заказ
    |		
    |		СГРУППИРОВАТЬ ПО
    |			ЗаказыПокупателейОстатки.ЗаказПокупателя,
    |			ЗаказыПокупателейОстатки.Номенклатура
    |		
    |		ОБЪЕДИНИТЬ ВСЕ
    |		
    |		ВЫБРАТЬ
    |			ТоварыВРезервеНаСкладахОстатки.ДокументРезерва,
    |			ТоварыВРезервеНаСкладахОстатки.Номенклатура,
    |			СУММА(0),
    |			СУММА(ТоварыВРезервеНаСкладахОстатки.КоличествоОстаток)
    |		ИЗ
    |			РегистрНакопления.ТоварыВРезервеНаСкладах.Остатки КАК ТоварыВРезервеНаСкладахОстатки
    |		ГДЕ
    |			ТоварыВРезервеНаСкладахОстатки.ДокументРезерва = &Заказ
    |		
    |		СГРУППИРОВАТЬ ПО
    |			ТоварыВРезервеНаСкладахОстатки.Номенклатура,
    |			ТоварыВРезервеНаСкладахОстатки.ДокументРезерва) КАК ВложенныйЗапрос
    |		ПО ЗаказыПокупателейОбороты.ЗаказПокупателя = ВложенныйЗапрос.ЗаказПокупателя
    |			И ЗаказыПокупателейОбороты.Номенклатура = ВложенныйЗапрос.Номенклатура
    |ГДЕ
    |	ЗаказыПокупателейОбороты.ЗаказПокупателя = &Заказ
    |
    |СГРУППИРОВАТЬ ПО
    |	ЗаказыПокупателейОбороты.ЗаказПокупателя,
    |	ЗаказыПокупателейОбороты.Номенклатура");
    
    запрос.УстановитьПараметр("Заказ",заказ);					  
    
    Результат = Запрос.Выполнить();
    тРезервы.Очистить();
    	
    Если Не Результат.Пустой() Тогда
    	Выборка = Результат.Выбрать();
    	Пока Выборка.Следующий() Цикл
    		НоваяСтрока 		= тРезервы.Добавить();
    		НоваяСтрока.Номенклатура 	= Выборка.Номенклатура;
    		НоваяСтрока.КоличествоВЗаказе = Выборка.КоличествоВЗаказе;
    		НоваяСтрока.ОстатокВРезерве 	= Выборка.ОстатокВРезерве;
    		НоваяСтрока.ОстатокКОтгрузке 	= Выборка.ОстатокПоЗаказу;
    	КонецЦикла; 
    КонецЕсли;

    Заполнение таблицы значений, очень быстро работает)))
    КоличествоВЗаказе в 2 раза больше получается

    SrK, 04 Февраля 2010

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

    +65.1

    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
    #include <iostream>
    #include <math.h>
    using namespace std;
    double absolute( double x ) {
         return (( x >= 0.0 ) ? x : x*(-1) );
        }
    double get_cof( double time ) {
         if( time ==1 ) return 1;
         double rettime = ( time + 1 ) / time;
         return rettime;
        }
    double get_disnow( double time, double speed ) {
          double disnow = get_cof( time ) * speed;
          return disnow;
         }
    double get_distance( double time, double speed ) {
         if( time ==1 ) return 20;
         double distance =  get_disnow( time, speed );
         return distance;
        }
    using namespace std;
    int main( int argc, char **argv ) {
         double x = 0.0;
         for( double t = 1.0; t < 10000 ;t+=1 )
             {
               x += get_distance( t, 10.0 );
               x *= get_cof( t );
               if( (absolute( x - (t * 100 ) ) < 5) || t == 6480 )
                {
                    cout << " hallelua  time = " << t << endl;
                    cout << "  Moskitos  =     " << x << " cm;   ";
                    cout << ",  Man       =     " << t * 100 << " cm;   " << endl;
                }
             }
         return 0;
        }

    Даже не знаю, что здесь самое интересное. Просто прочитайте.

    Abrosov, 21 Января 2010

    Комментарии (17)
  10. Pascal / Говнокод #2412

    +144.9

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    function ... : Integer;
    var
      i:integer;
    begin
      Result := 0;
      for i := 1 to ... do
        if bla-bla then
          inc(Result);
      Result := Result;
    end;

    popa, 14 Января 2010

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

    +148.3

    1. 1
    2. 2
    3. 3
    4. 4
    $cnt2 = $db->get_rows("select count(*) from `".TABLE_PRODUCTS."` where `id`='".intval($s_id)."'");
    if ($cnt2[0]['count(*)']) {
         //...
    }

    Это писец.

    aerowave, 09 Ноября 2009

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