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

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

    +73.6

    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
    package psorter;
    
    import java.util.Vector;
    
    public class CArray extends Vector {
        String type="";
    
        /**
         * constructor of /array/
         * @param i set capacity increment
         */
        public CArray(int i) {
    	this.capacityIncrement=i;
        }
    
        /**
         * add object to end of vector with check of type
         * if type same as @ first added - add this object
         * safer than add
         * @param o object to add
         */
        public void append(Object o) {
    	if ( this.type.equals("") )
    	    this.type=o.getClass().toString();
    
    	if ( o.getClass().toString().equals(this.type) ){
    	    this.add(o);
    	} else {
    	    if ( this.type.contains("Float") && o.getClass().toString().contains("Integer") )
    		this.add( Float.valueOf(o.toString()) );
    
    	    if ( this.type.contains("Double") && o.getClass().toString().contains("Integer") )
    		this.add( Double.valueOf(o.toString()) );
    	    if ( this.type.contains("Double") && o.getClass().toString().contains("Float") )
    		this.add( Double.valueOf(o.toString()) );
    
    	    if ( this.type.contains("String") && o.getClass().toString().contains("Char") )
    		this.add( o.toString() );
    	}
        }
    
        public byte compare(int i, int j) throws Exception {
    	if (type.contains("Integer")) {
    	    if ((Integer) (this.get(i)) > (Integer) (this.get(j)))
    		return 1;
    	    if ((Integer) (this.get(i)) < (Integer) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("Float")) {
    	    if ((Float) (this.get(i)) > (Float) (this.get(j)))
    		return 1;
    	    if ((Float) (this.get(i)) < (Float) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("Double")) {
    	    if ((Double) (this.get(i)) > (Double) (this.get(j)))
    		return 1;
    	    if ((Double) (this.get(i)) < (Double) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("Char")) {
    	    if ((Character) (this.get(i)) > (Character) (this.get(j)))
    		return 1;
    	    if ((Character) (this.get(i)) < (Character) (this.get(j)))
    		return -1;
    	    return 0;
    	}
    
    	if (type.contains("String")) {
    	    if ( this.get(i).toString().compareTo(this.get(j).toString())>0 )
    		return 1;
    	    if ( this.get(i).toString().compareTo(this.get(j).toString())<0 )
    		return -1;
    	    return 0;
    	}
    
    	return 0;
        }
    }

    сел писать 3 лабы естественно в последнюю ночь. начал в 11. эта была около 3х. самому потом стыдно было нести такое

    ilardm, 17 Апреля 2010

    Комментарии (15)
  3. Java / Говнокод #2641

    +73.6

    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
    private void applyFilter(Article article, List<Article> allArticles, RSSFilter filter) {
    
            if (filter != null) {
    
                if ((filter.isAnd()) && (filter.isContent()) && (filter.isTitle())) {
                    if (article.getTitle().toLowerCase().contains(filter.getFilter().toLowerCase())
                            && (article.getContent().toLowerCase().contains(filter.getFilter()
                                    .toLowerCase()))) {
                        allArticles.add(article);
                    }
                }
                if (filter.getFilter() == null || filter.getFilter().isEmpty()) {
                    allArticles.add(article);
                } else if ((filter.isAnd()) && (!filter.isContent()) && (filter.isTitle())) {
                    if (article.getTitle().toLowerCase().contains(filter.getFilter().toLowerCase())) {
                        allArticles.add(article);
                    }
                } else if ((filter.isAnd()) && (filter.isContent()) && (!filter.isTitle())) {
                    if (article.getContent().toLowerCase().contains(filter.getFilter().toLowerCase())) {
                        allArticles.add(article);
                    }
                } else if ((!filter.isAnd() && !filter.isContent()) && (filter.isTitle())) {
                    if (article.getTitle().toLowerCase().contains(filter.getFilter().toLowerCase()))
                        allArticles.add(article);
                } else if ((!filter.isAnd()) && (!filter.isTitle()) && (filter.isContent())) {
                    if (article.getContent().toLowerCase().contains(filter.getFilter().toLowerCase()))
                        allArticles.add(article);
                } else if (!filter.isAnd()) {
                    if (article.getTitle().toLowerCase().contains(filter.getFilter().toLowerCase())
                            || (article.getContent().toLowerCase().contains(filter.getFilter()
                                    .toLowerCase()))) {
                        allArticles.add(article);
                    }
                }
    
            } else {
                allArticles.add(article);
            }
        }

    стыдно, млин у себя нашел)))
    реализация фильтра
    взаимоисключение, нереальные условия (UI на радиобатонах)

    fisherman, 19 Февраля 2010

    Комментарии (0)
  4. Java / Говнокод #689

    +73.6

    1. 1
    int dayOfWeek = calendar.get(calendar.get(Calendar.DAY_OF_WEEK));

    guest, 10 Марта 2009

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

    +73.5

    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
    //...                            
                                           }
    
                                        }
                                      }
                                      if(found) break;
                                    }
                                  }
                                  aStr=wcstok(NULL,m_cmdSEP);
                                }
                              }
                            }
                          }
                        }
                      }
                      else NoDeviceErrorActive(1);
                    }
                  }
                }
                else NoDeviceErrorActive(1);
              }
            }
          }
        }
      }
    //...

    Кусочек функции, сегодня наткнулся, сама функция занимает 540 строк, все методы класса -- 8000 =). И форматирование оригинальное -- не табами, а двумя пробелами =) . Мне нужно было просто посмотреть, как этот класс одну штуку делает, и я теперь сижу счастливый и думаю, как хорошо, что не мне этот код поддерживать =)

    ISith, 03 Марта 2010

    Комментарии (17)
  6. Java / Говнокод #2742

    +73.4

    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
    public class SaveBlankElementException extends RuntimeException{
        public SaveBlankElementException(Throwable cause){
            super(cause);
        }
        public SaveBlankElementException(String message,Throwable cause){
            super(message,cause);
        }
        public SaveBlankElementException(String message){
            super(message);
        }
        public SaveBlankElementException(){
    
        }
        @Override
        public String getMessage(){
            return "Попытка сохранения пустого элемента\nНе вызван prepareCreate()";
        }
      
    }

    Зачем, спрашивается было создавать этот класс, когда можно было бы
    вызвать исключение
    throw new UnsupportedOperationException("Попытка сохранения пустого элемента\nНе вызван prepareCreate()");

    maxt, 10 Марта 2010

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

    +73.4

    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
    String tempFileName = "someFileName";
    URL url = SomeClass.class.getClassLoader().getResource(".");
    File currentFolder = new File(url.getFile());
    if(currentFolder.isDirectory()){
       File parentFolder = currentFolder.getParentFile();
       for (String file:parentFolder.list()) {
          if(file.equals("temp")){
             File targetFolder = new File(parentFolder.getAbsolutePath()+"\\"+file+"\\"+tempFileName);
             if(!targetFolder.exists()) {
    	targetFolder.mkdir();
             }
             this.pathToTempFile = parentFolder.getAbsolutePath()+"\\"+file+"\\"+tempFileName;
          }
       }
    }

    Поиск директории для создания временных файлов вместо использования File.createTempFile(prefix, suffix)

    eroese, 10 Декабря 2009

    Комментарии (3)
  8. Java / Говнокод #2625

    +73.3

    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
    package xx.xxxxxxxx.xxx.xxx.gui.constants;
    
    /**
     * constants.
     */
    public class Constants
    {
        public static final int HORIZONTAL_SIZE = 500;
    
        public static final int VERTICAL_SIZE = 340;
    
        public static final int ABS_MAX_LENGTH_NUMBER = 28;
    
        public static final int ZERO = 0;
        public static final int ONE = 1;
        public static final int TWO = 2;
        public static final int THREE = 3;
        public static final int FOUR = 4;
        public static final int FIVE = 5;
    
    }

    ZERO=0, ONE=1, TWO=2, ...
    Ваш К.О.

    xvro, 17 Февраля 2010

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

    +73.2

    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
    /*
        CANON D-SLR cameras core routine
        Property of CANON INC. 1998-2010
        
        v 1.0 made by Radja Tokamoto Goines
        v 1.1 made by Dugwin Yakioto jr.
        
        last changes: 10.11.2009
    */
    
    #include <stdlib.h>
    #include <math.h>
    #include <time.h>
    
    #include "inc/tweakfocus.h"
    #include "inc/radja_filters.h"
    
    bool do_focus(lens, camera) {
        double fp;
        time_t t;
    
        t = init_focus_timer(t);
        
        do {
            fp = measure_focus_point(lens);
            move_focus(lens, fp)
    
            if (timeout(t))
                return false;
    
        } while (!lens.is_focused());
        
        if (!L_LensDetected(lens))
            lens.adjust_focus(rand(10));
            
        return true;
    }
    
    rawdata * scandata(matrix, lens, camera) {
        rawdata *cr;
        double noise, aberrations;
    
        cr = create_cr(matrix);
        
        read_exif_info(cr->exif, lens, camera);
    
        prepare_everything(matrix, lens, camera);
        
        if (!do_focus(lens, camera))
            return NULL;
        else 
            beep();
          
        aberrations = pow(100 - lens.focallength, 2) * sqrt(2) + 10;
    
        if (L_LensDetected(lens))
            aberrations /= 2.0;
          
        scan_sensor(cr, matrix, aberrations);
    
        noise = matrix.iso / 100.0;
        noise *= matrix.cropfactor;
    
        if (camera.model == EOS1000D) {
            noise *= 1.2;
            wait_for_something();
        }
    
        if (camera.model != EOS7D)
            wait_for_something();
        
        if (lens.manufacture != CANON_LENS) {
            corrupt_something(cr);
            apply_random_filter(cr);
        }
        
        if (lens.model == EF_50_F1_4) {
            noise /= 1.2;
            apply_fcb(cr); //fucken cool bokeh
        }
        
        if (lens.model == CANON_L_17_40_F4) {
            blur(cr, 0.8);
            distort(cr, 40 - lens.focallength);
        }
          
        radja_filter(cr, 1.570796326794896619231321691641); //don't touch that!
    
        if (is_eos1d_series(camera.model))
            disable_all_spoiling(cr);
        else
            make_nice_colors(cr);
        // finally...
        apply_noise(cr, noise);    
        apply_barrel_distortion(cr, lens);
        apply_pillow_distortion(cr, lens);  
        
        return cr;
    }

    http://habrahabr.ru/blogs/DSLR/74958/
    Исходные тексты прошивки canon eos.
    Многие, наверное, уже слышали, что на днях была взломана внутренняя сеть компании Canon и в числе прочего в сеть «утёк» кусок ядра исходных текстов прошивки камер серии EOS, который я имею честь эксклюзивно опубликовать на суд общественности.
    Говночитатели без ЧЮ идут в *опу.

    sbb, 11 Ноября 2009

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

    +73.2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /*
     * когда-нибудь этот код будет смотреть другой программист
     * так вот, если ты есть тот самый программист и надеюсь ты хороший программист, 
     * то если возникнут какие-то недопонятки, извиняй, старался писать код как-можно качественее
     * но если несложно напиши мне(--------) если считаешь что код дерьмовый. я постараюсь его отрефакторить и объяснить тебе)
     * 
     * маразм какой-то конечно написал), но мне просто интересно насколько качествен или дерьмов мой код).
     * спс
     */

    думаю это надо постить на antigovnokod.ru, но к сожалению такого проекта еще нету. поэтому запостил строчки этого хорошего программиста сюда)

    guest, 11 Июня 2009

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

    +73.2

    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
    public void execute(String _filein, String _fileout) throws IOException {
            File fin = new File(_filein);
            File fout = new File(_fileout);
            FileWriter fwout = new FileWriter(fout);
            int chars_read = 0;
            FileReader in = new FileReader(fin);
            int size = (int) fin.length();
            char[] data = new char[size];
            while (in.ready()) {
                chars_read += in.read(data, chars_read, size - chars_read);
            }
            in.close();
            fwout.write(new String(data, 0, chars_read));
            fwout.close();
        }

    как копируют xml'и суровые фсб'шники...

    guest, 06 Мая 2009

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