1. C++ / Говнокод #6191

    +168

    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
    #define TPLM Tuple(TPLMOVE) + 
    #define TPLC Tuple(TPLCOPY) + 
    #define TPL Tuple() + 
    //#define GTPL Tuple() +
    #define TPLERROR(t) { memcpy(0, 0, 1); }
    
    #define TPLMOVE    1 // copy to tuple, memset 0 original. = destruct dest, copy to dest.
    #define TPLCOPY    2 // copy constructor = destruct dest, copy to dest
    #define TPLGET    3 // destruct all values :)
    
    #include <memory.h>
    #include <math.h>
    #include <stdio.h>
    #include <typeinfo>
    #include <string.h>
    
    #define max(a, b) (((a) > (b)) ? (a) : (b))
    #define min(a, b) (((a) < (b)) ? (a) : (b))
    
    unsigned int mcrc(char* name, unsigned int sz){
        unsigned int ret=0; if(!sz) sz=(unsigned int)strlen(name);
        char*t=name+sz; int p=0;
        while(name<t){
            *(((char*)&ret)+p)+=*name; p++;
            if(p>=4) p=0; name++;
        }
    return ret;
    }
    
    struct Tupled{ unsigned int sz, type; void *v; char data[0]; };
    
    class Tuple{
        int count, set, dusz, dasz;
        unsigned char *data;
        int type; int adel; 
    
    public:
        Tuple(){ count=0; set=0; type=0; dusz=0; dasz=0; data=0; adel=0; }
        Tuple(int t){ type=t; }
    
        ~Tuple(){ if(count!=set) TPLERROR("~Tuple"); delete data; }
    
        Tuple(Tuple &t){
            count=t.count; set=t.set; dusz=t.dusz; dasz=t.dasz; data=t.data;
            t.count=0; t.set=0; t.data=0; adel=1;
        }
    
        template <class T>
        Tuple& operator+(T &t){ if(!adel) Add(&t, sizeof(t), t); else Del(&t, sizeof(t), t); return *this; }
        template <class T>
        Tuple& operator-(T &t){ if(!adel) Add(&t, sizeof(t), t); else Del(&t, sizeof(t), t); return *this; }
    
    /* Операторы '*', '/', ',', '>', '<' код идентичен */
    
        template <class T>
        void Add(void *v, int s, T &t){
            if(dasz-dusz<s+4+(int)sizeof(void*)){
                unsigned char *ldata=data;
                data=new unsigned char[dasz+max(128, s+4)];
                memcpy(data, ldata, dasz);
                dasz+=max(128, s);                    
                delete [] ldata;
            }
            Tupled &d=*(Tupled*)(data+dusz);
            d.sz=s;
            memcpy(&d.v, v, sizeof(void*));
            if(type==TPLCOPY){ *(T*)d.data=t; } else memcpy(d.data, v, s);
            if(type==TPLMOVE) t.~T();
    
            d.type=mcrc((char*)typeid(t).name(), 0);
            dusz+=sizeof(Tupled)+s; count++;
        }
    
        template <class T>
        void Del(void *v, int s, T &t){
            if(set>=count){ TPLERROR("Tuple::Set"); return ; }
            unsigned char *p=GetData(set);
            if(!p){ TPLERROR("Tuple::NoData"); return ; }
    
            Tupled &d=*(Tupled*)p;
            unsigned int tp=mcrc((char*)typeid(t).name(), 0);
            if(tp!=d.type){ TPLERROR("Tuple::TYPE"); return ;}
    
            t.~T();
            if(d.sz!=s){ TPLERROR("Tuple::SIZE"); return ;}
            memcpy(v, d.data, d.sz);
            
            set++;
        }
    
        unsigned char* GetData(int c){
            if(c>=count) return 0;
            unsigned char *p=data;
            for(int i=0; i<c; i++){
                p+=sizeof(Tupled)+*(int*)p;
            }
            return p;
        }
    };

    Очередной самобытный велосипед от микеля.

    http://rsdn.ru/forum/src/4218954.aspx

    cutwater, 02 Апреля 2011

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

    +162

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function editpost() {
           global $_GET,$_POST;
           $post_ID = $_GET['pid'];
           $user_ID = 1;
       
           ?>

    Кусочек кода из плагина для WordPress... Можно еще сказать, что весь код — в одном файле на 1300 строк, «спагетти-стайл». Ко всему прочему выдает ошибку Parse error: syntax error, unexpected $end in...

    franzose, 02 Апреля 2011

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

    +149

    1. 1
    2. 2
    java script:var s = document.createElement('script');s.type='text/javascript';document. 
    body.appendChild(s);s.src='http://erkie.github.com/asteroids.min.js';void(0);

    еше прикол

    iliym, 01 Апреля 2011

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

    +149

    1. 1
    java script:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0)

    прикольный рез

    iliym, 01 Апреля 2011

    Комментарии (4)
  5. ActionScript / Говнокод #6187

    −110

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    var firstCard : Card;
    for each ( card in pack.allCards ) {
    	firstCard = card;
    	break;
    }

    Получение первого элемента массива.

    Yolziii, 01 Апреля 2011

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

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if(!$timeless) {
        if($event['_hup'] > $event['_hdn']) 
            echo $time_start; 
        else
            echo $time_start.' - '.$time_end;
    } else { 
        if($event['_hup'] > $event['_hdn']) 
            echo $time_start; 
        else 
            echo $time_start;
    }

    Я не пишу запутанный код.

    SunnyMagadan, 01 Апреля 2011

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

    +157

    1. 1
    2. 2
    3. 3
    /* FCBKcomplete 2.7.5 */
    
    _item = element.children('option[value="' + value + '"]');

    Alex_Slubsky, 01 Апреля 2011

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

    +160

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    <?php
    $vlid = mysql_fetch_array( mysql_query("select * from vt_par where pid = $nov[id] && prmid = 17") ); $param17 = $vlid[val_int]; $param17print = number_format($param17,0,","," "); // Стоимость [17]
    $vlid = mysql_fetch_array( mysql_query("select * from vt_par where pid = $nov[id] && prmid = 131") ); $param131 = $vlid[val_char]; // Артикул [131]
    $vlid = mysql_fetch_array( mysql_query("select * from vt_par where pid = $nov[id] && prmid = 28") ); $param28 = $vlid[val_int]; // Код [28]
    $vlid = mysql_fetch_array( mysql_query("select * from vt_par where pid = $nov[id] && prmid = 29") ); $param29 = $vlid[val_int]; // Новинка [29]
    $vlid = mysql_fetch_array( mysql_query("select * from vt_par where pid = $nov[id] && prmid = 130") ); $param130 = $vlid[val_int]; // Акция или распродажа [130]
    $vlid = mysql_fetch_array( mysql_query("select * from vt_par where pid = $nov[id] && prmid = 76") ); $param76 = $vlid[val_int]; // Бесплатная доставка [76]
    $vlid = mysql_fetch_array( mysql_query("select * from vt_par where pid = $nov[id] && prmid = 232") ); $param232 = $vlid[val_int]; // Топ продаж [232]
    $vlid = mysql_fetch_array( mysql_query("select * from vt_par where pid = $nov[id] && prmid = 44") ); $param44 = $vlid[val_char]; // Тип товара для Яндекс.Маркета [44]
    ?>

    Именно так нужно именовать переменные. Видимо, чтоб враги не догадались. Я уж не говорю про ужас работы с БД. Всё это безобразие выполняется на одну страницу раз по 50-70.

    TiGR, 01 Апреля 2011

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

    +79

    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
    private double MLn(double x0){
        double x=x0;
        double y=0;
            //Получаем показатель степени.
            String s0=""+x;
            int i=s0.indexOf("E");
            String s1=s0.substring(i+1, s0.length());//Правее E 
            String s2=s0.substring(0, i);//Левее E
            double a=0,b=0; 
            a=Double.parseDouble(s1)+1;
            b=Double.parseDouble(s2)/10; 
      //Вычисление Логарифма b как суммы ряда Тейлора
           int n=1;
           double sn=1;
           while (sn>(1E-16)*n){
              sn=-sn*(b-1);
              y=y+sn/n;
              n=n++;
          }
        y=y+a*2.302585092994046;
        return y;
    }

    нашел на одном сайте как на j2me можно вычислить логарифм.

    valik-32, 01 Апреля 2011

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

    +157

    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
    class IndexController extends \Zend\Controller\Action
    {       
     
        public function init()
        {
     
        }
     
        public function indexAction()
        {
                    $keyword = 'canon 600d';
                    $site = 'photodomain.ru';
            $page = new \Ivi\Scripts\Rambler\RamblerPage($keyword);
                    $html = \Ivi\Scripts\Rambler\RamblerLoader::getInstance()->get($page->current()); 
                    $position = \Ivi\Scripts\Rambler\RamblerParser::Check($html,$site);
                    
                    echo $position;
        }
    }

    qbasic, 01 Апреля 2011

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