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

    В номинации:
    За время:
  2. 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)
  3. Си / Говнокод #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)
  4. 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)
  5. 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)
  6. C++ / Говнокод #16847

    +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
    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
    bool nt_utils::enum_processes(std::vector<uint32_t>& pids)
    {
      pids.clear();
    
      PDWORD process_ids = NULL;
      DWORD cb = ALLOC_SIZE;
      DWORD bytes_returned = 0;
      BOOL complete = FALSE;
    
      __try {
    
        while (!complete) {
          process_ids = static_cast<PDWORD>(
            ::HeapAlloc(
              ::GetProcessHeap(),
              HEAP_GENERATE_EXCEPTIONS | HEAP_ZERO_MEMORY,
              cb
            )
          );
    
          if (::EnumProcesses(process_ids, cb, &bytes_returned)) {
            if (cb == bytes_returned) {
              ::HeapFree(::GetProcessHeap(), 0, process_ids);
              process_ids = NULL;
              cb *= 2;
            } else {
              complete = TRUE;
            }
          } else {
            ::HeapFree(::GetProcessHeap(), 0, process_ids);
            process_ids = NULL;
            complete = TRUE;
          }
        }
        
        if (process_ids) {
          DWORD size = bytes_returned / sizeof(DWORD);
          pids.reserve(size);
          for (DWORD i = 0; i < size; ++i) {
            assert(process_ids[i]);
            pids[i] = process_ids[i];
          }
          ::HeapFree(::GetProcessHeap(), 0, process_ids);
        }
    
      } __except (EXCEPTION_EXECUTE_HANDLER) {
        if (process_ids) {
          ::HeapFree(::GetProcessHeap(), 0, process_ids);
        }
        return false;
      }
    
      return !!process_ids;
    }

    Получение id всех процессов

    gc4242, 14 Октября 2014

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

    +152

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function init() {
      
        if (!document.body) return;
     
        var body = document.body;
        var html = document.documentElement;
        // ...
    }
    // ...

    https://gist.github.com/galambalazs/6477177/

    Плавный скролл, я вот только не пойму, почему "if (!document.body) return;"?
    Типа <body> тэга может не существовать?!

    volter9, 01 Октября 2014

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

    +156

    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
    for($i = 1; $i < $conf->nb_images + 1; $i++)
    {
    	$ext_name = chr(ord('a')+$i-1);
    	?>
    	<label for="ad_picture<?php echo $i;?>"><?php echo ADSMANAGER_FORM_AD_PICTURE." ".$i; ?></label>
    	<input id="ad_picture<?php echo $i;?>" type="file" name="ad_picture<?php echo $i;?>" />
    	<?php
    	if ($isUpdateMode) {
    		$pic = $mosConfig_absolute_path."/images/$option/projects/".$ad_id.$ext_name."_t.jpg";
    		if ( file_exists( $pic)) {
    			echo "<img src='".$mosConfig_live_site."/images/$option/projects/".$ad_id.$ext_name."_t.jpg' align='top' border='0' alt='image$ad_id' />";
    			echo "<input type='checkbox' name='cb_image$i' value='delete' />".ADSMANAGER_AD_DELETE_IMAGE;
    		}
    	}
    	echo "<br />";
    }

    Угадайте что за CMS :)))

    mishanon, 27 Сентября 2014

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

    +57

    1. 1
    if (!this) return;

    Actine, 05 Сентября 2014

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

    +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
    Public CallGridRowModel(CallView callView)
    {
      . . .
      Caller = GetCallerOrCalleeNameColumn(callView, true)
      Callee = GetCallerOrCalleeNameColumn(callView, false)
      . . .
    }
      
      
    private object GetCallerOrCalleeNameColumn(CallView callView, bool isCallerNameColumn)
    {
      if(isCallerNameColumn)
      {
        if(. . .) return . . .;
      }
      if(!isCallerNameColumn)
      {
        if(. . .) return . . .;
      }
      
      if(isCallerNameColumn)
      {
        return . . .;
      }
      else
      {
        return . . .;
      }
    }

    onixar, 15 Июля 2014

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

    +87

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    public BarrierAssessment(int id, Client client, int homephone, int mobile, int email, int transport, int licence, boolean notInWorkForce, boolean unpaidWork, boolean cdeProgram, boolean notWorkingBut, int paidWork, 
    String employerOcc, String reason, int highlevel, String further, int stableAccomodation, int loneParent, int livingWith, int policeProblems, int courtPending, int preventFrom, int medical, int drugTest, int currentBusy, 
    String scurrentBusy, String reasonForNotGettingJob, int startTomorrow, String jobGoals, int currentResume, int canvasLetter, int referees, int interviewClothing, String otherBarriers, int ec, LastModified lastModified, 
    Date datestamp, Date bupdated, String disabilityBarriers, Date licenceDueToExpire, Date licenceDueBack, String currentSkills, String possibleSkills) {
     
    ...
     
    }

    Мать всех конструкторов!

    Meegoo, 18 Июня 2014

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