1. JavaScript / Говнокод #18034

    +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
    function ValidateSignupData()
    {
        var username = $('#signup-name').val();
        var password = $('#signup-password').val();
        var password_confirm = $('#signup-password-confirmation').val();
        var email = $('#signup-email').val();
        var type_payment = $('#signup-payment').val();
        var card_numb = $('#signup-numb').val();
    
        if(username.length()>0) {
            if(password.length()>0) {
                if(password_confirm.length()>0) {
                    if (password == password_confirm) {
                        if(card_numb.length()>0 && card_numb.length()<14) {
                        }
                        else {
                            $('#message-signup').text('Поле "Номер карты" слишком короткое');
                        }
                    }
                    else {
                        $('#message-signup').text('Пароли не совпадают');
                    }
                }
                else
                {
                    $('#message-signup').text('Поле "Подтверждение пароля" не заполнено');
                }
        }
        else 
            {
            $('#message-signup').text('Поле "Пароль" не заполнено');
        }
        }
        else {
            $('#message-signup').text('Поле "Имя" не заполнено');
        }
    }

    Простейшая валидация формы.

    qstd, 21 Апреля 2015

    Комментарии (2)
  2. PHP / Говнокод #18033

    +142

    1. 1
    $listing_split_query = $listing_split_query_pieces[0]." and p.products_sort_order >= $last_sort and p.products_sort_order < $listing_split_limit order by".$listing_split_query_pieces[1]; // crazy hack for cool sort, sorry ;)

    sevenflash, 21 Апреля 2015

    Комментарии (0)
  3. Куча / Говнокод #18032

    +144

    1. 1
    2. 2
    <a href="javascript:redirect('http://apex.oracle.com/doc41');" title="Click here to learn how to get started" style="text-align:center;font-size:10px;display:block;margin:2px;">Click here to learn how to get started</a>
    <script>function redirect(a){location.href=a;return}</script>

    Oracle APEX божественен!

    Lokich, 21 Апреля 2015

    Комментарии (1)
  4. 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)
  5. Си / Говнокод #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)
  6. PHP / Говнокод #18029

    +142

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

    artembegood, 20 Апреля 2015

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

    +105

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

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

    Vindicar, 20 Апреля 2015

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

    +143

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

    laMer007, 20 Апреля 2015

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

    +143

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

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

    Vasiliy, 20 Апреля 2015

    Комментарии (95)
  10. 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)