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

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    foreach ($aa as $key => $value) {
                $aa[$key][2] = str_replace(',', '.', $aa[$key][2]);
                $aa[$key][3] = str_replace(',', '.', $aa[$key][3]);
                $aa[$key][4] = str_replace(',', '.', $aa[$key][4]);
            }

    jf4ever, 18 Ноября 2011

    Комментарии (7)
  3. Куча / Говнокод #8517

    +140

    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
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>По колено в коде —  Говнокод.ру</title>
        <meta name="keywords" content="говнокод, смешной код, быдлокод, быдлокодеры, индусы, для программистов, про программистов, индусский код, записки программиста, говно, говнокод на php, mysql, perl" />
        <meta name="description" content="Сборник говнокода на различных языках программирования" />
        <meta property="og:image" content="http://govnokod.ru/images/brand.gif" />
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
        <link rel="icon" href="/animated_favicon.gif" type="image/gif" />
        <link rel="stylesheet" href="/css/style.css?v=4" media="all" type="text/css" />
        <!--[if lte IE 7]><link href="/css/ie.css" rel="stylesheet" type="text/css"><![endif]-->
        <link title="rss govnokod.ru" type="application/rss+xml" rel="alternate" href="http://govnokod.ru/rss"/>
        <link rel="stylesheet" type="text/css" href="/media/b5aabef57bd7c3fa62379caa0e483deb.css?files=jshighlight/govnokod.css" />
        <script type="text/javascript">
        //<!--
        var SITE_PATH = ''; var SITE_LANG = '';
        //-->
        </script>
        <script type="text/javascript" src="/media/ddd20ce56acf1d9ebadd126322495087.js?files=jquery.js,jquery.scrollTo.js,govnokod.js,jshighlight/highlight.pack.js&v=4"></script>
    </head>

    Привлекает внимание поисковиков(04).

    ReallyBugMeNot2, 14 Ноября 2011

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

    +80

    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
    public static java.util.Date getPreviousMonth () throws ParseException {
            Date currentDate = new Date(System.currentTimeMillis());
            Calendar currentCalendar = Calendar.getInstance();
            currentCalendar.setTimeInMillis(currentDate.getTime());
            
            SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
            //currentCalendar.set(Calendar.MONTH, currentCalendar.get(Calendar.MONTH) - 1);
            currentCalendar.set(Calendar.DAY_OF_MONTH, currentCalendar.get(Calendar.DAY_OF_MONTH) - 30);
            //currentCalendar.set(Calendar.DATE, currentCalendar.getActualMinimum(Calendar.DAY_OF_MONTH));
            format.format(currentCalendar.getTime());
            java.util.Date resultDate = null;
            resultDate = format.parse(format.format(currentCalendar.getTime()));
            return resultDate;
        }

    Занимаюсь рефакторингом. Особо радует предпоследняя строчка.

    MAK, 11 Ноября 2011

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

    +121

    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
    private void textBox1_TextChanged(object sender, EventArgs e)
    {
    	if ((textBox1.Text + textBox2.Text).Length + 1 > 255)
    	{
    		textBox1.BackColor = Color.LightPink;
    		textBox2.BackColor = Color.LightPink;
    	}
    	else
    	{
    		textBox1.BackColor = Color.White;
    		textBox2.BackColor = Color.White;
    	}
    
    	if ((textBox3.Text + textBox6.Text).Length + 1 > 255)
    	{
    		textBox3.BackColor = Color.LightPink;
    		textBox6.BackColor = Color.LightPink;
    	}
    	else
    	{
    		textBox3.BackColor = Color.White;
    		textBox6.BackColor = Color.White;
    	}
    }
    
    private void bntSave_Click(object sender, EventArgs e)
    {
    	if (textBox1.BackColor == Color.LightPink)
    	{
    		MessageBox.Show("Длинна полей От и Адрес в сумме не должна превышать 255");
    		return;
    	}
    	if (textBox3.BackColor == Color.LightPink)
    	{
    		MessageBox.Show("Длинна полей Кому и Адрес в сумме не должна превышать 255");
    		return;
    	}
    
    	Properties.Settings.Default.Save();
    	Navigator.Navigate(new ConfigMenuPage());
    }

    ТЗ: "Суммарная длина полей X и Y не должна превышать 255 символов"
    Решение шедеврально как по вычислению длинны суммы строк, так и по цветовой идентификации :)

    ddv_demon, 10 Ноября 2011

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public function addOffer($type='vendor.model', $values) {
        switch ($type) {
          case 'vendor.model': $offer = new yml_type_vendor_model(); break;
          }
        // Заполняем значениями
        $offer->setValues($values);
       ......

    jonnywalker, 10 Ноября 2011

    Комментарии (7)
  7. JavaScript / Говнокод #8465

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    var howMany = 3
    function rndnumber(){
    var randscript = -1
    while (randscript < 0 || randscript > howMany || isNaN(randscript)){
    randscript = parseInt(Math.random()*(howMany+1))
    }
    return randscript
    }

    AjiTae, 09 Ноября 2011

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

    +147

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    class Object 
    { 
      #ifdef EDITOR_MODE 
      wchar[] name; 
      #endif
    
      UINT[] id;  // {21,64,567} 
    public: 
      UINT GetID(){return id[0];}; 
      UINT GetParentID(){return id[1];}; 
    };

    AnimeGovno-_-, 06 Ноября 2011

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

    +162

    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
    /**/
    	TCHAR* szFileType = _T("");
    	int ftype = JGetByte( hContact, "AvatarType", PA_FORMAT_UNKNOWN );
    	if( ftype == PA_FORMAT_UNKNOWN ) {
    		WIN32_FIND_DATA ffd;
    		HANDLE hFind = FindFirstFile( ptszDest, &ffd );
    		if ( hFind != INVALID_HANDLE_VALUE ) {
    			wchar_t* szExt = m_strrchrs( ffd.cFileName, ".\\" );
    			if( szExt ) {
    				if( !_tcsicmp( szExt, _T(".jpg") ) )
    					ftype = PA_FORMAT_JPEG;
    				else if( !_tcsicmp( szExt, _T(".png") ) )
    					ftype = PA_FORMAT_PNG;
    				else if( !_tcsicmp( szExt, _T(".gif") ) )
    					ftype = PA_FORMAT_GIF;
    				else if( !_tcsicmp( szExt, _T(".bmp") ) )
    					ftype = PA_FORMAT_BMP;
    				if( ftype != PA_FORMAT_UNKNOWN )
    					JSetByte( hContact, "AvatarType", ftype );
    			}
    			FindClose( hFind );
    		}
    	}
    	switch( ftype ) {
    		case PA_FORMAT_JPEG: szFileType = _T("jpg");   break;
    		case PA_FORMAT_PNG:  szFileType = _T("png");   break;
    		case PA_FORMAT_GIF:  szFileType = _T("gif");   break;
    		case PA_FORMAT_BMP:  szFileType = _T("bmp");   break;
    	}

    http://infium.googlecode.com/svn/trunk/Jabber/jabber_misc.cpp

    bot-minurast, 03 Ноября 2011

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    //левое меню
    
    $stra=str_replace("/text.php?id=","",$_SERVER['REQUEST_URI']);//узнаём название страницы
    
    $sql2 = "SELECT * FROM `$pref"."left_menu` where `id`='$stra'";

    "Цитата" из самописного движка

    antongorodezkiy, 30 Октября 2011

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

    +162

    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
    //записали значения, от которых отталкиваться будем. Типа первые значения. Почти повторяют столбцы в таблице
    $maxv1=303268.26141;
    $maxv2=0;
    $maxv3=0;
    $maxm1=294798.84277;
    $maxm2=0;
    $maxm3=0;
    $maxq=10067.89169;
    
    //а теперь финт ушами - находим сумму полей в таблице
    $thisres = mysql_db_query($base, "select * from $Tablename[3]", $link);
    while ($thisrow = mysql_fetch_array($thisres)) {
    	$maxv1+=0+(float)$thisrow['v1'];  //самая прекрасная часть
    	$maxv2+=0+(float)$thisrow['v2'];
    	$maxv3+=0+(float)$thisrow['v3'];
    	$maxm1+=0+(float)$thisrow['m_in'];
    	$maxm2+=0+(float)$thisrow['m_out'];
    	$maxm3+=0+(float)$thisrow['m3'];
    	$maxq+=0+(float)$thisrow['q'];
    }
    //и так еще 2 таблицы складываются

    Шедевр выдран из творения моего коллеги. Комментарии мои. Задача - найти разницу по каждому полю между двумя последними записями в таблице и результат записать в другую таблицу.

    zloiia, 30 Октября 2011

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