1. Лучший говнокод

    В номинации:
    За время:
  2. PHP / Говнокод #5211

    +37

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    error_log('json_upload(): called');
    error_log('json_upload(): dump $_POST');
    foreach(explode("\n", var_export($_POST, TRUE) ) as $val) error_log('advupload_json_upload() dump: ' . $val);
    error_log('json_upload(): dump $_GET');
    foreach(explode("\n", var_export($_GET, TRUE) ) as $val) error_log('advupload_json_upload() dump: ' . $val);

    отладка аццкого json вызова который вызываецо с клиента для загрузке файла покускам.
    думать было лень. наговнякал :)
    потом tail -f /var/log/apache2/errors.log в консоли и фпирет

    brainstorm, 11 Января 2011

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

    +37

    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
    HWND m_hEdit=::GetWindow(this->m_hWnd,GW_CHILD);
    
      TCHAR ClassName[200];
      while(1&&m_hEdit)
      {
        ::GetClassName(m_hEdit,ClassName,200);
        if((ClassName[0]==_T('E')||ClassName[0]==_T('e'))&&(ClassName[1]==_T('D')||ClassName[1]==_T('d'))
          &&(ClassName[2]==_T('I')||ClassName[2]==_T('i'))&&(ClassName[3]==_T('T')||ClassName[3]==_T('t')))
          break;
    
        m_hEdit=::GetWindow(m_hEdit,GW_HWNDNEXT);
      }
      if (m_hEdit) m_edit.SubclassWindow(m_hEdit);

    Получение hWnd EditBox расположенного внутри ComboBox.

    guest, 22 Мая 2009

    Комментарии (1)
  4. PHP / Говнокод #384

    +36.8

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $attachItems = "<table style=\'font-size : 8pt\' cellspacing = \'0\'><tr>"
    ."<td><img src=\'/js/extjs/resources/images/talentor/ico/files/mov.gif\'>  </td>"
    ."<td>".($justHTML == false ? '<a href=\\\'#\\\''
    .' onclick=\"new Ext.Window({title:\\\''.$rowData['name'].'\\\',resizable:false,maximizable:true,cls:\\\'window\\\',modal: true,width: 417,height : 375     ,html:\\\''.htmlspecialchars(flv('/files/persons/'.$rowData['name'],400,300)).'\\\'}).show();\"'
    ."\'>".$rowData['name']."</a>" : $rowData['name'] )."</td>"
    .(($justHTML == false && $deleteAttach == true) ? "<td>  <img  onclick=\'ERP.INTERVIEW.deleteVideo(\\\"".$rowData['name']."\\\",document.getElementById(\\\"intvideoid\\\").value,".$intId.",".$personId.")\' onmouseover=\' this.src=\\\"/js/extjs/resources/images/talentor/ico/remove_active.gif\\\" \' onmouseout=\'this.src=\\\"/js/extjs/resources/images/talentor/ico/remove.gif\\\" \' src=\'/js/extjs/resources/images/talentor/ico/remove.gif\'></td>" : '')
    ."</tr></table>"
    ."<input type=\'hidden\' id=\'intvideoid\' value=\'".$rowData['id']."\'>";
    if  (!$justHTML && $deleteAttach) $attachItems = "{xtype: 'panel', id: 'intVideo', html: '".$attachItems."'}";

    Нет слов

    guest, 13 Января 2009

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

    +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
    #include <iostream>
    
    class StaticClassData {
      int *pointer, value;
    
    public:
      StaticClassData(): pointer(&value) {}
      
      void add(int i) {
        std::cout << "Hello, this is " << this << std::endl;
        value = i;
        std::cout << "I'm fine" << std::endl;
        *pointer = i;
        std::cout << "You never read this text" << std::endl;
      }
    };
    
    class SomeClass {
      struct StaticConstructor {
        StaticConstructor(){ storage.add(1); }
      };
      
      static StaticConstructor constructor;
      static StaticClassData storage;
    };
    
    SomeClass::StaticConstructor SomeClass::constructor;
    StaticClassData SomeClass::storage;
    
    int main(){}

    Долго думал, с какого хрена программа падает на заполнении static поля в "статическом конструкторе". Поле вроде бы есть, но толку от этого мало.
    http://ideone.com/Ux14ep - из раздела ub.govnokod.ru или как выстрелить себе в ногу до выполнения main.

    1024--, 01 Марта 2014

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

    +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
    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
    #include <iostream>
    #include <cmath> 
    
    struct Point3D
    {
            float x,y,z;
            Point3D () {}
            Point3D (float x, float y, float z) : x(x), y(y), z(z) {}
            Point3D& operator -= (const Point3D& p) { x-=p.x; y-=p.y; z-=p.z; return *this; }
            Point3D operator - (const Point3D& p) const { Point3D p2(*this); return (p2-=p); }
            Point3D& operator *= (const float f) { x*=f; y*=f; z*=f; return *this; }
            Point3D operator * (const float f) const { Point3D p2(*this); return (p2*=f); }
    };
    
    float Dot (const Point3D& p1, const Point3D& p2) { return p1.x*p2.x + p1.y*p2.y + p1.z*p2.z; }
    
    struct Face
    {
            Point3D            n;
            float              nc;
            float Dist (const Point3D& p) const { return Dot(p,n)-nc; }
    };
    
    int show_float(float src)
    {
            union
            {
                    int i;
                    float f;
            } u;
            u.f = src;
            return u.i;
    }
    
    float from_int(int src)
    {
            union
            {
                    int i;
                    float f;
            } u;
            u.i = src;
            return u.f;
    }
    
    template<typename T>
    T& operator<<(T& str, const Point3D& p)
    {
            str << std::hex << "Point3D(from_int(0x" << show_float(p.x) << "), from_int(0x" << show_float(p.y) << "), from_int(0x" << show_float(p.z) << "))";
            return str;
    }
    
    struct SPoint
    {
            Point3D p;
            bool DoCorrectFace(const Face& face)
            {
                    bool correct = true;
                    float j=1.0f;
                    Point3D np=p;
                    for (;;)
                    {
                            float ad = face.Dist(np);
                            if (ad<=0.0f)
                                    break;
                            correct=false;
                            np = p - (face.n*(ad*j));
                            j += 1.0f;
                    }
                    p=np;
                    return correct;
            }
    }; 
    
    using namespace std;
    int main()
    {
            cout << "Hello World!" << endl;
            SPoint spoint;
            spoint.p = Point3D(from_int(0x41c6940e), from_int(0x427352a6), from_int(0xc166e2d0));
            cout << "Initial p:" << endl;
            cout << spoint.p << endl;
            cout << "Corrected:" << endl;
    
            Face f;
            f.n = Point3D(from_int(0x3d6cc83b), from_int(0x3f0e8841), from_int(0x3f5422bd));
            f.nc = from_int(0x41bac3dc); 
    
            bool result = spoint.DoCorrectFace(f);
            cout << spoint.p << endl;
            cout << "Done: " << result << endl;
            return 0;
    }

    говно в gcc
    g++ (rev5, Built by MinGW-W64 project) 4.8.1
    вывод в -O2 -DNDEBUG :

    Hello World!
    Initial p:
    Point3D(from_int(0x41c6940e), from_int(0x427352a6), from_int(0xc166e2d0))
    Corrected:
    Point3D(from_int(0x41c6940e), from_int(0x427352a6), from_int(0xc166e2d1))
    Done: 0

    вывод в -O3 -DNDEBUG:

    Hello World!
    Initial p:
    Point3D(from_int(0x41c6940e), from_int(0x427352a6), from_int(0xc166e2d0))
    Corrected:
    Point3D(from_int(0x41c6940e), from_int(0x427352a6), from_int(0xc166e2d0))
    Done: 0

    внимание вопрос: может ли быть такое, что DoCorrectFace не изменил точку ни на бит, но вернул false? В gcc может!

    TarasB, 23 Февраля 2014

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

    +36

    1. 1
    2. 2
    3. 3
    t = Min(::std::cref(x), ::std::cref(y));
    //или в зависимости от ситуации 
    t = Min(::std::move(x), ::std::move(y));

    Абстракционизм или Кубизм?

    LispGovno, 04 Февраля 2014

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

    +36

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #include <iostream>
    int main() 
    { 
        system("calc"); 
    }

    Калькулятор на C++? Да пожалуйста.

    zebraplus, 16 Февраля 2013

    Комментарии (21)
  9. 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)
  10. C++ / Говнокод #11861

    +36

    1. 1
    printf("Aligment control: %d", sizeof(DataTransfer_T));

    LispGovno, 02 Октября 2012

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

    +36

    1. 1
    2. 2
    3. 3
    $kd = strrpos("$fotofilenames[$i]", ".");
        $kf = substr("$fotofilenames[$i]", $kd+1, strlen("$fotofilenames[$i]")-$kd);
        $kf = strtolower($kf);

    вот так и живем.

    Специальная олимпиада по программированию для программистов PHP, VB и 1c (c)

    brainstorm, 22 Сентября 2011

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