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

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

    +170

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $(".fast-view .slide a").click(function() {
    			$(this).parent().parent().parent().parent().parent().parent().parent().find(".fast-view-list .tab").css("display", "none");
    			$(this).parent().parent().parent().parent().parent().parent().parent().find($(this).attr("href")).css("display", "block");
    			return false;
    		});

    lennar, 18 Марта 2015

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

    +62

    1. 1
    2. 2
    3. 3
    4. 4
    if( state != !val ) 
    {
       state = !val;
    }

    Переключение. Обе переменные булевские.

    absolut, 20 Февраля 2015

    Комментарии (25)
  4. Си / Говнокод #17590

    +109

    1. 1
    memcpy (stderr, stdout, sizeof (FILE));

    gpr, 06 Февраля 2015

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

    +65

    1. 1
    2. 2
    3. 3
    4. 4
    std::string Operations::getLastError()
    	{
    		return "Произошла неизвестная ошибка при выполнении криптооперации";
    	}

    laMer007, 30 Января 2015

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

    +67

    1. 1
    2. 2
    3. 3
    4. 4
    catch (...) 
    	{
    		return -__LINE__;
    	}

    laMer007, 29 Января 2015

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

    +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
    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
    public CookieContainer GetCookies(string url, string login, string password)
    {
        try
        {
            var cookies = new CookieContainer();
            string postData = string.Format(@"subaction=dologin&username={0}&password={1}&selected_language=Russian&x=62&y=37", Uri.EscapeDataString(login), Uri.EscapeDataString(password));
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url + "admin.php");
            httpWebRequest.AllowAutoRedirect = true;
            httpWebRequest.CookieContainer = cookies;
            httpWebRequest.Method = "POST";
            httpWebRequest.ContentType = "application/x-www-form-urlencoded";
            httpWebRequest.UserAgent = "Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.10.289 Version/12.01";
            httpWebRequest.ServicePoint.Expect100Continue = false;
            byte[] ByteQuery = System.Text.Encoding.UTF8.GetBytes(postData);
            httpWebRequest.ContentLength = ByteQuery.Length;
            Stream QueryStream = httpWebRequest.GetRequestStream();
            QueryStream.Write(ByteQuery, 0, ByteQuery.Length);
            QueryStream.Close();
            HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            StreamReader sr = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding(1251));
            string loginPage = sr.ReadToEnd();
            sr.Close();
            if (loginPage.IndexOf(@"div class=""error""") == -1)
            {
                httpWebResponse.Cookies = httpWebRequest.CookieContainer.GetCookies(httpWebRequest.RequestUri);
                httpWebResponse.Close();
                return cookies;
            }
            else
            {
                return null;
            }
            
        }
        catch (Exception)
        {
            if (n < 3)
            {
                Thread.Sleep(400);
                n++;
                return GetCookies(url, login, password);
            }
            else
            {
                n = 0;
                return null;
            }
        }
    }

    Костыльно-ориентированное велосипедирование. Выдержка из паттерна "тулза для работы с вебом", метод авторизации на какой-то из CMS.

    pushistayapodmyshka, 27 Ноября 2014

    Комментарии (25)
  8. JavaScript / Говнокод #17129

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    setInterval(
       setTimeout(){
          function(){
            updater();
          },
         10
       }
    ,2000);

    Просто увидел в коде

    kit, 18 Ноября 2014

    Комментарии (25)
  9. Си / Говнокод #17087

    +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
    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
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    main(){    
        
        FILE *filein, *fileout;
        
        char fname1[15], fname2[15];
        int n, m;
        int i, j;
        
        printf("Enter name of input file: "); scanf("%s", &fname1);
        printf("Enter name of output file: "); scanf("%s", &fname2);
        
        filein=fopen(fname1, "r");
        fileout=fopen(fname2, "w");
        if(filein==NULL){
          fprintf(stderr, "\nError: can't open file \"%s\"\n\n", fname1);
          fclose(filein);
          fclose(fileout);
          getch();
          }
        else{
             fscanf(filein, "%d%d", &n, &m);
             char ch[m][n];
             int array[m][n];
             int V[m][n];
             
             for(i=0;i<m;i++){
                for(j=0;j<n;j++){
                   V[i][j]=0;
                   }
                }
             
             for(i=0;i<m;i++){
                for(j=0;j<n;j++){
                   fscanf(filein, "%s", &ch[i][j]);
                   if(ch[i][j]=='+') array[i][j]=1;
                   else if(ch[i][j]=='-') array[i][j]=0;
                   }
                }
             
             int sum;
             for(i=0;i<m;i++){
                sum=0;
                for(j=0;j<n;j++){
                   sum+=array[i][j];
                   }
                   if(sum==1){
                             for(j=0;j<n;j++){
                                V[i][j]=array[i][j];
                                }
                             }
                   else continue;
                }
                
             int mm=0, c;
             for(i=0;i<m;i++){
                for(j=0;j<n;j++){
                   mm+=V[i][j];
                   }
                }
             c = m-mm;
             
             int VoteArray[n];
             
             for(j=0;j<n;j++){
                sum=0;
                for(i=0;i<m;i++){
                   sum+=V[i][j];
                   VoteArray[j]=sum;
                   }
                }
             
             float percent[n];
             float per;
             per = 100/(float)c;
             for(i=0;i<n;i++){
                
                if((percent[i]=per*VoteArray[i])>=7.0) fprintf(fileout, "%d ", i+1);
                }
                
             }
        
        fclose(fileout);
        fclose(filein);
        puts("\nMission comleted\nPress any key...\n");
        getch();
    }

    Фу, блять

    Sushev, 09 Ноября 2014

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

    +140

    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
    virtual QModelIndex parent(const QModelIndex &child) const = 0;
    
        virtual QModelIndex sibling(int row, int column, const QModelIndex &idx) const;
        virtual int rowCount(const QModelIndex &parent = QModelIndex()) const = 0;
        virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;
        virtual bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
    
        virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const = 0;
        virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
    
        virtual QVariant headerData(int section, Qt::Orientation orientation,
                                    int role = Qt::DisplayRole) const;
        virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
                                   int role = Qt::EditRole);
    
        virtual QMap<int, QVariant> itemData(const QModelIndex &index) const;
        virtual bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
    
        virtual QStringList mimeTypes() const;
        virtual QMimeData *mimeData(const QModelIndexList &indexes) const;
        virtual bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
                                     int row, int column, const QModelIndex &parent) const;
        virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action,
                                  int row, int column, const QModelIndex &parent);

    ну, вы поняли. они написали тысячи говнокода и говорят, что это круто.
    они написали говно-пример, и говорят, что это круто.
    а вы что думаете по этому поводу?

    FadeToBlack, 29 Октября 2014

    Комментарии (25)
  11. C++ / Говнокод #16856

    +57

    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
    bool operator ==( const CClass& lhs, const CClass& rhs )
    {
       bool rc = true;
    
       // No self-comparison...
       if ( &lhs != &rhs )
       {
          // Do not compare fields if result is already false...
          if ( rc )
          {
             rc = ( lhs.frameId() == rhs.frameId());
          }
          if ( rc )
          {
             rc = ( lhs.objectId() == rhs.objectId());
          }
          if ( rc )
          {
             rc = ( lhs.type() == rhs.type() );
          }
          if ( rc )
          {
             rc = ( lhs.transition() == rhs.transition() );
          }
          if ( rc )
          {
             rc = ( lhs.rotation() == rhs.rotation() );
          }
       }
       return rc;
    }

    hedrok, 15 Октября 2014

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