1. Куча / Говнокод #27778

    0

    1. 1
    https://twitter.com/RCS/status/1452367702727831565

    Ай, Молодца !!!

    gne4do, 31 Октября 2021

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

    +1

    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
    if (op.size() == 1)
    				{
    					if (op[0].id == LexemID::REGISTER)
    					{
    						if (isSIBbase(registerName2registerId.at( std::get<std::string>(op[0].lexemas))))
    							mnemonic.mnemonics.emplace_back(IndirectAddress{
    								.base = Register(std::get<std::string>(op[0].lexemas))
    								});
    						else
    							mnemonic.mnemonics.emplace_back(IndirectAddress{
    								.index = Register(std::get<std::string>(op[0].lexemas))
    								});
    					}
    					else if (op[0].id == LexemID::LABEL_USE)
    						mnemonic.mnemonics.emplace_back(IndirectAddress{
    							.disp = LabelUse(std::get<std::string>(op[0].lexemas))
    							});
    					else if (op[0].id == LexemID::NUMBER)
    						mnemonic.mnemonics.emplace_back(IndirectAddress{
    							.disp = Constant(std::get<int>(op[0].lexemas))
    							});
    				}
    				else if (op.size() == 3)
    				{
    					if (const auto operation = std::get<std::string>(op[1].lexemas)[0]; operation == '+')
    					{
    						if (op[0].id == LexemID::REGISTER && op[2].id == LexemID::REGISTER)
    						{
    							if (isSIBbase(registerName2registerId.at(std::get<std::string>(op[0].lexemas))))
    								mnemonic.mnemonics.emplace_back(IndirectAddress{
    									.base = Register(std::get<std::string>(op[0].lexemas)),
    									.index = Register(std::get<std::string>(op[2].lexemas))
    									});
    							else
    								mnemonic.mnemonics.emplace_back(IndirectAddress{
    									.base = Register(std::get<std::string>(op[2].lexemas)),
    									.index = Register(std::get<std::string>(op[0].lexemas))
    									});
    						}
    						else if (op[0].id == LexemID::REGISTER && op[2].id == LexemID::NUMBER)
    						{
    							if (isSIBbase(registerName2registerId.at(std::get<std::string>(op[0].lexemas))))
    								mnemonic.mnemonics.emplace_back(IndirectAddress{
    									.base = Register(std::get<std::string>(op[0].lexemas)),
    									.disp = Constant(std::get<int>(op[2].lexemas))
    									});
    							else
    								mnemonic.mnemonics.emplace_back(IndirectAddress{
    									.index = Register(std::get<std::string>(op[0].lexemas)),
    									.disp = Constant(std::get<int>(op[2].lexemas))
    									});
    						}
    						else if (op[0].id == LexemID::REGISTER && op[2].id == LexemID::LABEL_USE)
    						{
    							if (isSIBbase(registerName2registerId.at(std::get<std::string>(op[0].lexemas))))
    								mnemonic.mnemonics.emplace_back(IndirectAddress{
    									.base = Register(std::get<std::string>(op[0].lexemas)),
    									.disp = LabelUse(std::get<std::string>(op[2].lexemas))
    									});
    							else
    								mnemonic.mnemonics.emplace_back(IndirectAddress{
    								.index = Register(std::get<std::string>(op[0].lexemas)),
    								.disp = LabelUse(std::get<std::string>(op[2].lexemas))
    									});
    						}
    					}
    					else if (operation == '*')
    					{
    						if (op[0].id == LexemID::NUMBER && op[2].id == LexemID::REGISTER)
    							mnemonic.mnemonics.emplace_back(IndirectAddress{
    								.base = Register(std::get<std::string>(op[2].lexemas)),
    								.scale = static_cast<uint8_t>(std::get<int>(op[0].lexemas))
    								});
    					}
    				}
    				else if(op.size() == 5)
    				{
    
    					if (op[4].id == LexemID::REGISTER)
    						mnemonic.mnemonics.emplace_back(IndirectAddress{
    							.base  = Register(std::get<std::string>(op[4].lexemas)),
    							.index = Register(std::get<std::string>(op[2].lexemas)),
    							.scale = static_cast<uint8_t>(std::get<int>(op[0].lexemas))
    							});
    					else if (op[4].id == LexemID::NUMBER)
    						mnemonic.mnemonics.emplace_back(IndirectAddress{
    							.index = Register(std::get<std::string>(op[2].lexemas)),
    							.scale = static_cast<uint8_t>(std::get<int>(op[0].lexemas)),
    							.disp = Constant(std::get<int>(op[4].lexemas))
    							});
    					else if (op[4].id == LexemID::LABEL_USE)
    						mnemonic.mnemonics.emplace_back(IndirectAddress{
    							.index = Register(std::get<std::string>(op[2].lexemas)),
    							.scale = static_cast<uint8_t>(std::get<int>(op[0].lexemas)),
    							.disp = LabelUse(std::get<std::string>(op[4].lexemas))
    							});
    ...

    чё к щам близко?

    https://github.com/kcalbSphere/PVC-16/blob/master/pvc-asm/syntaxer.cpp

    digitalEugene, 31 Октября 2021

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

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    // a.h
    inline struct $q1 {unsigned a;} $q1i;
    
    // main.cpp
    #include "a.h"
    int main(int argc, char** args) 
    {
        $q1i.a = argc; 
        return $q1i.a;
    };

    у некоторых линукс-юзеров может упасть на этапе линковки

    digitalEugene, 31 Октября 2021

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

    0

    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
    #define REGISTERS_LIST A, B, C, D, E, SI, BP, SP, IP
    #define LREGISTERS_LIST AH, AL, BH, BL, CH, CL, DH, DL, EH, EL, SIH, SIL, BPH, BPL, SPH, SPL, IPH, IPL
    
    enum RegisterID
    {
    	REGISTERS_LIST,
    	LREGISTERS_LIST
    };
    
    const static std::string registerId2registerName[] = {
    #define _MAP(x) #x
    	MAP_LIST(_MAP, REGISTERS_LIST),
    	MAP_LIST(_MAP, LREGISTERS_LIST)
    };
    #undef _MAP
    
    const static std::map<std::string, RegisterID> registerName2registerId = {
    #define _MAP(x) {#x, x}
    	MAP_LIST(_MAP, REGISTERS_LIST),
    	MAP_LIST(_MAP, LREGISTERS_LIST)
    };
    #undef _MAP

    покруче гомоиконности

    digitalEugene, 30 Октября 2021

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    const boost::escaped_list_separator<char> els("\\"s, " \n\t"s, "\"");
    
    boost::replace_all(src, "\"", "\"\\\"");
    const boost::tokenizer tok(src, els);

    els не умеет в keeping quotes хнык хнык

    digitalEugene, 30 Октября 2021

    Комментарии (0)
  6. C# / Говнокод #27773

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private List<OutputData> AddSomeSpecialStateToFoo(
                List<OutputData> foos,
                IDictionary<Guid, SomeSpecialState> fooStates)
            {
                foreach(var foo in foos)
                {
                    foo .State = fooStates.FirstOrDefault(x => x.Key == cam.FooId).Value;
                }
    
                return foos;
            }

    Митируем листы и юзаем словарь правильно.

    LozorcevDiyosha, 29 Октября 2021

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

    0

    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
    interface Something {
        r: number;
        g: number;
        b: number;
        toString: () => string;
    }
    
    function main() {
        const something = {
            r: 11.0, g: 12.0, b: 13.0, toString() {
                return "Hello " + this.b;
            }
        };
    
        const iface = <Something>something;
        print(iface.toString());
    
        print("done.");
    }

    Интерфесы для абстрактых обьектов.. а ваш говно компилятор может так?

    ASD_77, 28 Октября 2021

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    Щас продукты перетекают в сервисы, разработка ПО делится на фронт и бэк, всякие аджайлоскрамы со спринтами, 
    ретро и бэклог-ревью, автотесты, проверить работает ли код можно на лету. 
    
    А как выглядела работа у разработчиков ПО в начале 10-х, 00-х, 90-х? 
    Как контролировали выполнение задач? 
    Насколько часто переключались на проверку работоспособности кода?
    Как тестили приложения с GUI (десктоп, игры всякие)? 
    Какие задачи давали на техническом интервью кандидатам?

    JaneBurt, 27 Октября 2021

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

    0

    1. 1
    Давайте флудить и троллить ;-)

    Давайте флудить и троллить ;-)

    bot_batbot_batbot, 27 Октября 2021

    Комментарии (6)
  10. bash / Говнокод #27769

    +4

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    #!/usr/bin/env bash
    
    URL=https://foo.bar/baz.zip
    PATH=/home/foo/bar/baz.zip
    
    wget -O "$PATH" "$URL"

    И только потом до мена дошло…

    ISO, 26 Октября 2021

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