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

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

    +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
    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
    if (scannedLiteralType.compareTo("<!") == 0) {
              if (textPosition + 5 < text.length) {
                if (scannedByte == (byte)'[') {
                  if (text[textPosition] == (byte)'C') {
                    if (text[textPosition + 1] == (byte)'D') {
                      if (text[textPosition + 2] == (byte)'A') {
                        if (text[textPosition + 3] == (byte)'T') {
                          if (text[textPosition + 4] == (byte)'A') {
                            if (text[textPosition + 5] == (byte)'[') {
                              scanByte();
                              scanByte();
                              scanByte();
                              scanByte();
                              scanByte();
                              scanByte();
                              scanByte();
                              Element childNode = createNode("");
                              node.addChild(childNode);
                              scanBytes("]]>".getBytes(), false);
                              byte[] bytes = new byte[literalPosition - 1];
                              System.arraycopy(literal, 0, bytes, 0, literalPosition - 1);
                              try {
                                String string = new String(bytes, encoding);
                                childNode.setValue(string);
                                childNode.setIdentifier("<![SDATA[]]");
                              } catch (Exception exception) {
                                childNode.setValue(bytes);
                                childNode.setIdentifier("<![CDATA[]]");
                              }
                              scanByte();
                              scanByte();
                              scanByte();
                              scanToken();
                              continue;
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }

    проверка "CDATA"

    nesferatos, 06 Августа 2012

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

    +137

    1. 1
    model = (IModel)Activator.CreateInstance("DataModel", type).Unwrap() as IModel;

    Maps, 01 Августа 2012

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

    −109

    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
    // код в модели - создаются фильтры для колонок
    override protected function createFiltersData():IList
      {
       var filtersDescription:IList = new ArrayList();
       filtersDescription.addItem(new StatusFilter());
       filtersDescription.addItem(new ProdUIDFilter());
       filtersDescription.addItem(new ProdLongNameFilter());
       filtersDescription.addItem(new ProductTypeFilter());
       filtersDescription.addItem(new LatestRecordFilter());
       
       filtersDescription.addItem(new LastActionFilter(true));
       filtersDescription.addItem(new UsersFilter(this.userModel.users, true));
       filtersDescription.addItem(new PublishFilter(true));
       filtersDescription.addItem(new ProdNameFilter(true));
       filtersDescription.addItem(new ProductComplexityRatingFilter(true));
       filtersDescription.addItem(new ProductDescriptionFilter(true));
       return filtersDescription;
      }
    
    // код в контроллере - создаются сами колонки
    override protected function createTableColumns () : Array
      {
       var columns : Array = new Array();
       columns.push(new ProdUIDColumn(0));
       columns.push(new ProdLongNameColumn(1));
       columns.push(new ProdNameColumn(2));
       columns.push(new ProductDescriptionColumn(8));
       columns.push(new ProdTypeColumn(3));
       columns.push(new ProdComplRatingColumn(4));
       columns.push(new EditorSeparator(40, 5));
       columns.push(new CommentsColumn(9));
       columns.push(new ValidStartDateColumn(6));
       columns.push(new ValidEndDateColumn(7));
       columns.push(new LastActionColumn());
       columns.push(new UserColumn());
       columns.push(new LastActionDateColumn());
       columns.push(new LatestRecordColumn());
       columns.push(new StatusColumn());
       columns.push(new PublishColumn());
       return columns;
      }

    Со слезами в глазах вопрошаю - ну нахуя, а????

    kyzi007, 28 Июля 2012

    Комментарии (7)
  5. Куча / Говнокод #11459

    +129

    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
    F[numbers_, setNumber_, ParenNum_] := 
     Block[{func = {"+", "-", "*", "/"}[[setNumber]], 
       parens = {{"", "", "", "", "", ""}, {"", "(", "", "", ")", 
           ""}, {"", "", "", "(", "", ")"}, {"", "(", "", "", "", 
           ")"}, {"(", "", ")", "(", "", ")"}}[[ParenNum]], e}, 
      e = ToExpression[
        ToString[
         StringJoin[parens[[1]], ToString[numbers[[1]]], func[[1]], 
          parens[[2]], ToString[numbers[[2]]], parens[[3]], func[[2]], 
          parens[[4]], ToString[numbers[[3]]], parens[[5]], func[[3]], 
          ToString[numbers[[4]]], parens[[6]]]]]; e];Timing[c = 0; d = 0; 
     b = Permutations[{1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4}, {3}]; 
     For[n1 = 1, n1 < 10, n1++, 
      For[n2 = 1, n2 < n1, n2++, 
       For[n3 = 1, n3 < n2, n3++, 
        For[n4 = 1, n4 < n3, n4++, 
         a = Permutations[{n1, n2, n3, n4}, {4}]; sol = {}; 
         For[i = 1, i <= Length[a], i++, 
          For[j = 1, j <= 64, j++, 
           For[n = 1, n <= 5, n++, g = F[a[[i]], b[[j]], n]; 
            If[IntegerQ[g] && g > 0, AppendTo[sol, g]]]]; 
          m = Sort[DeleteDuplicates[sol]]; 
          l = Complement[Range[1000], m][[1]]; 
          If[l > c, c = l; d = {n1, n2, n3, n4}]]]]]]; 
     FromDigits[Reverse[d]]]

    http://projecteuler.net/problem=93
    http://projecteuler.net/thread=93&page=6


    Язык, кстати, Mathematica.

    TheHamstertamer, 22 Июля 2012

    Комментарии (7)
  6. VisualBasic / Говнокод #11421

    −98

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    Private Sub Command2_Click()
    Cls
    For x = 1 To Text2 + 1
    For y = 1 To Text2 + 1
    A(x, y) = Round(Rnd(1))
    If A(x, y) = 0 Then A(x, y) = -1
    Next
    Next
    For x = 2 To Text2
    For y = 2 To Text2
    PSet (1200 + x * 15, 200 + y * 15), A(x, y)
    Next
    Next
    End Sub
    
    Private Sub Command3_Click()
    Cls
    For x = 1 To Text2 + 1
    For y = 1 To Text2 + 1
    A(x, y) = 1
    Next
    Next
    A(Text20, Text21) = -1
    A(Text22, Text23) = -1
    A(Text24, Text25) = -1
    A(Text26, Text27) = -1
    For x = 2 To Text2
    For y = 2 To Text2
    PSet (1200 + x * 15, 200 + y * 15), A(x, y)
    Next
    Next
    End Sub
    
    Private Sub Form_Load()
    
    For x = 1 To Text2 + 1
    For y = 1 To Text2 + 1
    A(x, y) = Round(Rnd(1))
    If A(x, y) = 0 Then A(x, y) = -1
    Next
    Next
    
    
    
    'For x = 1 To Text2 + 1
    'For y = 1 To Text2 + 1
    'A(x, y) = 1
    'Next
    'Next
    'A(10, 10) = -1
    
    
    
    End Sub
    
    Private Sub Command1_Click()
    Cls
    
    For k = 1 To Text1
    
    For x = 1 To Text2 + 1
    A(x, 1) = A(x, Text2)
    A(x, Text2 + 1) = A(x, 2)
    Next
    
    For y = 1 To Text2 + 1
    A(1, y) = A(Text2, y)
    A(Text2 + 1, y) = A(2, y)
    Next
    
    
    
    For x = 2 To Text2
    For y = 2 To Text2
    
    xp = A(x - 1, y - 1) + A(x, y - 1) + A(x + 1, y - 1) + A(x - 1, y) + A(x + 1, y) + A(x - 1, y + 1) + A(x, y + 1) + A(x + 1, y + 1)
    Select Case xp
    Case -8
    B(x, y) = Text3
    Case -7
    B(x, y) = Text4
    Case -6
    B(x, y) = Text5
    Case -5
    B(x, y) = Text6
    Case -4
    B(x, y) = Text7
    Case -3
    B(x, y) = Text8
    Case -2
    B(x, y) = Text9
    Case -1
    B(x, y) = Text10
    Case 0
    B(x, y) = Text11
    Case 1
    B(x, y) = Text12
    Case 2
    B(x, y) = Text13
    Case 3

    Жестокий, безумный мозг пятнадцатилетнего пацана родил клеточный автомат. Нашел свои исходники десятилетней давности.
    А ведь я себя тогда считал крутым программистом... стыдно вспоминать.

    xcont, 16 Июля 2012

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

    +76

    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
    public static void main(String[] args) {      
    List<String> parameters = new ArrayList<String>();
    
    if (args.length > 1) {
             int count = 0;
             for (String arg : args) {
                if (count == 0) {
                   count++;
                   continue;
                }
                parameters.add(arg);
             }
    }
    ...

    Ах Индия, Индия...
    (все имена переменных изменены, все совпадения - исключительно случайны)

    Taru4, 12 Июля 2012

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

    +15

    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
    #pragma once
    #include <assert.h>
     
    template<typename T>
    inline T notNull(T arg)
    {
            assert(arg!=NULL);
            return arg;
    }
     
    /*
    //example:
    class AnotherClass;
    
    class SomeClass
    {
    AnotherClass * m_another;
    //...
            SomeClass(AnotherClass * another, /*skipped*/) : m_another(notNull(another)), /*skipped*/;
    }
    */

    Мелочь, конечно же, но всё-таки чушь, несмотря на пользу.

    Xom94ok, 04 Июля 2012

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

    +5

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    template<class T>
    bool IsAligned(T SizeOrAddress, const size_t AlignStep)
    {
    	return SizeOrAddress==Align(SizeOrAddress, AlignStep);
    }

    HaskellGovno, 03 Июля 2012

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

    +12

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if(maxbits<3) x = genrand64_int64() & genrand64_int64() & genrand64_int64() & genrand64_int64() & genrand64_int64();
    				else 
    				{
    					if(maxbits<6) x = genrand64_int64() & genrand64_int64() & genrand64_int64() & genrand64_int64();
    					else x = genrand64_int64() & genrand64_int64() & genrand64_int64();
    				}

    Fai, 03 Июля 2012

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

    +137

    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
    #define FMT_2_LEN  16
    #define FMT_4_LEN  24
    // и т.д. всего около десятка форматов
    
    void calc_check_code(const unsigned char * from, unsigned fmt, unsigned * code)
    {
        switch (fmt) {
        case 2:
            //...
            memset(data, 0, sizeof(FMT_2_LEN));
            // выборочное наполнение data из from
            make_code(data, FMT_2_LEN, code);
            break;
        case 4:
            //...
            memset(data, 0, sizeof(FMT_4_LEN));
            // выборочное наполнение data из from
            make_code(data, FMT_2_LEN, code);
            break;
        // для всех остальных аналогично
    }

    странно, и почему контрольный код не совпадает с эталонными примерами...

    defecate-plusplus, 20 Июня 2012

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