1. Лучший говнокод

    В номинации:
    За время:
  2. C++ / Говнокод #28181

    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
    97. 97
    class Memory 
     { 
     public: 
             Memory() : hProcess{ nullptr }, pID{ 0 } {} 
             ~Memory() { SafeCloseHandle(hProcess); } 
      
             bool Attach(const char* _Process, DWORD rights) 
             { 
                     HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 
      
                     if (hSnap == INVALID_HANDLE_VALUE) 
                             return false; 
      
                     PROCESSENTRY32 pe{ sizeof(PROCESSENTRY32) }; 
      
                     while (Process32Next(hSnap, &pe)) 
                             if (!strcmp(pe.szExeFile, _Process)) 
                             { 
                                     SafeCloseHandle(hSnap); 
                                     pID = pe.th32ProcessID; 
      
                                     hProcess = OpenProcess(rights, 0, pe.th32ProcessID); 
      
     #ifdef _DEBUG || DEBUG 
                                     if (hProcess) // Ok 
                                     { 
                                             std::cout << "Attaching to process: " << _Process << " -> "; 
                                             ColoredMessage("OK!", LGREEN, true); 
                                     } 
     #endif // DEBUG 
      
                                     return true; 
                             } 
      
     #ifdef _DEBUG || DEBUG 
                     std::cout << "Attaching to process: " << _Process << " -> "; 
                     ColoredMessage("FAIL!", LRED, true); 
     #endif // DEBUG 
      
                     SafeCloseHandle(hSnap); 
                     return false; 
             } 
      
             PModule GetModule(const char* _Module) 
             { 
                     HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pID); 
      
                     if (hSnap == INVALID_HANDLE_VALUE) 
                             return PModule{ 0, 0 }; 
      
                     MODULEENTRY32 mEntry{ sizeof(MODULEENTRY32) }; 
      
                     while (Module32Next(hSnap, &mEntry)) 
                             if (!strcmp(mEntry.szModule, _Module)) 
                             { 
                                     SafeCloseHandle(hSnap); 
      
                                     return PModule{ (DWORD)mEntry.hModule, mEntry.modBaseSize }; 
                             } 
      
     #ifdef _DEBUG || DEBUG 
                     std::cout << "Getting module: "; ColoredMessage("FAIL!", LRED, true); 
     #endif // DEBUG 
      
      
                     SafeCloseHandle(hSnap); 
                     return PModule{ 0, 0 }; 
             } 
      
             template <class _Ty> 
             _Ty read(DWORD _Addr) 
             { 
                     DWORD _dwRead; 
                     _Ty _Val; 
      
     #ifdef _DEBUG || DEBUG  
                     if (!ReadProcessMemory(hProcess, (LPCVOID)_Addr, &_Val, sizeof(_Ty), &_dwRead)) 
                     { 
                             std::cout << "Reading the memory: "; 
                             ColoredMessage("FAIL!", LRED, true); 
                     } 
     #else // DEBUG  
                     ReadProcessMemory(hProcess, (LPCVOID)_Addr, &_Val, sizeof(_Ty), &_dwRead) 
     #endif 
                             return _Val; 
             } 
      
             template <class _Ty> 
             void write(DWORD _Addr, _Ty _Val) 
             { 
                     DWORD _dwWrite; 
      
     #ifdef _DEBUG || DEBUG  
                     if (!WriteProcessMemory(hProcess, (LPVOID)_Addr, &_Val, sizeof(_Ty), &_dwWrite)) 
                     { 
                             std::cout << "Writing the memory: "; 
                             ColoredMessage("FAIL!", LRED, true);

    Ладно.

    Ddddddddd, 22 Мая 2022

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

    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
    #include <stdio.h>
    #include <setjmp.h>
    #include <assert.h>
    
    jmp_buf ebuf;
    
    void f2(void)
    {
    	longjmp(ebuf, (int)"kokoko");
    }
    
    int main(void)
    {
    	const char* i;
    	printf("petuhi ");
    	i = (const char*)setjmp(ebuf);
    	if (!i) 
    	{
    		f2();
    		printf ("moo ");
    	}
    	printf("%s\n", i);
    	return 0;
    }

    можно елду сделать

    digitalEugene, 14 Февраля 2022

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

    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
    function some<T>(arr: T[], f: (it: T) => boolean) : boolean
    {
    	let r = false;
    	for (const v of arr) if (r ||= f(v)) break;
    	return r;
    }
    
    function main() {
        let str = [1.0, 2.0, 3.0];
        assert(some(str, (x => x == 2.0)), "sometrue");
        assert(!some(str, (x => x < 0)), "somefalse");
        print("done.");
    }

    Ну что скажите про мои "генерики" ? вам нравиться? А кто знает какой челенж я тут проходил пока написал эту часть компилятора... (даю подстказку - проблема в определении типов для лямбды)

    ASD_77, 02 Февраля 2022

    Комментарии (17)
  5. PHP / Говнокод #27898

    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
    function normalizeUrl($url)
    {
        if (strpos($url, 'http://') === 0) {  
             $domain = substr($url, 7);
         } elseif (strpos($url, 'https://') === 0) {
              $domain = substr($url, 8);
         } else {
              $domain = $url;
         }
    
         return "https://{$domain}";
    }

    YpaHeLI_, 27 Декабря 2021

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

    +2

    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
    % Totoro sitting in the snow
    % By Noa Hoffmann and Pascal Günthner, 21.12.2020
    \documentclass[tikz,11pt]{{standalone}}
    \usepackage{calligra}
    \usepackage[T1]{fontenc}
    \usetikzlibrary{%
      shapes, shadows, patterns, calc,
      decorations.shapes,
      decorations.fractals,
      decorations.markings,
      decorations.pathmorphing
    }
    
    \colorlet{bodycolor}{black!35!gray!60!brown!98!green}
    \colorlet{bellycolor}{yellow!70!white!92!green}
    
    \tikzset{
       furspot/.pic = {
        \path [draw = black, thick, fill] (0,0)    
        .. controls +(0.3,0)        and  +(0.25,-0.05)   ..  ++(0.35,-.45)
        .. controls +(-0.45,0.25)   and  +(0.1,0)        ..  ++(-0.85,-0.05)
        .. controls +(-0.3,0.1)     and  +(-0.4, 0)      ..  cycle;
       },
       claw/.pic = {
        \path [fill = bodycolor!70, draw] (0,0) arc (0:45:0.2 and 0.8)
                                               arc (135:180:0.2 and 0.8)
        arc (180:360:0.059) -- cycle;
       },
       whiskers/.pic = {
        \path [fill = bodycolor!70,draw] (0,0) arc (0:45:0.05 and 2.3)
                                            arc (135:180:0.3 and 2.3)
        to[out=-90,in=-90] cycle;
       },
       snowflake/.pic = {
       \fill [decoration = Koch snowflake, white] decorate{ decorate{
              decorate{ (-0.5,-0.3) -- ++(60:1) -- ++(-60:1) -- cycle }}};
       \foreach \i in {30, 90, 150, 210, 270, 330} {
            \draw[blue!50!white,very thin] (0,0) -- +(\i:0.3);
            }
        \draw[decoration = Koch snowflake, blue!50!white, very thin]
              decorate{($(0,0)+(60:0.2)$) -- ($(0,0)+(300:0.2)$) --
                       ($(0,0)+(180:0.2)$) -- cycle};
       }
    }
    \tikzset{
      snow/.style   = {decoration = {random steps, segment length = 2mm,
                       amplitude = 0.4mm}, decorate},
      plush/.style  = {decoration = {random steps, segment length = 1mm,
                       amplitude = 0.5mm},decorate}
    }
    
    \begin{document}
    \begin{tikzpicture}[color = bodycolor, draw = black, thick]
    
    %---------------------background and tail----------------------
    % blue sky
    \fill[blue!30!white] (-8cm,-11cm) rectangle (8cm,10cm);
    % random snowflakes
    \foreach \i in {0.1,0.11,...,1}{
      \pic [scale = \i, opacity = 0.9] at (rand*7.5, rnd*18-10.5) {snowflake};}
    % more tiny snowflakes
    %\foreach \i in {0.1,0.11,...,0.5}{
      %\pic [scale = \i, opacity = 0.9] at (rand*7.5, rnd*18-10.5) {snowflake};}
    % cloud with merry christmas
    \node [cloud,aspect = 6.5, cloud puff arc = 120, cloud puffs = 12.9, fill = white,
           color = white] at (0,7) {\Huge M \hspace{9.8cm}.};
    \node [color = red] at (0,7) {\fontsize{50}{80}
                                  \textbf{Merry Christmas \quad }};
    % tail
    \path [draw, fill, rotate = 50] (-4,-7.5) circle (1.5 and 2.2);
    % snowhill
    \fill [draw, gray!6, snow] (-8,-11) to[in=200, out=0] (-3,-7.5) to (3,-7.5)
          to[out=-20, in=180] (8,-11);
    
    %--------------------body-----------------------------------------
    % right ear
    \path [fill, draw] (0.6,2.3)+(-45:1) arc (-60:35:1 and 1.5) 
                       arc (115:210:1 and 1.5);
    % left ear
    \path [fill, draw] (-0.6,2.3)+(-135:1) arc (-120:-215:1 and 1.5)
                       arc (65:-30:1 and 1.5);
    % head
    \path [draw, fill] ($(0,0)+(170:2.5 and 2)$) arc (170:10:2.5 and 2)
                       arc(35:-20: 3 and 2)
            -- ($(0,-0.8)+(200:3 and 2)$) arc (200:145:3 and 2) -- cycle;
    % body
    \path[fill] ($(0,-4)+(200:4 and 4.5)$) arc (200:-20:4 and 4.5);
    
    %----------------------face----------------------------------------
    % left eye
    \path [draw, fill = white] (-1.4,0.7) circle (0.45 and 0.4);
    \fill [black] (-1.2,0.7) circle (0.16);
    \fill [white] (-1.24,0.74) circle (0.03);
    % right eye
    \path [draw, fill = white, thick] (1.4,0.7) circle (0.4);
    \fill [black] (1.25,0.7) circle (0.16);
    \fill [white] (1.20,0.74) circle (0.03);
    % nose
    \path [draw] (0.35, 0.7) .. controls (0.2,0.8) and (-0.2, 0.8)
                             .. (-0.35, 0.7);

    Какое аниме ))) https://texample.net/tikz/examples/totoro/

    CHayT, 08 Октября 2021

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    #include <iostream>
    
    int main() {
        std::cout << "Hello, shhhit!";
    }

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

    Комментарии (17)
  8. 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)
  9. JavaScript / Говнокод #27630

    −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
    function* foo() {
        let i = 1;
        while (i < 10)
    	    yield ++i;
    }
    
    function main() {
        for (const o of foo()) {
            print(o);
        }
    
        print("done.");
    }

    возрадуйтесь браться и сестры .. я вам благую весть принес... наконец-то я доделал это ..говно.. и "елдаки" теперь работают нормально.

    ASD_77, 30 Августа 2021

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

    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
    let glb1 = 0;
    
    function doubleIt(f: (x: number) => number) {
        return f(1) - f(2);
    }
    
    function testLambdas() {
        let x = doubleIt(k => k * 108);
    
        assert(x == -108, "l0");
    }
    
    function main() {
        testLambdas();
        print("done.");
    }

    я вам еще принес новых фич.

    ASD_77, 20 Июля 2021

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

    0

    1. 1
    А куда пропал инканус?

    OCETuHCKuu_nemyx, 27 Апреля 2021

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