1. C++ / Говнокод #18037

    +145

    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
    void* PhysicsWorld::CreateBodyImpl(const PhysicsBodyCInfo& bodyInfo)
    {
    	void* pBody = 0;
    	PhysicsBody* body = 0;
    
    	switch(bodyInfo.GetType())
    	{
    		case PHYSICS_BODY:
    			pBody = new PhysicsKovahBody(this);
    			// This one is special and I dont know why. I used AddToWatch1 to get this std::string well casted.
    			body = (PhysicsBody*)(&(*(PhysicsKovahRigidBody*)(&*((PhysicsKovahBody*)pBody))));
    			pBody = body;
    			break;
    		case PHYSICS_CHARACTER_BODY:
    			pBody = new PhysicsKovahCharacterBody(this);
    			body = (PhysicsBody*)((PhysicsCharacterBody*)pBody);
    			break;
    		case PHYSICS_CAR_BODY:
    			pBody = new PhysicsKovahCarBody(this);
    			body = (PhysicsBody*)((PhysicsCarBody*)pBody);
    			break;
    		case PHYSICS_MOTO_BODY:
    			pBody = new PhysicsKovahMotoBody(this);
    			body = (PhysicsBody*)((PhysicsMotoBody*)pBody);
    			break;
    		case PHYSICS_BOAT_BODY:
    			pBody = new PhysicsKovahBoatBody(this);
    			body = (PhysicsBody*)((PhysicsBoatBody*)pBody);
    			break;
    		case PHYSICS_AIRPLANE_BODY:
    			pBody = new PhysicsKovahAirplaneBody(this);
    			body = (PhysicsBody*)(&(*(PhysicsVehicleBody*)(&(*(PhysicsAirplaneBody*)(&*((PhysicsKovahAirplaneBody*)pBody))))));
    			break;
    		case PHYSICS_HELICOPTER_BODY:
    			pBody = new PhysicsKovahHelicopterBody(this);
    			body = (PhysicsBody*)(&(*(PhysicsVehicleBody*)(&(*(PhysicsHelicopterBody*)(&*((PhysicsKovahHelicopterBody*)pBody))))));
    			break;
    		case PHYSICS_JETPACK_BODY:
    			pBody = new PhysicsKovahJetpackBody(this);
    			body = (PhysicsBody*)(&(*(PhysicsVehicleBody*)(&(*(PhysicsJetpackBody*)(&*((PhysicsKovahJetpackBody*)pBody))))));
    			break;
    		case PHYSICS_VTOL_BODY:
    			pBody = new PhysicsKovahVTOLBody(this);
    			body = (PhysicsBody*)(&(*(PhysicsVehicleBody*)(&(*(PhysicsVTOLBody*)(&*((PhysicsKovahVTOLBody*)pBody))))));
    			break;
    		case PHYSICS_CAMERA_BODY:
    			break;
    	};
    
    	if(body && body->Create(bodyInfo))
    	{
    		return pBody;
    	}
    	SafeDelete(body);
    	return 0;
    }

    int0x18, 21 Апреля 2015

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

    +142

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    if ((subchannel == undefined || "none") && (subsubchannel == undefined || "none")) {
        subchannel = channel;
        subsubchannel = subchannel;
    } else if ((subchannel != undefined || "none") && (subsubchannel == undefined || "none")) {
        subsubchannel = subchannel;
    } else if ((subchannel == undefined || "none") && (subsubchannel != undefined || "none")) {
        subchannel = channel;
    } else {
        subchannel = subchannel;
        channel = channel;
    }

    Скопировал из похожего проекта не глядя, и потом удевляюсь что херня получается. А там ведь как-то работает, бля...

    russling, 21 Апреля 2015

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

    +137

    1. 1
    2. 2
    3. 3
    static const uint32_t frequencies[] = {
    #include "frequencies.h"
    };

    codemonkey, 21 Апреля 2015

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

    +142

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

    artembegood, 20 Апреля 2015

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

    +105

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

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

    Vindicar, 20 Апреля 2015

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