1. PHP / Говнокод #11889

    +55

    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
    function GetNumberOfLinks ($cat){ 
      $queue[] = intval($cat);
      $query = "select count(*) from #__jxlspp_prices  where ( 0!=0";
       while (list($key, $cat) = each($queue)) {
         $query .= " or catid = $cat";
       }
     $query = $query . " ) and published=1";
    	$database->setQuery($query);//это от Джумлы
      $result = $database->query();//и это от Джумлы
    	$val = mysql_fetch_row($result);//а это с бодуна
      return $val[0];
    
    }

    Сижу, скучаю, ковыряю очередной говносайт и, вдруг!
    Аж от души отлегло.

    virtual_cia, 07 Октября 2012

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

    −119

    1. 1
    select count(*) from jxlspp_prices  where 0!=0  or catid = 2	}

    А вот так его!

    virtual_cia, 07 Октября 2012

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

    +38

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    #include <iostream>
     
    using namespace std;
     
    class Program
    {
        public:
            friend int main()
            {
                    return 0;
            }
    };

    Мой знакомый говорит, что его компилятор поддерживает Java\C#-нотацию точки входа таким образом. И ещё он говорит, что так должно компилироваться по стандарту.

    LispGovno, 07 Октября 2012

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

    +33

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    class Chatter : public QListBoxItem {
        [...]
        private:
            static ChatterRef *chatters[MAX_NUM_CHATTERS];
            [...]
            friend int main(int, char *argv[]);	// to destroy chatters[]
    };

    Сам проект: http://www.qtchat.org/qtchat/
    Пример дается в этой книге: http://books.google.ru/books?id=8lYbNfsAVT4C&dq=qtchat&source=g bs_navlinks_s как пример friend-функций

    myaut, 07 Октября 2012

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

    +36

    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
    gp_terrains.at(0)->draw();
    		//it took me only 50 lines of spaghetti code to implement the spiral layout					
    		//direction 1 for +x, 2 for +y, 3: -x, 0: -y
    		int repetition_count = 1;
    		int i = 1;
    		int direction = 0;
    		while(i < (int)gp_terrains.size()) {
    			for (int k = 0; k < 2; k++) {
    				direction = (++direction) % 4;
    				for (int j = 0; j < repetition_count; j++) {
    					switch(direction) {
    						case 1: {
    							glTranslated(512, 0, 0);
    							gp_terrains.at(i)->draw();
    							
    							break;
    						}
    						case 2: {
    							glTranslated(0, 512, 0);
    							gp_terrains.at(i)->draw();
    							
    							break;
    						}
    						case 3: {
    							glTranslated(-512, 0, 0);
    							gp_terrains.at(i)->draw();
    							
    							break;
    						}
    						case 0: {
    							glTranslated(0, -512, 0);
    							gp_terrains.at(i)->draw();
    							
    							break;
    						}
    					}	
    					if (++i >= (int)gp_terrains.size())
    						break;
    				}
    				if (i >= (int)gp_terrains.size())
    						break;
    			}
    			if (i >= (int)gp_terrains.size())
    					break;
    			repetition_count++;

    catcall, 07 Октября 2012

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

    −98

    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
    -(UIImage*) getImageForDigit:(int)value
    {
    	UIImage *img = nil;
    	
    	switch (value)
    	{
    		case -1:
    		{
    			img = [UIImage imageNamed:@"beat_0_off.png"];
    			break;
    		}
    		case 0:
    		{
    			img = [UIImage imageNamed:@"beat_0.png"];
    			break;
    		}
    		case 1:
    		{
    			img = [UIImage imageNamed:@"beat_1.png"];
    			break;
    		}
    		case 2:
    		{
    			img = [UIImage imageNamed:@"beat_2.png"];
    			break;
    		}
    		case 3:
    		{
    			img = [UIImage imageNamed:@"beat_3.png"];
    			break;
    		}
    		case 4:
    		{
    			img = [UIImage imageNamed:@"beat_4.png"];
    			break;
    		}
    		case 5:
    		{
    			img = [UIImage imageNamed:@"beat_5.png"];
    			break;
    		}
    		case 6:
    		{
    			img = [UIImage imageNamed:@"beat_6.png"];
    			break;
    		}
    		case 7:
    		{
    			img = [UIImage imageNamed:@"beat_7.png"];
    			break;
    		}
    		case 8:
    		{
    			img = [UIImage imageNamed:@"beat_8.png"];
    			break;
    		}
    		case 9:
    		{
    			img = [UIImage imageNamed:@"beat_9.png"];
    			break;
    		}
    		default:
    		{
    			break;
    		}
    	}
    	
    	return img;
    }

    Ученица отрыла простановку цифр на "кагбэ жидкокристаллический" дисплей.

    QuickNick, 06 Октября 2012

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

    +20

    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
    D:\Sources\jimbot_at_cpp>make -f Makefile.win clean-full
    rm -f *.o lib.a dist/jimbot.exe
    
    D:\Sources\jimbot_at_cpp>make -f Makefile.win lib
    gcc -c sqlite3.c -pipe -O2 -g1 DSQLITE_THREADSAFE=1
    gcc.exe: error: DSQLITE_THREADSAFE=1: No such file or directory
    make: *** [lib] Error 1
    
    D:\Sources\jimbot_at_cpp>make -f Makefile.win
    g++ -c *.cpp -std=c++0x -O2 -g1 -pipe -Wno-deprecated -Wno-write-strings -Wno-de
    precated-declarations  -DDEBUG -DEASTER -DTESTER
    g++  -o dist/jimbot -pipe *.o -O2 -g1 lib.a -lpthread -lgnutls -lwsock32 -ladvap
    i32 -lcrypt32 -lsecur32 -ldnsapi -liconv
    g++.exe: error: lib.a: No such file or directory
    make: *** [all] Error 1
    
    D:\Sources\jimbot_at_cpp>

    JavaCoder, 06 Октября 2012

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

    +134

    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
    // histogram_data.c   550 Kb
    int n_records = 100000;
    unsigned char data[] = {
      215, 100, 200, 204, 233, 50 , 85 , 196, 71 , 141, 122, 160, 93 , 131, 243, 234, 162, 183, 36 , 155, 
      4  , 62 , 35 , 205, 40 , 102, 33 , 27 , 255, 55 , 131, 214, 156, 75 , 163, 134, 126, 249, 74 , 197, 
      134, 197, 102, 228, 72 , 90 , 206, 235, 17 , 243, 134, 22 , 49 , 169, 227, 89 , 16 , 5  , 117, 16 , 
      60 , 248, 230, 217, 68 , 138, 96 , 194, 131, 170, 136, 10 , 112, 238, 238, 184, 72 , 189, 163, 90 , 
      176, 42 , 112, 225, 212, 84 , 58 , 228, 89 , 175, 244, 150, 168, 219, 112, 236, 101, 208, 175, 233, 
      123, 55 , 243, 235, 37 , 225, 164, 110, 158, 71 , 201, 78 , 114, 57 , 48 , 70 , 142, 106, 43 , 232, 
      26 , 32 , 126, 194, 252, 239, 175, 98 , 191, 94 , 75 , 59 , 149, 62 , 39 , 187, 32 , 203, 42 , 190, 
      19 , 243, 13 , 133, 45 , 61 , 204, 187, 168, 247, 163, 194, 23 , 34 , 133, 20 , 17 , 52 , 118, 209, 
      146, 193, 13 , 40 , 255, 52 , 227, 32 , 255, 13 , 222, 18 , 1  , 236, 152, 46 , 41 , 100, 233, 209, 
      91 , 141, 148, 115, 175, 25 , 135, 193, 77 , 254, 147, 224, 191, 161, 9  , 191, 213, 236, 223, 212, 
      250, 190, 231, 251, 170, 127, 41 , 212, 227, 19 , 166, 63 , 161, 58 , 179, 81 , 84 , 59 , 18 , 162, 
      57 , 166, 130, 248, 71 , 139, 184, 28 , 120, 151, 241, 115, 86 , 217, 111, 0  , 88 , 153, 213, 59 , 
      172, 123, 123, 78 , 182, 46 , 159, 10 , 105, 178, 172, 163, 88 , 47 , 155, 160, 187, 84 , 189, 51 , 
      235, 175, 167, 65 , 136, 22 , 66 , 224, 175, 23 , 28 , 92 , 147, 151, 170, 73 , 198, 73 , 84 , 48 , 
      251, 0  , 211, 84 , 48 , 111, 245, 235, 195, 178, 31 , 175, 98 , 198, 241, 234, 220, 52 , 203, 140, 
     // over 5000 строк подобного
    
    int expected_results[] = {
        404,   389,   376,   394,   376,   342,   364,   364,   383,   396, 
        412,   409,   394,   409,   405,   383,   379,   401,   377,   400, 
        383,   410,   386,   383,   418,   416,   406,   349,   390,   388, 
        393,   372,   386,   386,   400,   384,   404,   355,   400,   361, 
        398,   371,   389,   383,   406,   414,   364,   389,   418,   391, 
        404,   396,   390,   397,   375,   389,   387,   392,   368,   430, 
        407,   387,   380,   380,   383,   352,   386,   413,   435,   413, 
        358,   453,   436,   409,   419,   393,   423,   398,   407,   372, 
        399,   353,   370,   389,   399,   376,   395,   439,   412,   379, 
        404,   374,   392,   393,   366,   377,   374,   395,   402,   380, 
        422,   407,   379,   398,   376,   410,   376,   392,   374,   409, 
        415,   382,   411,   398,   379,   385,   383,   374,   421,   371, 
        359,   403,   373,   396,   365,   365,   382,   383,   352,   399, 
        367,   439,   401,   418,   407,   403,   392,   373,   385,   374, 
        389,   365,   414,   415,   360,   384,   387,   381,   400,   410, 
        400,   406,   385,   395,   373,   381,   419,   362,   383,   399, 
        424,   379,   394,   401,   371,   426,   376,   375,   383,   370, 
        405,   402,   372,   404,   364,   419,   390,   376,   368,   405, 
        393,   386,   402,   393,   420,   388,   380,   364,   412,   383, 
        411,   357,   412,   377,   346,   389,   380,   371,   393,   408, 
        386,   425,   392,   338,   373,   382,   380,   365,   379,   394, 
        379,   378,   415,   394,   352,   378,   417,   403,   407,   388, 
        390,   433,   352,   394,   398,   407,   397,   409,   419,   378, 
        387,   359,   406,   384,   403,   385,   411,   418,   408,   371, 
        384,   386,   392,   422,   377,   399,   364,   381,   362,   379, 
        393,   383,   381,   400,   434,   404};
    
    // example_vectors.c - 1.8 Mb
    int vector_size=100000;
    int vector_a[] = {
      215 , 100 , 200 , 204 , 233 , 50  , 85  , 196 , 71  , 141 , 122 , 160 , 93  , 131 , 243 , 234 , 162 , 183 , 36  , 155 , 
      4   , 62  , 35  , 205 , 40  , 102 , 33  , 27  , 255 , 55  , 131 , 214 , 156 , 75  , 163 , 134 , 126 , 249 , 74  , 197 , 
      134 , 197 , 102 , 228 , 72  , 90  , 206 , 235 , 17  , 243 , 134 , 22  , 49  , 169 , 227 , 89  , 16  , 5   , 117 , 16  , 
      60  , 248 , 230 , 217 , 68  , 138 , 96  , 194 , 131 , 170 , 136 , 10  , 112 , 238 , 238 , 184 , 72  , 189 , 163 , 90  , 
      176 , 42  , 112 , 225 , 212 , 84  , 58  , 228 , 89  , 175 , 244 , 150 , 168 , 219 , 112 , 236 , 101 , 208 , 175 , 233 , 
      123 , 55  , 243 , 235 , 37  , 225 , 164 , 110 , 158 , 71  , 201 , 78  , 114 , 57  , 48  , 70  , 142 , 106 , 43  , 232 , 
      26  , 32  , 126 , 194 , 252 , 239 , 175 , 98  , 191 , 94  , 75  , 59  , 149 , 62  , 39  , 187 , 32  , 203 , 42  , 190 , 
      19  , 243 , 13  , 133 , 45  , 61  , 204 , 187 , 168 , 247 , 163 , 194 , 23  , 34  , 133 , 20  , 17  , 52  , 118 , 209 , 
      146 , 193 , 13  , 40  , 255 , 52  , 227 , 32  , 255 , 13  , 222 , 18  , 1   , 236 , 152 , 46  , 41  , 100 , 233 , 209 , 
      91  , 141 , 148 , 115 , 175 , 25  , 135 , 193 , 77  , 254 , 147 , 224 , 191 , 161 , 9   , 191 , 213 , 236 , 223 , 212 , 
      250 , 190 , 231 , 251 , 170 , 127 , 41  , 212 , 227 , 19  , 166 , 63  , 161 , 58  , 179 , 81  , 84  , 59  , 18  , 162 , 
      57  , 166 , 130 , 248 , 71  , 139 , 184 , 28  , 120 , 151 , 241 , 115 , 86  , 217 , 111 , 0   , 88  , 153 , 213 , 59  , 
      172 , 123 , 123 , 78  , 182 , 46  , 159 , 10  , 105 , 178 , 172 , 163 , 88  , 47  , 155 , 160 , 187 , 84  , 189 , 51  , 
      235 , 175 , 167 , 65  , 136 , 22  , 66  , 224 , 175 , 23  , 28  , 92  , 147 , 151 , 170 , 73  , 198 , 73  , 84  , 48  , 
    
    // over 15000 cтрок

    - Сударь, вы изволили принять наркотических средств?
    - Чего?
    - Ты что, сука, упоротый?!

    denis90, 06 Октября 2012

    Комментарии (84)
  9. Python / Говнокод #11880

    −94

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    def __call__(self, *args, **kw):
        # ...
        if args and len(args) > 1 and args[0] is args[1][0]:
            # fml...
            temp = list(args)
            temp.pop(1)
            args = tuple(temp)
        return self._execute(*args, **kw)

    Быль про архитектуру.

    wvxvw, 06 Октября 2012

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

    +29

    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
    template <class Monad>
       struct XMapM {
          template <class F, class M> struct Sig : FunType<F,M,
             typename RT<typename ::fcpp::BindM<Monad>::Type,M,typename LEType<
                LAM<LV<1>,CALL<typename ::fcpp::UnitM<Monad>::Type,
                CALL<F,LV<1> > > > >::Type>::ResultType> {};
          template <class F, class M>
          typename Sig<F,M>::ResultType
          operator()( const F& f, const M& m ) const {
             LambdaVar<1> A;
             return bindM<Monad>()( m, lambda(A)[ unitM<Monad>()[f[A]] ] );
          }
       };

    Хаскель не нужен.

    serpinski, 05 Октября 2012

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