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

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

    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
    interface Animal {
      live(): void;
    }
    interface Dog extends Animal {
      woof(): void;
    }
     
    type Example1 = Dog extends Animal ? number : string;
     
    type Example2 = RegExp extends Animal ? number : string;
    
    function main() {
    
        let a: Example1;
        a = 10.0;
    
        print(a);
      
        let b: Example2;
        b = "asd";
    
        print(b);
    
        print("done.");
    }

    "Условные типа" подвезли.... ура ... теперь можно всякую х. наговнокодить..

    ASD_77, 28 Декабря 2021

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

    +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
    #include <stdio.h>
    #include <stdlib.h>
    #include <inttypes.h>
    #include <limits.h>
    typedef unsigned __int128 uint128_t;
    typedef __int128 int128_t;
    
    // в чем тут по-вашему баг ?
    uint64_t add1bit_left_1_bug(const uint64_t a, int shift)
    {
      return ~(~(a << shift) >> shift);
    }
    
    uint64_t add1bit_left_1(const uint64_t a, int shift)
    {
      return ~((uint128_t)~(uint64_t)((uint128_t)a << shift) >> shift);
    }
    
    // или тут ?
    uint64_t add1bit_left_2_bug(const uint64_t a, int shift)
    {
      return a | (uint64_t)(UINT64_MAX << (CHAR_BIT * sizeof(uint64_t) - shift));
    }
    
    uint64_t add1bit_left_2(const uint64_t a, int shift)
    {
      return a | (uint64_t)((uint128_t)-1 << (CHAR_BIT * sizeof(uint64_t) - shift));
    }
    
    uint64_t add1bit_left_3(const uint64_t a, int shift)
    {
      if (shift == 0) return a;
      return (uint64_t)((int64_t)((a << (shift-1)) | ((uint64_t)1 << (CHAR_BIT * sizeof(uint64_t) - 1)) ) >> (shift-1)); // а тут вообще UB
    }
    
    
    int main(void)
    {
      // tests
      for (int i = 0; i <= 64; i++) // пробуем сдвигать от 0 до 64 включительно.
      {
        // for (uint128_t j = 0; j < UINT64_MAX+1; j++) - какая формальная верификация )))
        for (uint64_t j = 0; j < 100; j++)
        {
          if (add1bit_left_1(j,i) != add1bit_left_2(j,i))
          {
            printf("error1\n");
            printf("%" PRIu64 " %d\n", j,i);
            return EXIT_FAILURE;
          }
          if (add1bit_left_1(j,i) != add1bit_left_3(j,i))
            printf("error2\n");
          if (add1bit_left_2(j,i) != add1bit_left_3(j,i))
            printf("error3\n");
        }
      }
      printf("%" PRIX64 "\n", add1bit_left_1(0,0));
      printf("%" PRIX64 "\n", add1bit_left_2(0,0));
      printf("%" PRIX64 "\n", add1bit_left_3(0,0));
      printf("%" PRIX64 " - bug\n", add1bit_left_1_bug(0,0));
      printf("%" PRIX64 " - bug\n", add1bit_left_2_bug(0,0));
      puts("");
      printf("%" PRIX64 "\n", add1bit_left_1(0,1));
      printf("%" PRIX64 "\n", add1bit_left_2(0,1));
      printf("%" PRIX64 "\n", add1bit_left_3(0,1));
      printf("%" PRIX64 " - bug\n", add1bit_left_1_bug(0,1));
      printf("%" PRIX64 " - bug\n", add1bit_left_2_bug(0,1));
      puts("");
      printf("%" PRIX64 "\n", add1bit_left_1(0,2));
      printf("%" PRIX64 "\n", add1bit_left_2(0,2));
      printf("%" PRIX64 "\n", add1bit_left_3(0,2));
      printf("%" PRIX64 " - bug\n", add1bit_left_2_bug(0,2));
      printf("%" PRIX64 " - bug\n", add1bit_left_2_bug(0,2));
      puts("");
      printf("%" PRIX64 "\n", add1bit_left_1(0,64));
      printf("%" PRIX64 "\n", add1bit_left_2(0,64));
      printf("%" PRIX64 "\n", add1bit_left_3(0,64));
      printf("%" PRIX64 " - bug\n", add1bit_left_1_bug(0,64));
      printf("%" PRIX64 " - bug\n", add1bit_left_2_bug(0,64));
      return EXIT_SUCCESS;
    }

    Вореанты говнофункции, которая сдвигает влево uint64_t но набрасывает единички вместо ноликов.

    j123123, 17 Ноября 2021

    Комментарии (22)
  4. 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)
  5. Куча / Говнокод #27642

    +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
    package com.javarush.task.task10.task1013;
    
    /* 
    Конструкторы класса Human
    */
    
    public class Solution {
        public static void main(String[] args) {
        }
    
        public static class Human {
            // Напишите тут ваши переменные и конструкторы
            private String name;
            private int age;
            private int height;
            private String profession;
            private String sex;
            private String citizen;
    
            public Human(String name, int huy) {
                this.name = name;
                huy = huy;
            }
    
            public Human(String name, int huy, int pizda) {
                this.name = name;
                huy = huy;
                pizda = pizda;
            }
    
            public Human(String name) {
                this.name = name;
            }
    
            public Human(String name, int age, String sex) {
                this.name = name;
                this.age = age;
                this.sex = sex;
    
            }
    
            public Human(String name, int age, String sex, String profession) {
                this.name = name;
                this.age = age;
                this.sex = sex;
                this.profession = profession;
    
            }
    
            public Human(String name, int age, String sex, String profession, String citizen) {
                this.name = name;
                this.age = age;
                this.sex = sex;
                this.profession = profession;
                this.citizen = citizen;
    
            }
    
            public Human(String name, int age, int height, String sex, String profession, String citizen) {
                this.name = name;
                this.age = age;
                this.height = height;
                this.sex = sex;
                this.profession = profession;
                this.citizen = citizen;
    
            }
    
            public Human(String name, int age, int height, String sex, String profession, String citizen, boolean pidor) {
                this.name = name;
                this.age = age;
                this.height = height;
                this.sex = sex;
                this.profession = profession;
                this.citizen = citizen;
                pidor = pidor;
    
            }
    
            public Human(String name, int age, int height, String sex, String profession, String citizen, boolean pidor, boolean govno) {
                this.name = name;
                this.age = age;
                this.height = height;
                this.sex = sex;
                this.profession = profession;
                this.citizen = citizen;
                pidor = pidor;
                govno = govno;

    IIIyqpymuHckuu_nemyx, 03 Сентября 2021

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

    −1

    1. 1
    2. 2
    https://thestreetjournal.org/2021/04/chinese-authorities-seize-7221-human-penises-on-cargo-ship-from-nigeria/
    7221 камерунских шоколадных зайцев пострадало.

    PenisDealer, 14 Апреля 2021

    Комментарии (22)
  7. Python / Говнокод #27339

    +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
    def ForQueryInAddr(query, addr):
    	global listed, primalsource
    	print("Searcing in: "+addr)
    	html = requests.get(addr,proxies=proxies).text
    	if (query.lower() in html.lower()):
    		print("==============================================")
    		print("Query found in: "+addr)
    		print("==============================================")
    	if ("<html>" in html or "<head>" in html):
    		data = PyQuery(html)
    		links = data('a')
    		for link in links:
    			ahref = link.attrib['href']
    			#print("Found: "+ahref)
    			if (ahref not in listed):
    				if (ahref[0].lower() == "h"):
    					if (primalsource in ahref):
    						if (ahref[-3:].lower() not in filetypes and ahref[-4:].lower() not in filetypes and ahref[-5:].lower() not in filetypes):
    							listed.append(ahref)
    							ForQueryInAddr(query, ahref)

    https://github.com/Dev1lroot/OnionSearch/blob/master/main.py

    PolinaAksenova, 06 Апреля 2021

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

    +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
    declare @NL table
     (ARTICLE_ID int primary key,
      M int,
      DS datetime,
      DD datetime,
      RAS money,
      REST money,
      NWS money,
      NWA money,
      LD_AMOUNT money,
      LD_DATE datetime,
      IS_NL bit,
      SCC_ID int,
      IS_NOT_MARKDOWN bit)

    Double Side,Single Density / Double Side, Double Density — это понятно. Но почему datetime?

    tucvbif, 09 Декабря 2020

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

    0

    1. 1
    Тест потерянных комментариев

    Desktop, 17 Сентября 2020

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if(object)
        if(object->isSolid)
            event.isCancelled = true;
        ;else //<
            throw NullEventArgumentException("object == nullptr");

    Новый токен в C++ про который знает только 0.6% говнокодеров

    digitalEugene, 21 Мая 2020

    Комментарии (22)
  11. PHP / Говнокод #26523

    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
    $dump = preg_replace_callback(
        '/
            (?<utf8>
                [\x09\x0A\x0D\x20-\x7E]
                | [\xC2-\xDF][\x80-\xBF]
                | \xE0[\xA0-\xBF][\x80-\xBF]
                | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}
                | \xED[\x80-\x9F][\x80-\xBF]  
                | \xF0[\x90-\xBF][\x80-\xBF]{2}
                | [\xF1-\xF3][\x80-\xBF]{3} 
                | \xF4[\x80-\x8F][\x80-\xBF]{2}
            )
            |
            (?<trash>.)
        /xs',
        function (array $match) {
            if (isset($match['utf8']) && strlen($match['utf8']) > 0) {
                $char = $match['utf8'];
                if (strlen($char) === 1 && ord($char) < 31) {
                    return '\x' . bin2hex($char);
                } else {
                    return $char;
                }
            } else {
                return '\x' . bin2hex($match['trash']);
            }
        },
        hex2bin('2cd2d948cfaf4b1097530f7c74fb6737')
    );
    
    var_dump($dump);

    https://phpclub.ru/talk/threads/bytes-fromhex-в-php.86568/
    Матёрые пхпшники переводят «Python» на «PHP».

    gost, 22 Марта 2020

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