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

    +126

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    public static IEnumerable<TItem> GetNextItemFrom<TItem>(IEnumerable<TItem> Collection)
            {
                foreach (var Item in Collection)
                    yield return Item;
            }

    Говногость, 26 Июня 2011

    Комментарии (10)
  2. Java / Говнокод #7060

    +148

    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
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import javax.swing.JFrame;
    public class Main extends JFrame{
        static int a=100;
        BufferedImage offscreen = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
    	static double p1[][]={{-a},{0},{a}};
    	static double p2[][]={{0},{-a},{a}};
    	static double p3[][]={{a},{-a},{a}};
    	static double p4[][]={{a},{a},{a}};
    	static double p5[][]={{-a},{a},{a}};	
    	static double p6[][]={{-a},{0},{-a}};
    	static double p7[][]={{0},{-a},{-a}};
    	static double p8[][]={{a},{-a},{-a}};
    	static double p9[][]={{a},{a},{-a}};
    	static double p10[][]={{-a},{a},{-a}};
    	static double mas[][][]=new double[10][][];
    	
    	public static void main(String[] args) {
    		Main mf=new Main();
    		mf.setVisible(true);
    		mf.setSize(800,800);
    		mf.setDefaultCloseOperation(EXIT_ON_CLOSE);
    		
    		Matrix P1=new Matrix(p1);
    		Matrix P2=new Matrix(p2);
    		Matrix P3=new Matrix(p3);
    		Matrix P4=new Matrix(p4);
    		Matrix P5=new Matrix(p5);
    		Matrix P6=new Matrix(p6);
    		Matrix P7=new Matrix(p7);
    		Matrix P8=new Matrix(p8);
    		Matrix P9=new Matrix(p9);
    		Matrix P10=new Matrix(p10);
    		
    		double a=0;
    		while(true){
    			Matrix ox=new OX(a);
    			Matrix oy=new OY(a);
    			Matrix oz=new OZ(a);
    			Matrix m=ox.multiplication(oy.multiplication(oz));
    			mas[0]=m.multiplication(P1).getData();
    			mas[1]=m.multiplication(P2).getData();	
    			mas[2]=m.multiplication(P3).getData();	
    			mas[3]=m.multiplication(P4).getData();
    			mas[4]=m.multiplication(P5).getData();
    			mas[5]=m.multiplication(P6).getData();	
    			mas[6]=m.multiplication(P7).getData();	
    			mas[7]=m.multiplication(P8).getData();
    			mas[8]=m.multiplication(P9).getData();	
    			mas[9]=m.multiplication(P10).getData();
    			a+=0.06;
    			//a=0;
    			mf.repaint();
    			try {
    				Thread.sleep(100);
    			} catch (InterruptedException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    		}
    	}
       
    	public void paint(Graphics g){
    		super.paint(g);
    		this.display(mas);
    	}
    	
    	public void display(double m[][][]){
    		Graphics g= this.getGraphics();
    		g.setColor(Color.BLACK);
    		for(int i=0;i<m.length;i++){
    			m[i][0][0]+=300;
    			m[i][1][0]+=300;
    		}
    		g.drawLine((int)m[0][0][0],(int)m[0][1][0],(int)m[1][0][0],(int)m[1][1][0]);
    		g.drawLine((int)m[1][0][0],(int)m[1][1][0],(int)m[2][0][0],(int)m[2][1][0]);
    		g.drawLine((int)m[2][0][0],(int)m[2][1][0],(int)m[3][0][0],(int)m[3][1][0]);
    		g.drawLine((int)m[3][0][0],(int)m[3][1][0],(int)m[4][0][0],(int)m[4][1][0]);
    		g.drawLine((int)m[4][0][0],(int)m[4][1][0],(int)m[0][0][0],(int)m[0][1][0]);
    		g.drawLine((int)m[5][0][0],(int)m[5][1][0],(int)m[6][0][0],(int)m[6][1][0]);
    		g.drawLine((int)m[6][0][0],(int)m[6][1][0],(int)m[7][0][0],(int)m[7][1][0]);
    		g.drawLine((int)m[7][0][0],(int)m[7][1][0],(int)m[8][0][0],(int)m[8][1][0]);
    		g.drawLine((int)m[8][0][0],(int)m[8][1][0],(int)m[9][0][0],(int)m[9][1][0]);
    		g.drawLine((int)m[9][0][0],(int)m[9][1][0],(int)m[5][0][0],(int)m[5][1][0]);
    		g.drawLine((int)m[0][0][0],(int)m[0][1][0],(int)m[5][0][0],(int)m[5][1][0]);
    		g.drawLine((int)m[1][0][0],(int)m[1][1][0],(int)m[6][0][0],(int)m[6][1][0]);
    		g.drawLine((int)m[2][0][0],(int)m[2][1][0],(int)m[7][0][0],(int)m[7][1][0]);
    		g.drawLine((int)m[3][0][0],(int)m[3][1][0],(int)m[8][0][0],(int)m[8][1][0]);
    		g.drawLine((int)m[4][0][0],(int)m[4][1][0],(int)m[9][0][0],(int)m[9][1][0]);
    		Graphics g2 =  offscreen.getGraphics();
            g2.setColor(Color.WHITE);
            g2.fillRect(0, 0, getWidth(), getHeight());
            g2.setColor(Color.BLUE);
            g2.fillRect(0, 0, 100, 100);
            g.drawImage(offscreen, 0, 0, null);
    	}
    }

    Говнолаба по предмету "компьютерная графика".
    Задача: нарисовать куб с усеченным углом, повернутый на произвольный угол вокруг трех осей (OX, OY, OZ).
    Вот как эту задачу решает мой однокурсник.
    Вместо того, чтобы использовать одну матрицу поворота, он создает 10 матриц для каждой из 10 точек...
    Впрочем, код лучше расскажет...

    just_nameless, 26 Июня 2011

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

    +179

    1. 1
    2. 2
    public:
      void* getThis(void){return this;};;;;

    Говногость, 26 Июня 2011

    Комментарии (37)
  4. Куча / Говнокод #7058

    +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
    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
    rem ID generator
    :idgen
    set nsmb=36
    set idstr=
    for /l %%i in (1,1,8) do call :rsadd
    echo ID=%idstr%
    exit /b
    
    rem Random symbol adding [0-9a-z]
    :rsadd
    set r=%random%
    set /a c=r-r/nsmb*nsmb
    if %c% lss 10 set idstr=%idstr%%c%
    if %c% == 10 set idstr=%idstr%a
    if %c% == 11 set idstr=%idstr%b
    if %c% == 12 set idstr=%idstr%c
    if %c% == 13 set idstr=%idstr%d
    if %c% == 14 set idstr=%idstr%e
    if %c% == 15 set idstr=%idstr%f
    if %c% == 16 set idstr=%idstr%g
    if %c% == 17 set idstr=%idstr%h
    if %c% == 18 set idstr=%idstr%i
    if %c% == 19 set idstr=%idstr%j
    if %c% == 20 set idstr=%idstr%k
    if %c% == 21 set idstr=%idstr%l
    if %c% == 22 set idstr=%idstr%m
    if %c% == 23 set idstr=%idstr%n
    if %c% == 24 set idstr=%idstr%o
    if %c% == 25 set idstr=%idstr%p
    if %c% == 26 set idstr=%idstr%q
    if %c% == 27 set idstr=%idstr%r
    if %c% == 28 set idstr=%idstr%s
    if %c% == 29 set idstr=%idstr%t
    if %c% == 30 set idstr=%idstr%u
    if %c% == 31 set idstr=%idstr%v
    if %c% == 32 set idstr=%idstr%w
    if %c% == 33 set idstr=%idstr%x
    if %c% == 34 set idstr=%idstr%y
    if %c% == 35 set idstr=%idstr%z
    exit /b

    Windows shell

    Собственноручно написанное. Нашел, разбирая старые скрипты.

    vp2729, 25 Июня 2011

    Комментарии (4)
  5. Си / Говнокод #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)
  6. 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)
  7. Си / Говнокод #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)
  8. 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)
  9. C++ / Говнокод #7053

    +158

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

    =)

    MoN, 25 Июня 2011

    Комментарии (11)
  10. Си / Говнокод #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)