1. Си / Говнокод #7057

    +137

    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
    int    bufImin[32]={ 4000,  4000,  4000,  4000,  4000,  4000,  4000,  4000,  4000,  4000,  4000,  4000,  4000,  4000,  4000,  4000};
    int    bufImax[32]={20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000};
    double bufPmin[32]={    0,     0,     0,     0,     0,     0,     0,     0,     0,   315,     0,     0,     0,     0,     0,     0};
    double bufPmax[32]={    6,    10,     1,    10,    40,    10 ,   10,    10,    10,  -315,     0,     0,   100,   100,    10,  1000};
    
    /*...*/
    bufPmin[9]=(double)CR1_Lb1_4mA*5-500.0;
    bufPmax[9]=(double)CR1_Lb1_20mA*5-500.0;
    Presh[9]=CurrentToPresh(I_9, bufImax[9],bufImin[9],bufPmax[9],bufPmin[9]);
    
    bufPmin[10]=(double)CR1_Lb2_4mA*5-500.0;
    bufPmax[10]=(double)CR1_Lb2_20mA*5-500.0;
    Presh[10]=CurrentToPresh(I_10, bufImax[10],bufImin[10],bufPmax[10],bufPmin[10]);
    
    /*...*/
    
    bufPmax[10]=(double)CR5_Tg_max;
    Presh[15]==CurrentToPresh(I_15, bufImax[15],bufImin[15],bufPmax[15],bufPmin[15]);

    Разгребаю г*вно от предыдущего программиста...
    - зачем массивы на 32 элемента, если их всегда 16.
    - зачем массивы с одинаковыми данными.
    - зачем инициализировать массив числами, которые никогда не используются.
    - массивы используются только для передачи значений в функцию.
    - 17 строка. Это ж надо спутать индекс; как незаметно.
    - 18 строка. :) ==3
    - "Presh" отнюдь не значит "precious", как подумали б американцы. Это Pressure по своей сути.

    MereNonsense, 25 Июня 2011

    Комментарии (16)
  2. PHP / Говнокод #7056

    +147

    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
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    $url_view = 'pages/news';// страница вида
    			$data = array(); //Создаем массив дата
    			// сегменты урл
    			$data['segment_1'] = $filter_1;
    			$data['segment_2'] = $filter_2; 
    			$limit = 10; // вывод новостей
    			$num_links = 4;  // кол-во страниц во круг текущей
    			$uri_segment = 5; // сегмент ссылки
    			$offset = ($page - 1) * $limit; // переводим page в offset
    			if(!is_numeric($filter_2)) {$filter_2 = iconv('utf-8', 'windows-1251', urldecode($filter_2));}	
    				
    			$base_url = '/page/filter/'.$filter_1.'/'.$filter_2.'/'; 
    			
    			// разбираем 1 фильтр для проверки
    			$filter_global = explode("_",$filter_1);
    			if($filter_global[0] == 'user') {$filter_1 = 'user'; $user_id = (int)$filter_global[1];}
    		
    			// описание каждого элемента фильтра
    			switch($filter_1) {
    				
    				case 'date':
    					$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
    					$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
    				break;
    				
    				case 'date_day':
    					$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
    					$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
    				break;
    				
    				case 'date_month':
    					$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
    					$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);	
    				break;
    				
    				case 'date_year':
    					$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
    					$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
    				break;
    				
    				case 'rating':
    					$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
    					$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
    				break;
    				
    				case 'random':
    					$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
    					$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
    				break;
    				
    				case 'moderation':
    					$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
    					$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
    				break;
    				
    				case 'user':
    					$filter_1 = $filter_global[0].'_'.$filter_global[1]; // собираем обратно
    					$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
    					$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
    				break;
    				
    				default:
    					$total = $this->paginations->count_posts_filter('news',$filter_1,$filter_2);
    					$data['materials'] = $this->paginations->list_posts_filter($limit, $offset, 'news', $filter_1, $filter_2);
    				break;
    				
    			}
    
    		$this->auxiliary->pagination($base_url,$uri_segment,$num_links,$total,$limit);//настройки пагинации
    		$this->auxiliary->general_view($data,'title_best','description_best','keywords_best',$url_view); // общий вид

    проверьте на наличие гавно кода .

    Контроллер фильтра выдачи в Codeigniter

    nepster, 25 Июня 2011

    Комментарии (19)
  3. Си / Говнокод #7055

    +101

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    double k;
    
    if(deviceType == "firstType"){
      for(int i = 0;i < 100000;i++)
        k = pow(2,10);
    }
    else if(deviceType == "secondType"){
      for(int i = 0;i < 700000;i++)
        k = pow(2,10);
    }

    Думаю этот даунизм поймут все. Маразм крепчал)

    eclipse, 25 Июня 2011

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

    +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
    ModuleManagerImpl::ModuleManagerImpl()
    {
    	ModuleManager::loadPlugins();
    	Config config = ProfileDialog::profilesInfo();
    #ifdef QUTIM_SINGLE_PROFILE
    	bool singleProfile = true;
    #else
    	bool singleProfile = false;
    #endif
    	singleProfile = config.value("singleProfile", singleProfile);
    	if (singleProfile) {
    		if (!config.hasChildGroup("profile")) {
    			QWidget *wizard = new ProfileCreationWizard(this, QString(), QString(), true);
    			wizard->setAttribute(Qt::WA_DeleteOnClose, true);
    			wizard->setAttribute(Qt::WA_QuitOnClose, false);
    			SystemIntegration::show(wizard);
    		} else {
    			config.beginGroup("profile");
    			if(ProfileDialog::acceptProfileInfo(config, QString())) {
    				QTimer::singleShot(0, this, SLOT(initExtensions()));
    			} else {
    				qWarning("Can't login");
    				QDialog *dialog = new ProfileDialog(config, this);
    				SystemIntegration::show(dialog);
    			}
    			config.endGroup();
    		}
    	} else {
    		QDialog *dialog = new ProfileDialog(config, this);
    		SystemIntegration::show(dialog);
    	}
    }

    не знаю как вам, а мне не нравится объявление singleProfile.
    qutim/core/src/modulemanagerimpl.cpp

    POPSuL, 25 Июня 2011

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

    +158

    1. 1
    2. 2
    3. 3
    for (int i = 0; i < n; i++)
       if (i == n + 2) 
          //действия

    =)

    MoN, 25 Июня 2011

    Комментарии (11)
  6. Си / Говнокод #7052

    +140

    1. 1
    return (a >= factor || (a == factor && (c & 1) == 1)) ? 1 : 0;

    https://github.com/mono/mono/blob/master/mono/metadata/decimal.c

    carsten, 25 Июня 2011

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

    +147

    1. 1
    dirname(__FILE__)

    peinguin, 25 Июня 2011

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

    +135

    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
    (+ 3 5)
    (* 5 6 7)
    (kupitj bulochnaja baton)
    
    Можно записать выражения и посложнее:
    (kupitj bulochnaja baton (+ 2 1))
    «Купи в булочной батоны: два плюс ещё один». Просто, не правда ли? Давайте двигаться дальше.
    
    
    (define (privet imja)
      (display "Privet ")
      (display imja)
      (display "!")
      (newline))
    (define (polzovatel)
      (write "Predstavtes:")
      (read))
    (privet (polzovatel))

    Нашел этот пиздец в Введение в язык Scheme для школьников, сначала подумал что автор таким образом заставляет работать мозг школьника(пища все таки) но нет подобное продолжается. К сожалению полной версии "учебника" не имею надеюсь подобное затрагивает только вступление и дальше будет лучше..
    З.ы думаю первый говнокод на Scheme....(:

    Epik, 25 Июня 2011

    Комментарии (15)
  9. JavaScript / Говнокод #7049

    +159

    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
    jQuery("select[id='select1']").change(
    			function () 
    			{
    				var city_id = jQuery(this).attr("value");
    				jQuery("select[id='select_hotel']").html('<option>Выберите категорию</option>');
    				jQuery("select[name='room']").html('<option>Выберите категорию и отель</option>');
    				
    				jQuery("select[id='select_5']").change(
    					function () 
    					{
    						....................................
    					}
    				);			
    			}
    		);

    обратите внимание на то, как селекторы объектов написаны.. автор вместо "#select1" пишет "select[id='select1']" зачем это делать непонятно.
    наговнокодено на сайте el-tour.com

    magistr_bender, 24 Июня 2011

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

    +162

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    setGeometry((int)(QApplication::desktop()->width() -
    (QApplication::desktop()->width() -
      (QApplication::desktop()->width() / 2)) * 1.5) / 2,
      (int)(QApplication::desktop()->height() -
    (QApplication::desktop()->height() -
      (QApplication::desktop()->height() / 2)) * 1.5) / 2,
      (int)((QApplication::desktop()->width() -
    (QApplication::desktop()->width() / 2)) * 1.5),
      (int)((QApplication::desktop()->height() -
    (QApplication::desktop()->height() / 2)) * 1.5));

    Center app window!

    Aleskey, 24 Июня 2011

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