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

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

    +28

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    const std::string cyrillic = "аАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяЯ";
    
    std::string cyrillic_toupper(std::string s)
    {
       if(cyrillic.find(s) == std::string::npos)
          throw std::runtime_error(std::string("cyrillic_toupper(): ") + "'" + s + "' is not cyrillic char");
    
       return cyrillic.substr(cyrillic.find(s) + 2, 2);
    }

    an0nym, 21 Октября 2012

    Комментарии (36)
  3. C++ / Говнокод #11867

    +28

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    std::string toString(std::function<std::string(T)> f = std::function<std::string(T)>()) {
       std::stringstream ss;
       if(f)
          ss << f(some_value);
       else
          ss << some_value;
       return ss.str();
    }

    an0nym, 03 Октября 2012

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

    +28

    1. 1
    2. 2
    std::size_t _;
    std:size_t __;

    http://ideone.com/Ie1AY

    HaskellGovno, 13 Сентября 2012

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

    +28

    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
    byte* GetBuffer0(bool free = false)
    {
    	static std::auto_ptr<byte> transferBuffer;
    
    	if (free)
    	{
    		delete [] transferBuffer.release();
    	}
    	else
    	{
    		if (!transferBuffer.get())
    		{
    			transferBuffer.reset(new byte[BUFFER_SIZE]);
    		}
    	}
    	return transferBuffer.get();
    }
    
    byte* GetBuffer1(bool free = false)
    {
    	static std::auto_ptr<byte> transferBuffer;
    
    	if (free)
    	{
    		delete [] transferBuffer.release();
    	}
    	else
    	{
    		if (!transferBuffer.get())
    		{
    			transferBuffer.reset(new byte[BUFFER_SIZE]);
    		}
    	}
    	return transferBuffer.get();
    }

    legacy-дебри

    ni3_inv, 14 Августа 2012

    Комментарии (8)
  6. Куча / Говнокод #-11225

    +28

    1. 1
    <br />

    striker, 18 Июня 2012

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

    +28

    1. 1
    2. 2
    3. 3
    function _spb_similar_similar_video_html(&$item, $key) {
      $item = htmlspecialchars($item, ENT_NOQUOTES);
    }

    brainstorm, 29 Марта 2012

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

    +28

    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
    COMMAND command;
    BUFFER Buffer1;
    BUFFER Buffer2;
    ...
    byte NetSend(byte*& data, int& size)
    {
    	byte fErr = NO_ERRORS;
    	char* const Data = (char* const)data;
    
    	if(Data != 0)
    	{
    		if(Data[0] != 0)
    		{
    			Buffer1.writeData(Data,size,NULL);
    			command='Send';
    			byte fErr=net.sendCommand(command,Buffer1);
    		}
    		else 
    		{
    			Buffer2.writeData(Data,size,NULL);
    			command='SendFast';
    			byte fErr=net.sendCommand(command,Buffer2);
    		};
    	}
    	else
    	{
    		byte fErr=SEND_PARAM_ERROR;
    	}
    	
    	return fErr;
    };

    Зачем же автор завёл два Buffer? :D

    Говногость, 19 Августа 2009

    Комментарии (9)
  9. PHP / Говнокод #448

    +28

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $query = "update users set password = '{$cnf['userpass']}', email = '{$cnf['useremail']}' where login = 'root'";
    if (mysql_query($query, $link) === false) {
         throw new Exception(mysql_error($link));
    }
    mysql_close($link);

    удалить)

    guest, 23 Января 2009

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

    +28

    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
    /* 
    пройдя голосование пользователь переходит на такую страничку
    /voted.html?how=bae60998ffe4923b131e3d6e4c19993e&key=
    а ниже обработчик этой страницы
    */
    
    if ($_GET['how'] == md5('bad')) {
      $msg['msg'] = "<h1>You have already voted!</h1>";
      $msg['coupon'] = "Your 5% discount coupon is <font color=red>".$voteSys->getUsedCoupon($_GET['key'])."</font>";
      $msg['coupon_link'] = '<a style="border: red;" href="'.$site_url.'/order.htm?coupon='.$voteSys->getUsedCoupon($_GET['key']).'"><h1>You can use your 5% discount NOW!</h1></a>';
      
    }
    elseif ($_GET['how'] == md5('good')) {
    	if ($voteSys->isValidKeyWithCoupon($_GET['key'])) { 
          $msg['msg'] = " Thank you for completing this questionnaire, <br>you opinion is very important to us!";

    А наших программистов не учили пользоваться СЕССИЯМи !!

    guest, 19 Января 2009

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

    +28

    1. 1
    http://www.xs4all.nl/~weegen/eelis/analogliterals.xhtml

    guest, 18 Января 2009

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