1. C# / Говнокод #6237

    +132

    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
    /// <summary>
    /// Конвертирование руского текста в английский.
    /// </summary>
    /// <param name="russianText">Русский текст.</param>
    public static string ConvertToEnglish(string russianText)
    {
    	string englishText = russianText.ToLower();
    
    	englishText = englishText.Replace("КПК", "PDA");
    	englishText = englishText.Replace("ПК", "PC");
    	englishText = englishText.Replace("Ач ", "Ah");
    	englishText = englishText.Replace("ПО", "Software");
    	englishText = englishText.Replace("ОС", "OS");
    	.
    	.
    	.
    	//далее еще около 300 подобных замен
    
    	return englishText;
    }

    Изюминка этого говнокода заключается в первой строчке функции.
    Встретил там же где и http://govnokod.ru/6170

    lexx-pnz, 05 Апреля 2011

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

    +160

    1. 1
    std::cout << (valid_flag + prior ? 1 : 0) << " " << valid_flag+1-1 << std::endl;

    Говнокод - загадка. Какой тип у valid_flag?

    seregakabancheg, 05 Апреля 2011

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

    +162

    1. 1
    2. 2
    foreach(split(',', '101,102,150,1351,2135,22153,351,15321,5351,235') as $key => $val)
    	$tmparray[] = $val;

    разбиваем строку в массив )))

    pes, 05 Апреля 2011

    Комментарии (14)
  4. SQL / Говнокод #6234

    −864

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    SELECT COUNT(*) FROM apteka.cache_offers WHERE ORG_ID = '21963' AND `subject_id` IN (35,30052,20262,20263,20001,30488,30776,22099,22044,21982,21938,21823,
    (еще триста чисел),
    26313,26358,26478,23381,27430,26367,26418,23433,23404,23372,23289,23321,23285,23315,23282,23406,23287,
    26356,23429,23263,23349,23399,23356,23291,23346,23351,23250,23198,23194,23319,23238,23296,23259,23167,23268,23130,23052,23119,22430,23146,22315,23069,23083,23
    127,23189,23023,23014,23059,22988,23020,23007,22989,22949,22937,22939,22941,22979,22786,22842,22849,22758,22913,22919,22833,22718,22753,22779,22724,22857,2276
    8,22761,22733,22823,22759,22764,22658,22681,22674,22706,22599,22698,22667,22627,22776,22654,22655,22601,22619,22598,22694,22696,22603,22541,22570,22469,22534,
    22515,22676,22516,22477,22491,22677,22513,22421,22537,22451,22507,22482,22440,22353,22523,22422,22510,22397,22473,22348,22383,22424,22333,22380,22359,22508,22
    486,22456,22330);

    Стандартный запрос. При формировании страницы конструкция встречается многократно (>10 раз)

    deadwire, 05 Апреля 2011

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

    +117

    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
    int massaotves = 0;
                        var result = db.Vesi500.SingleOrDefault(x => x.Id_vesi500 == 10);
                        massaotves = Convert.ToInt32(result.Value_vesi500);
                        int step500 = 0;
                        //int ost1 = summ500 % massaotves;
                        //if (ost1 == 0)
                        //    step500 = summ500 / massaotves;
                        //else
                        //    step500 = (summ500 / massaotves) + 1;
    
                        int ost1 = summ500 % 450;
                        if (ost1 == 0)
                            step500 = summ500 / 450;
                        else
                            step500 = (summ500 / 450) + 1;
                        #endregion
    
                        #region Отвесы и суммы для 200 весов
                        int massaotves200 = 0;
                        var result1 = db.Vesi200.SingleOrDefault(x => x.Id_vesi200 == 9);
                        massaotves200 = Convert.ToInt32(result1.Value_vesi200);
                        int step200 = 0;
                        //int ost2 = summ200 % massaotves200;
                        //if (ost2 == 0)
                        //    step200 = summ200 / massaotves200;
                        //else
                        //    step200 = (summ200 / massaotves200) + 1;
                        
                        int ost2 = summ200 % 180;
                        if (ost2 == 0)
                            step200 = summ200 / 180;
                        else
                            step200 = (summ200 / 180) + 1;
                        #endregion                   
    
    
                        int itog = 0;
                        //if (step200 > step500)
                        //    itog = step200;
                        //else
                        //    itog = step500;
    
                        int test = (summ200 + summ500) / massaotves200;
                        if (test >= step500 && test >= step200)
                            itog = test;
                        else if (step200 > step500)
                            itog = step200;
                        else   
                            itog = step500;
    
                        textBox3.Text = Convert.ToString(itog);
                        vsegootvesov = itog;

    Выполняет расчет необходимых показателей, для запуска технологического процесса

    fxlancer, 05 Апреля 2011

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

    +119

    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
    string[] otgruzka = new string[11] { "Отгрузка компонент 1 Вес 5дк-500", "Отгрузка компонент 2 Вес 5дк-500", "Отгрузка компонент 3 Вес 5дк-500", "Отгрузка компонент 4 Вес 5дк-500", "Отгрузка компонент 5 Вес 5дк-500", "Отгрузка компонент 6 Вес 5дк-500", "Отгрузка компонент 1 Вес 5дк-200", "Отгрузка компонент 2 Вес 5дк-200", "Отгрузка компонент 3 Вес 5дк-200", "Отгрузка компонент 4 Вес 5дк-200", "Отгрузка компонент 5 Вес 5дк-200", };
                        string[] silos = new string[11] { "Силос 1", "Силос 5", "Силос 6", "Силос 7", "Силос 8", "Силос 31-H", "Силос 9", "Силос 11", "Силос 2", "Силос 3", "Силос 4" };
                                           
                        for (int i = 0; i < dataGridView1.RowCount; i++)
                        {
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 1")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[0]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 5")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[1]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 6")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[2]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 7")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[3]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 8")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[4]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 31-H")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[5]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 9")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[6]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 11")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[7]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 2")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[8]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 3")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[9]);
                            if (Convert.ToString(dataGridView1.Rows[i].Cells[5].Value) == "Силос 4")
                                dataGridView1.Rows[i].Cells[3].Value = modbus_master.GetValue(otgruzka[10]);
                        }                    
                        textBox12.Text = Convert.ToString(modbus_master.GetValue("Текущий отвес 5дк-200") + 1);
    
                        if (modbus_master.GetValue("Текущий отвес 5дк-200") > WorkWithArchive.currentOtves200)
                        {
                            WorkWithArchive.WriteArchiveOtves200(modbus_master.GetValue("Текущий отвес 5дк-200"));
                            WorkWithArchive.currentOtves200 = modbus_master.GetValue("Текущий отвес 5дк-200");
                            WorkWithArchive.WriteArchiveKomponent200(dataGridView1);
                            WorkWithArchive.ot200 = true;
                        }

    Программа управления на производстве, взаимодействует с контроллером, получает кучу данных и такую же кучу отправляет.

    fxlancer, 05 Апреля 2011

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

    +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
    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
    public function Showday($id)
    	{
    		//echo $id;exit;
    		if($id==1)
    		{
    		$day ='Monday';
    		}
    		elseif($id==2)
    		{
    		$day ='Tuesday';
    		}
    		elseif($id==3)
    		{
    		$day ='Wednesday';
    		}
    		elseif($id==4)
    		{
    		$day ='Thursday';
    		}
    		elseif($id==5)
    		{
    		$day ='Friday';
    		}
    		
    	    return $day;
    	}	
    	
    	
    	public function Showdayno($id)
    	{
    		//echo $id;exit;
    		if($id=='Monday')
    		{
    		$day ='1';
    		}
    		elseif($id=='Tuesday')
    		{
    		$day ='2';
    		}
    		elseif($id=='Wednesday')
    		{
    		$day ='3';
    		}
    		elseif($id=='Thursday')
    		{
    		$day ='4';
    		}
    		elseif($id=='Friday')
    		{
    		$day ='5';
    		}
    		
    	    return $day;
    	}

    Вот такой код попался в ZF проекте, написанном индусами.

    gerra, 05 Апреля 2011

    Комментарии (5)
  8. Java / Говнокод #6230

    +75

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    String filler = "";
      int tot = text.length();
      int til = 18 - (tot/100);
      for(int i = 0; i < tot; i++)
      {
        if(text.charAt(i) == '\n')
        {
          text = text.substring(0, i) + "<br/>" + text.substring(i+1);
          tot += 3; i += 3;
          til--;
        }
      }

    Продакшн. Форматирование текста - вставка перевода строки.

    a4060276, 05 Апреля 2011

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

    +177

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if(x*x > = 0)
    {
    // какие-то действия
    }
    else
    {
    // какие-то действия
    }

    Код встретил у знакомой студентки :3 Не, ну а в вдруг?

    minuzZ, 05 Апреля 2011

    Комментарии (37)
  10. JavaScript / Говнокод #6228

    +165

    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
    javascript:
    document.write(
    document.getElementsByTagName('body')0].
    getElementsByTagName('div')[0].
    getElementsByTagName('div')[0].
    getElementsByTagName('div')[2].
    getElementsByTagName('div')[1].
    getElementsByTagName('div')[0].
    getElementsByTagName('div')[0].
    getElementsByTagName('table')[0].
    getElementsByTagName('tbody')[0].
    getElementsByTagName('tr')[0].
    getElementsByTagName('td')[0].
    getElementsByTagName('div')[0].
    getElementsByTagName('div')[0].
    getElementsByTagName('div')[0].
    getElementsByTagName('div')[1].
    getElementsByTagName('table')[0].
    getElementsByTagName('tbody')[0].
    getElementsByTagName('tr')[0].
    getElementsByTagName('td')[1].
    getElementsByTagName('div')[0].
    getElementsByTagName('b')[0].
    getElementsByTagName('a')[0].value
    );

    http://javascript.ru/tutorial/dom/search#comment-5934

    Вот как писать надо!

    fuckyounoob, 05 Апреля 2011

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