1. Си / Говнокод #27693

    +1

    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
    #include <stdio.h>
    #include <memory>
    #define Property(type,name) type name;auto &set_##name(type val){name = val; return *this;}
    #define Set(x,y) set_##x(y)
    
    //#define Create(type, ...) (*(new type(__VA_ARGS__)))
    
    template <typename T>
    static inline T& Create_(const char *name)
    {
        return *(new T(name));
    }
    #define Create(type, ...)  Create_<type>(__VA_ARGS__)
    
    template <typename T>
    static inline T CreateNoAlloc_(const char *name)
    {
        return T(name);
    }
    #define CreateNoAlloc(type, ...)  CreateNoAlloc_<type>(__VA_ARGS__)
    
    struct BaseItem
    {
        const char *Name;
        BaseItem(const char *n): Name(n) {}
        Property(int, Width);
        Property(int, Height);
    };
    #include <vector>
    struct Markup
    {
        std::vector<BaseItem*> Children;
        template <typename T>
        Markup &Add(T &item)
        {
            Children.push_back(&item);
            return *this;
        }
    };
    
    static inline Markup CreateMarkup(const char *n)
    {
        return Markup();
    }
    /*
    struct Markup2
    {
        std::vector<std::shared_ptr<BaseItem>> Children;
        template <typename T>
        Markup2 &Add(T item)
        {
            Children.push_back(std::shared_ptr(&item));
            return *this;
        }
    };
    */
    
    template<std::size_t I = 0, typename... Tp>
    inline typename std::enable_if<I == sizeof...(Tp), void>::type
      print(std::tuple<Tp...>& t)
      { }
    
    template<std::size_t I = 0, typename... Tp>
    inline typename std::enable_if<I < sizeof...(Tp), void>::type
      print(std::tuple<Tp...>& t)
      {
        printf("%s\n",std::get<I>(t).Name);
        print<I + 1, Tp...>(t);
      }
    
    #include <string.h>
    
    static BaseItem NOT_FOUND("NOT_FOUND");
    
    template<typename T, std::size_t I = 0, typename... Tp>
    inline typename std::enable_if<I == sizeof...(Tp), void>::type
      print1(std::tuple<Tp...>& t, const char *n)
      { }
    
    template<typename T, std::size_t I = 0, typename... Tp>
    inline typename std::enable_if<I < sizeof...(Tp), T&>::type
      print1(std::tuple<Tp...>& t, const char *n)
      {
        if( !strcmp(std::get<I>(t).Name, n))
        return std::get<I>(t);
        print1<T, I + 1, Tp...>(t,n);
        return NOT_FOUND;
      }
    
    
    #define CreateMarkup(...) std::make_tuple(__VA_ARGS__)
    #define AppendMarkup(src, ...) std::tuple_cat(src, std::make_tuple(__VA_ARGS__))
    #define MarkupItem(markup,type,name,action) namespace {type &i = print1<type>(markup,name).action; }
    
    auto markup1 = CreateMarkup(BaseItem("test").Set(Width,14), BaseItem("test2"));
    auto markup2 = AppendMarkup(markup1,BaseItem("test3").Set(Width,15));
    auto markup3 = markup1;
    MarkupItem(markup3,BaseItem,"test2",Set(Width,16));
    
    template <typename T>

    Т.к юзается препроцессор, запощу в C

    mittorn, 29 Сентября 2021

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

    +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
    function main() {
        let c = 0;
    
        try {
            c++;
            print("try");
            throw "except";
            c--;
            print("after catch");
        } finally {
            c++;
            print("finally");
        }
    
        assert(2 == c);
    }

    ну вот и все... проимплементил последний keyword в языке... (осталось только темплейты - ну и головняк меня ждем)

    ASD_77, 29 Сентября 2021

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

    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
    // этот код дает Segment Fault
    
    struct TypeNames
    {
        std::string typeName;
    };
    
    class LLVMRTTIHelperVCLinux
    {
        SmallVector<TypeNames> types;
    }
    
    // a этот нет
    
    class LLVMRTTIHelperVCLinux
    {
        SmallVector<std::string> types;
    }

    ну и гавно этот ваш Clang. MSVC работает, GCС работает а Clang нет

    ASD_77, 29 Сентября 2021

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

    −1

    1. 1
    Здесь будут опубликованы пароли от учётных записей

    Lokich, 29 Сентября 2021

    Комментарии (78)
  5. Pascal / Говнокод #27689

    +1

    1. 1
    2. 2
    3. 3
    Ой, девачьки, я 5 лет не заходило. Почему нет говнокодов на Дульфи? Я десять страниц промотал! Неужели все дульфисты впали 
    в старческий маразм и не могут больше срать на этом недоязыке? Почему? Он же изначально создавался для даунов.
    Что стало с Тарасом? Что стало с поняшей-ассемблеристом?

    Только одфаги меня вспомнят.

    DelphiGovno, 28 Сентября 2021

    Комментарии (96)
  6. JavaScript / Говнокод #27688

    +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
    alex@ASD-PC:~/TypeScriptCompiler/3rdParty/llvm-wasm/debug/bin$ node mlir-translate.js --help
    OVERVIEW: MLIR Translation Testing Tool
    USAGE: mlir-translate.js [options] <input file>
    
    OPTIONS:
    
    Color Options:
    
      --color                                              - Use colors in output (default=autodetect)
    
    General options:
    
      --dot-cfg-mssa=<file name for generated dot file>    - file name for generated dot file
      --mlir-disable-threading                             - Disabling multi-threading within MLIR
      --mlir-elide-elementsattrs-if-larger=<uint>          - Elide ElementsAttrs with "..." that have more elements than the given upper limit
      --mlir-pretty-debuginfo                              - Print pretty debug info in MLIR output
      --mlir-print-debuginfo                               - Print debug info in MLIR output
      --mlir-print-elementsattrs-with-hex-if-larger=<long> - Print DenseElementsAttrs with a hex string that have more elements than the given upper limit (use -1 to disable)
      --mlir-print-op-on-diagnostic                        - When a diagnostic is emitted on an operation, also print the operation as an attached note
      --mlir-print-stacktrace-on-diagnostic                - When a diagnostic is emitted, also print the stack trace as an attached note
      -o=<filename>                                        - Output filename
      --split-input-file                                   - Split the input file into pieces and process each chunk independently
      Translation to perform
          --deserialize-spirv                                 - deserialize-spirv
          --import-llvm                                       - import-llvm
          --mlir-to-llvmir                                    - mlir-to-llvmir
          --serialize-spirv                                   - serialize-spirv
          --test-spirv-roundtrip                              - test-spirv-roundtrip
          --test-spirv-roundtrip-debug                        - test-spirv-roundtrip-debug
      --verify-diagnostics                                 - Check that emitted diagnostics match expected-* lines on the corresponding line
    
    Generic Options:
    
      --help                                               - Display available options (--help-hidden for more)
      --help-list                                          - Display list of available options (--help-list-hidden for more)
      --version                                            - Display the version of this program
    program exited (with status: 0), but EXIT_RUNTIME is not set, so halting execution but not exiting the runtime or preventing further async execution (build with EXIT_RUNTIME=1, if you want a true shutdown)
    alex@ASD-PC:~/TypeScriptCompiler/3rdParty/llvm-wasm/debug/bin$

    сказ о том как я LLVM на WASM компилял :)

    ASD_77, 28 Сентября 2021

    Комментарии (21)
  7. Lua / Говнокод #27687

    −2

    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
    function throw_artefact(obj)
    	if obj==nil then
    		return
    	end
    	math.randomseed(time_global())
    	local rnd=math.random(10)
    	local sect = obj:section()
    	local lv = obj:level_vertex_id()
    	local gv = obj:game_vertex_id()
    	local pos = obj:position()
    	local off_x = 2
    	local off_y = 1.5
    	local off_z = 2
    	pos.x = pos.x + off_x
    	pos.y = pos.y + off_y
    	pos.z = pos.z + off_z	
    	if lv and gv and pos then
    		math.randomseed(time_global())
    		if string.find(sect, "witches") then			
    			if string.find(sect, "weak") then
    				math.randomseed(time_global())
    				if math.random(4) == 1 then alife():create("af_electra_sparkler", pos, lv, gv) end
    			elseif string.find(sect, "average") then
    				math.randomseed(time_global())
    				if math.random(6) == 1 then alife():create("af_electra_sparkler", pos, lv, gv) end
    				if math.random(4) == 1 then alife():create("af_electra_flash", pos, lv, gv) end
    			else
    				math.randomseed(time_global())
    				if math.random(4) == 1 then alife():create("af_electra_moonlight", pos, lv, gv) end
    				if math.random(5) == 1 then alife():create("af_electra_flash", pos, lv, gv) end
    				if math.random(5) == 1 then alife():create("af_electra_sparkler", pos, lv, gv) end
    			end
    			
    		elseif string.find(sect, "mosquito") then
    			math.randomseed(time_global())
    			if string.find(sect, "weak") then
    				if math.random(6) == 1 then alife():create("af_cristall_flower", pos, lv, gv) end
    			elseif string.find(sect, "average") then
    				if math.random(4) == 1 then alife():create("af_cristall_flower", pos, lv, gv) end
    				if math.random(5) == 1 then alife():create("af_medusa", pos, lv, gv) end
    			else
    				if math.random(6) 	== 1 then alife():create("af_night_star", pos, lv, gv) end
    				if math.random(4)  == 1 then alife():create("af_medusa", pos, lv, gv) end
    				if math.random(5)  == 1 then alife():create("af_cristall_flower", pos, lv, gv) end
    			end
    			
    		elseif string.find(sect, "mincer") then
    			math.randomseed(time_global())
    			if string.find(sect, "weak") then
    				if math.random(6)==1 then alife():create("af_blood", pos, lv, gv) end
    			elseif string.find(sect, "average") then
    				if math.random(5) == 1 then alife():create("af_blood", pos, lv, gv) end
    				if math.random(4) <= 1 then alife():create("af_mincer_meat", pos, lv, gv) end
    			else
    				if math.random(6) == 1 then alife():create("af_soul", pos, lv, gv) end
    				if math.random(4) == 1 then alife():create("af_mincer_meat", pos, lv, gv) end
    				if math.random(5) == 1 then alife():create("af_blood", pos, lv, gv) end
    			end
    			
    		elseif string.find(sect, "gravi") then
    			math.randomseed(time_global())
    			if string.find(sect, "weak") then
    				if math.random(6)==1 then alife():create("af_vyvert", pos, lv, gv) end
    			elseif string.find(sect, "average") then
    				if math.random(4) == 1 then alife():create("af_vyvert", pos, lv, gv) end
    				if math.random(5) <= 1 then alife():create("af_gravi", pos, lv, gv) end
    			else
    				if math.random(6) == 1 then alife():create("af_gold_fish", pos, lv, gv) end
    				if math.random(4) == 1 then alife():create("af_gravi", pos, lv, gv) end
    				if math.random(5) == 1 then alife():create("af_vyvert", pos, lv, gv) end
    			end
    			
    		elseif string.find(sect, "ameba") or string.find(sect, "burning_fuzz") or string.find(sect, "rusty") then
    				math.randomseed(time_global())
    				if math.random(2) == 1 then alife():create("af_rusty_sea-urchin", pos, lv, gv) end
    				if math.random(2) == 1 then alife():create("af_rusty_kristall", pos, lv, gv) end
    				if math.random(2) == 1 then alife():create("af_rusty_thorn", pos, lv, gv) end
    		elseif string.find(sect, "buzz") then
    			if string.find(sect, "weak") then
    				if math.random(6)==1 then alife():create("af_ameba_slug", pos, lv, gv) end
    			elseif string.find(sect, "average") then
    				if math.random(5) == 1 then alife():create("af_ameba_slime", pos, lv, gv) end
    				if math.random(4) <= 1 then alife():create("af_ameba_slug", pos, lv, gv) end
    			else
    				if math.random(5) == 1 then alife():create("af_ameba_mica", pos, lv, gv) end
    				if math.random(5) == 1 then alife():create("af_ameba_slug", pos, lv, gv) end
    				if math.random(4) == 1 then alife():create("af_ameba_slime", pos, lv, gv) end
    			end
    
    elseif string.find(sect, "doggy") then
    			local n=0
    			math.randomseed(time_global())
    			for n=1, math.random(3) do
    				alife():create("dog_weak", pos, lv, gv)
    			end

    Свиток перебирает аномалии на локации и по рандому спавнит в них артефакты.
    Да, блять - мне пришлось изучить луа. Теперь я тоже "золотой хуй".

    Нижние строки отвечают за функционирование самодельной аномалии, которая после полуночи (по ИВ) плодит гипнособак и прочую нечисть. Стаи собак вырезают целые поселения; таким образом, я стал поистине сталкером. Так как я давно фриплею, надо разнообразить ко-ко-корутину.

    CBuHOKYP, 27 Сентября 2021

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

    0

    1. 1
    IT Оффтоп #118

    #88: https://govnokod.ru/27432 https://govnokod.xyz/_27432
    #89: https://govnokod.ru/27435 https://govnokod.xyz/_27435
    #90: https://govnokod.ru/27439 https://govnokod.xyz/_27439
    #91: https://govnokod.ru/27449 https://govnokod.xyz/_27449
    #92: https://govnokod.ru/27460 https://govnokod.xyz/_27460
    #93: https://govnokod.ru/27463 https://govnokod.xyz/_27463
    #94: https://govnokod.ru/27466 https://govnokod.xyz/_27466
    #95: https://govnokod.ru/27473 https://govnokod.xyz/_27473
    #96: https://govnokod.ru/27478 https://govnokod.xyz/_27478
    #97: https://govnokod.ru/27484 https://govnokod.xyz/_27484
    #98: https://govnokod.ru/27495 https://govnokod.xyz/_27495
    #99: https://govnokod.ru/27504 https://govnokod.xyz/_27504
    #100: https://govnokod.ru/27508 https://govnokod.xyz/_27508
    #101: https://govnokod.ru/27511 https://govnokod.xyz/_27511
    #102: https://govnokod.ru/27518 https://govnokod.xyz/_27518
    #103: https://govnokod.ru/27526 https://govnokod.xyz/_27526
    #104: https://govnokod.ru/27534 https://govnokod.xyz/_27534
    #105: https://govnokod.ru/27544 https://govnokod.xyz/_27544
    #106: https://govnokod.ru/27552 https://govnokod.xyz/_27552
    #107: https://govnokod.ru/27554 https://govnokod.xyz/_27554
    #108: https://govnokod.ru/27557 https://govnokod.xyz/_27557
    #109: https://govnokod.ru/27581 https://govnokod.xyz/_27581
    #110: https://govnokod.ru/27610 https://govnokod.xyz/_27610
    #111: https://govnokod.ru/27644 https://govnokod.xyz/_27644
    #112: https://govnokod.ru/27648 https://govnokod.xyz/_27648
    #113: https://govnokod.ru/27652 https://govnokod.xyz/_27652
    #114: https://govnokod.ru/27659 https://govnokod.xyz/_27659
    #115: https://govnokod.ru/27665 https://govnokod.xyz/_27665
    #116: https://govnokod.ru/27671 https://govnokod.xyz/_27671
    #117: https://govnokod.ru/27675 https://govnokod.xyz/_27675

    nepeKamHblu_nemyx, 27 Сентября 2021

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

    +1

    1. 1
    Давайте займёмся анальным сексом.

    .

    pdro11, 26 Сентября 2021

    Комментарии (1)
  10. JavaScript / Говнокод #27681

    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
    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
    const range = (count) => Array.from(Array(count).keys());
    class Matrix {
    
        static Dot(A, B) {
            // Dot production
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != hB)
            {
                throw "A width != B height";
            }
    
            const C = range(hA).map((_, i) => range(wB).map((_, j) => 0));
    
            for (let i = 0; i < hA; ++i)
                for (let j = 0; j < wB; ++j) {
                    let sum = 0;
    
                    for (let k = 0; k < wA; ++k) {
                        const a = A[i][k];
                        const b = B[k][j];
                        sum += a * b;
                    }
    
                    C[i][j] = sum;
                }
    
            return C;                
        }
    
        static Mul(A, B) {
            // Dot production
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != wB || hA != hB)
            {
                throw "A width != B width, A height != B height";
            }
    
            const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] * B[i][j]));
            return C;
        }            
    
        static Add(A, B) {
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != wB || hA != hB)
            {
                throw "A width != B width, A height != B height";
            }
    
            const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] + B[i][j]));
            return C;
        }
    
        static Sub(A, B) {
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != wB || hA != hB)
            {
                throw "A width != B width, A height != B height";
            }
    
            const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] - B[i][j]));
            return C;
        }
    
            static Translate(A, shift) {
            const wA = A[0].length;
            const hA = A.length;
    
            const R = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] + shift));
            return R;                        
        }         
    
        static Sigmoid(A) {
            const wA = A[0].length;
            const hA = A.length;
    
            const R = range(hA).map((_, i) => range(wA).map((_, j) => 1 / (1 + Math.exp(-A[i][j]))));
            return R;                                        
        }
    //...
    }

    лаба по математике матрици :)

    ASD_77, 26 Сентября 2021

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