1. Java / Говнокод #18031

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    private String getNewRowKey() {
        	Hashtable<String, String> dataFields = new Hashtable<String, String>();
        	dataFields.put(TCommandConstants.TRANSITIONS_MARKET, Utils.convertMarketFrom("RUS",marketCB.getSelectedItem().toString()));
            dataFields.put( TCommandConstants.TRANSITIONS_INITIAL_STATUS, initialStatusCB.getSelectedItem().toString());
            dataFields.put( TCommandConstants.TRANSITIONS_TRANS_RULE, transitionRuleCB.getSelectedItem().toString());
            dataFields.put(TCommandConstants.TRANSITIONS_TARGET_STATUS, targetStatusCB.getSelectedItem().toString());
            return dataFields.get(TCommandConstants.TRANSITIONS_INITIAL_STATUS) + BPGraph.EMPTY_ITEM + dataFields.get(TCommandConstants.TRANSITIONS_TRANS_RULE) + BPGraph.EMPTY_ITEM + dataFields.get(TCommandConstants.TRANSITIONS_TARGET_STATUS);
        }

    grlgory, 21 Апреля 2015

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

    +142

    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
    #include <inttypes.h>
    #include <stdio.h>
     
    typedef union
    {
      struct
      {
        #define BITG(n) uint8_t bit##n : 1
        BITG(0);
        BITG(1);
        BITG(2);
        BITG(3);
        BITG(4);
        BITG(5);
        BITG(6);
        BITG(7);
        #undef BITG
      } bits;
      uint8_t value;
    }getbit;
     
    uint8_t bit_sum(uint8_t, uint8_t);
     
     
    uint8_t bit_sum(uint8_t a, uint8_t b)
    {
      getbit op1, op2, opr;
      uint8_t carry;
      op1.value=a; op2.value=b;
      #define OP1(n) op1.bits.bit##n
      #define OP2(n) op2.bits.bit##n
      #define OPR(n) opr.bits.bit##n
      #define XOR(a,b) ((a)^(b))
      #define AND(a,b) ((a)&(b))
      OPR(0) = XOR(OP1(0), OP2(0));
      carry = AND(OP1(0), OP2(0));
      #define SETBIT(n)                \
      OPR(n) = XOR                     \
               (                       \
                 carry,                \
                 XOR(OP1(n), OP2(n))   \
               );
     
      #define CARRYBIT(n)              \
      carry = XOR                      \
              (                        \
                AND(OP1(n), OP2(n)),   \
                AND                    \
                (                      \
                  XOR(OP1(n), OP2(n)), \
                  carry                \
                )                      \
              );
      SETBIT(1);
      CARRYBIT(1);
      SETBIT(2);
      CARRYBIT(2);
      SETBIT(3);
      CARRYBIT(3);
      SETBIT(4);
      CARRYBIT(4);
      SETBIT(5);
      CARRYBIT(5);
      SETBIT(6);
      CARRYBIT(6);
      SETBIT(7);
      return opr.value;
      #undef SETBIT
      #undef CARRYBIT
      #undef OP1
      #undef OP2
      #undef OPR
      #undef XOR
      #undef AND
    }
     
    int main (int argc, char *argv[], char *envp[])
    {
      uint8_t a, b, c;
      scanf ("%"SCNu8"%"SCNu8, &a, &b);
      c = bit_sum(a,b);
      printf("%"PRIu8"\n", c);
      return 0;
    }

    Побитовое сложение двух 8-битных чисел по схеме двоичного сумматора

    j123123, 20 Апреля 2015

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

    +142

    1. 1
    echo (yaml_parse_file('schema.yaml')['Article']['fields']['title']);

    artembegood, 20 Апреля 2015

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

    +105

    1. 1
    x = x + exp(ln(2)*i);

    Встретил в коде опроса датчика, не сразу понял, что это делает.
    Когда понял, понял что лучше бы не понимал.

    Vindicar, 20 Апреля 2015

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

    +143

    1. 1
    http://luck.subarctic.org/?gclid=CIbj18GRhcUCFaLUcgodJ5UAOg

    laMer007, 20 Апреля 2015

    Комментарии (9)
  6. Куча / Говнокод #18026

    +143

    1. 1
    http://habrahabr.ru/company/neuronspace/blog/254671/

    Захотелось поделится с сообществом.

    Vasiliy, 20 Апреля 2015

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

    +142

    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>
    #include <iomanip>
    #include <vector>
    using namespace std;
    int possition[65535] = {0};
    int sum[65535] = {0};
     
    int main() {
    int i=0;
    int j=0;
    int N;
    cin >> N;
    for(i=0; i<N; i++)
    cin >> possition[i];
     
    for(i=0; i<N; i++){                  
    for(j=0; j<possition[i]; j++){
             if(sum[i]<=possition[i]-j){
             sum[i]+=j;}
             
    }
           
    if(possition[i]-sum[i]==1)
    cout<<1<<" ";
    else cout<<0<<" ";
     
    }
     
    return 0;
    }

    Забавное это дело - листать новые пасты на pastebin'е.

    gost, 20 Апреля 2015

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

    +143

    1. 1
    if (($logons_result > 0) && ($logons_result < 2)) {

    шаманство

    simplycrazy, 20 Апреля 2015

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

    +937

    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
    public DataTable GetAllVideoDevice()
           {
               DataTable dt = DbUtil.GetData("SELECT VideoUrlId,VideoUrlName FROM VideoUrl");
               return dt;
           }
    
           public int GetVideoDeviceCount()
           {
               int i = 0;
               DataTable dt = GetAllVideoDevice();
               if (dt.Rows.Count > 0) return dt.Rows.Count;
               else return i;
           }

    У меня будут свои нули с блекджеком и шлюхами

    visviva, 20 Апреля 2015

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

    +144

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    public int[] GetIntVideoAll(int videoCount)
          {
              List<int> listOfIntsVideo = new List<int>();
              for (int i = 0; i < videoCount; i++)
              {
                  listOfIntsVideo.Add(i);
              }
    
              return listOfIntsVideo.ToArray();
          }
    foreach (int item in mediaServ.GetIntVideoAll(videoCount))
               { ........}

    Вот так вот. Такие жемчужины встречаются с частотой примерно раз в 10 минут в коде одного проекта который я переписываю.

    visviva, 20 Апреля 2015

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