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

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

    +143

    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 postUrl(path, params, method) {
    	if ($('#service-form').length > 0) {
    		return false;
    	}
        var formHtml = '<form action="' + path + '" method="' + method + '" style="display:none;" id="service-form">';
        for(var key in params) {
            formHtml += '<input type="hidden" name="' + key + '" value="' + params[key] + '" />';
        }
        formHtml += '</form>';
    
        $("#main").append(formHtml);
        $("#service-form").submit();
    }

    Игра МосВар

    Vasiliy, 12 Мая 2011

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

    +146

    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
    #include <stdio.h>
    
    #define BELL '\a'
    #define TACT {for (i = 0; i < 100000000; i++) ;}
    #define HALFTACT {for (i = 0; i < 20000000; i++) ;} 
    
    int main ()
    {
    	int i;
    	putchar(BELL);
    	TACT;
    	putchar(BELL);
    	TACT;
    	putchar(BELL);
    	HALFTACT
    	putchar(BELL);
    	HALFTACT
    	putchar(BELL);
    	TACT;
    	putchar(BELL);
    	HALFTACT;
    	putchar(BELL);
    	HALFTACT;
    	putchar(BELL);
    	HALFTACT;
    	putchar(BELL);
    	TACT;
    	putchar(BELL);
    	HALFTACT;
    	putchar(BELL);
    	return 0;
    }

    Ну хоть что-то автоматизировал...

    dwinner, 16 Января 2011

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

    +124

    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
    /// <summary>
            /// Return "Yes" for true and "No" for false
            /// </summary>
            public static string GetYesNoString(this bool val) 
            {
                return val ? "Yes" : "No";
            }
    
            /// <summary>
            /// Return "N/A" if no value, "Yes" for true and "No" for false
            /// </summary>
            public static string GetYesNoString(this object val)
            {            
                if(val is bool)
                    return ((bool)val).GetYesNoString();
    
                return "N/A";
            }

    Extension of the object class :) Very stupid because it make sense only for bool type, but it can be selected for every type in intellisense :)

    bugotrep, 27 Декабря 2010

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

    +151

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    function pro($input) { 
    $input=str_replace("\0", '_', $input); 
    $input=trim($input); 
    $input=strtr($input,array('!'=>'&#33;','"'=>'&#34;','$'=>'&#36;','%'=>'&#37;',"'"=>"&#39;",'('=>'&#40;',')'=>'&#41;','*'=>'&#42;','+'=>'&#43;',','=>'&#44;','-'=>'&#45;','.'=>'&#46;','/'=>'&#47;',':'=>'&#58;','<'=>'&#60;','='=>'&#61;','>'=>'&#62;','?'=>'&#63;','@'=>'&#64;','['=>'&#91;','\\'=>'&#92;',']'=>'&#93;','^'=>'&#94;','_'=>'&#95;','`'=>'&#96;','{'=>'&#123;','|'=>'&#124;','}'=>'&#125;','~'=>'&#126;')); 
    return $input; 
    } 
    
    function depro($input) { 
    $input=strtr($input,array('&#33;'=>'!','&#34;'=>'"','&#36;'=>'$','&#37;'=>'%',"&#39;"=>"'",'&#40;'=>'(','&#41;'=>')','&#42;'=>'*','&#43;'=>'+','&#44;'=>',','&#45;'=>'-','&#46;'=>'.','&#47;'=>'/','&#58;'=>':','&#60;'=>'<','&#61;'=>'=','&#62;'=>'>','&#63;'=>'?','&#64;'=>'@','&#91;'=>'[','&#92;'=>'\\','&#93;'=>']','&#94;'=>'^','&#95;'=>'_','&#96;'=>'`','&#123;'=>'{','&#124;'=>'|','&#125;'=>'}','&#126;'=>'~')); 
    return $input; 
    }

    во всяком случае аффтар считает что это действительно защита не в рот ибацца, anti sql inj.. это вам не это.

    GoodTalkBot, 24 Августа 2010

    Комментарии (76)
  6. PHP / Говнокод #3587

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    function banByIP($ip) {
    	$result = mysql_query("SELECT * FROM `" . $GLOBALS['mysql_bans_table'] . "` WHERE `ip` = '" . mysql_real_escape_string($ip) . "' LIMIT 1");
    	while ($ban = mysql_fetch_assoc($result)) {
    		return $ban;
    	}
    }

    Из движка TinyIB.

    telnet, 29 Июня 2010

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

    +159

    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 a w[p]++;              // a +  add
    #define s w[p]--;              // s -  subtract
    #define m p++;                 // m >  more
    #define l p--;                 // l <  less
    #define b while(w[p]) {        // b [  begin
    #define e }                    // e ]  end
    #define o putchar(w[p]);       // o .  out
    #define i w[p]=getchar();      // i ,  in
    
    void main()
    {
      int w[1024];
      int p = 0;
      int _ = 1024;
      while (_--) w[_] = 0;
    
      m a a a a b l a a a a a a a a a a a a a a a a m s e l a a a a a a a a o m a a
      b l a a a a a a a a a a a a a a a a m s e l s s s o a a a a a a a o o a a a o
      m a a a a a b l s s s s s s s s s s s s s s s s m s e l a o m a a a b l a a a
      a a a a a a a a a a a a a m s e l a a a a a a a o a a a a a a a a a a a a a a
      a a a a a a a a a a o a a a o s s s s s s o s s s s s s s s o i
    }

    Fuck my brain...
    По мотивам http://daniel.lorch.cc/projects/brainfuck/php-brainfuck-1.01/doc.html

    Stalker, 29 Мая 2010

    Комментарии (76)
  8. SQL / Говнокод #28896

    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
    Новогодний оффтоп #4
    ░░░░░░░░░░░░░░░░░▐▌░░░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░▀████▀░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░▄█▀▀█▄░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░░▄▄░░░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░▄████▄░░░░░░░░░░░░░░░
    ░░░░░░░░░░░▄▄██╬██╬████▄▄░░░░░░░░░░░
    ░░░░░░░░▀███████╬███╬██████▀░░░░░░░░
    ░░░░░░░░░░▄▄█╬████╬█████▄▄░░░░░░░░░░
    ░░░░▄▄▄▄██╬████╬█████╬███╬██▄▄▄▄░░░░
    ░░░░░░▀▀████╬█████╬█████████▀▀░░░░░░
    ░░░░░░░░░▄█████╬██████╬███▄░░░░░░░░░
    ░░▄▄▄▄██████╬█████╬███████╬███▄▄▄▄░░
    ░░▀▀▀████╬█████╬████╬███╬██████▀▀▀░░
    ░░░░░░░░████╬████████╬██████░░░░░░░░
    ░░▄▄▄█████╬██████╬█████╬███╬███▄▄▄░░
    ▀▀▀████╬█████╬█████╬████╬███╬████▀▀▀
    ░░░░░░▀▀▀██████████████████▀▀▀░░░░░░
    ░░░░░░░░░░░░░░░░████░░░░░░░░░░░░░░░░
    ░░░░░░░░░░░░░░░░████░░░░░░░░░░░░░░░░

    #1: https://govnokod.ru/27188 https://govnokod.xyz/_27188
    #2: https://govnokod.ru/27893 https://govnokod.xyz/_27893
    #2: https://govnokod.ru/28484 https://govnokod.xyz/_28484

    Milochocientos, 01 Января 2024

    Комментарии (75)
  9. Assembler / Говнокод #28812

    0

    1. 1
    2. 2
    3. 3
    E       2     2
    M  X = A  + B
    S            I

    Угадайте, на каком языке программирования написан этот код.

    В поле "Язык" есть подсказка.

    JloJle4Ka, 01 Июля 2023

    Комментарии (75)
  10. Java / Говнокод #28118

    +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
    public class Spot {
        private Piece piece;
        private int x;
        private int y;
      
        public Spot(int x, int y, Piece piece)
        {
            this.setPiece(piece);
            this.setX(x);
            this.setY(y);
        }
      
    
        public Piece getPiece() // метод возвращает объект фигуру
        {
            return this.piece;
        }
      
        public void setPiece(Piece p)
        {
            this.piece = p;
        }
      
        public int getX()
        {
            return this.x;
        }
      
        public void setX(int x)
        {
            this.x = x;
        }
      
        public int getY()
        {
            return this.y;
        }
      
        public void setY(int y)
        {
            this.y = y;
        }
    }

    Дизайн шахматной игры
    Эти виды вопросов задаются на интервью, чтобы судить о навыке объектно ориентированного дизайна кандидата. Итак, прежде всего, мы должны подумать о классах.
    https://habr.com/ru/post/660003/

    ISO, 10 Апреля 2022

    Комментарии (75)
  11. C++ / Говнокод #26983

    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
    #include <cstdlib>
    #include <chrono>
    #include <iostream>
    #include <thread>
    
    int p = 0;
    int *q = nullptr;
    
    void g()
    {
        using namespace std::chrono_literals;
    
        std::cout << "g()" << std::endl;
    
        std::cout << "g(): p = 1" << std::endl;
        p = 1;
    
        std::this_thread::sleep_for(1s);
    
        
        if (q != nullptr) {
            std::cout << "g(): *q = 1" << std::endl;
            *q = 1;
        } else {
            std::cout << "g(): q == nullptr" << std::endl;
        }
    }
    
    void f()
    {
        using namespace std::chrono_literals;
    
        std::cout << "f()" << std::endl;
    
        if (p == 0) {
            std::cout << "f(): first loop start" << std::endl;
            while (p == 0) { }  // Потенциально конечный
            std::cout << "f(): first loop end" << std::endl;
        }
    
        int i = 0;
        q = &i;
        std::cout << "f(): second loop start" << std::endl;
        while (i == 0) { }  // Потенциально конечный, хотя в условии только автоматическая пельменная
        std::cout << "f(): second loop end" << std::endl;
    }
    
    int main()
    {
        using namespace std::chrono_literals;
    
        std::cout << "f() thread start" << std::endl;
        auto thr1 = std::thread(f);
        thr1.detach();
        std::this_thread::sleep_for(1s);
    
        std::cout << "g() thread start" << std::endl;
        auto thr2 = std::thread(g);
        thr2.detach();
        std::this_thread::sleep_for(2s);
    
        std::cout << "Done" << std::endl;
        
        std::_Exit(EXIT_SUCCESS);
    }

    Ожидание:

    f() thread start
    f()
    f(): first loop start
    g() thread start
    g()
    g(): p = 1
    f(): first loop end
    f(): second loop start
    g(): *q = 1
    f(): second loop end
    Done

    gost, 28 Сентября 2020

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