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

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    // https://github.com/WebKit/webkit/blob/e0e7e8f907f4c01c723374e8230a63d46e89e6a0/Source/WebCore/platform/graphics/filters/FEComposite.cpp#L98
    
    static unsigned char clampByte(int c)
    {
        unsigned char buff[] = { static_cast<unsigned char>(c), 255, 0 };
        unsigned uc = static_cast<unsigned>(c);
        return buff[!!(uc & ~0xff) + !!(uc & ~(~0u >> 1))];
    }

    j123123, 22 Апреля 2019

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

    +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
    #include <type_traits>
    
    struct Foo {
      void bar(int) const & {}
    };
    
    int main() {    
      using MethodPtr = decltype(&Foo::bar);
      const MethodPtr arr[] = { &Foo::bar };
      auto *ptr = &arr;
      auto &ref = ptr;
    
      static_assert(std::is_same_v<decltype(ref), void (Foo::* const (*&)[1])(int) const &>);
    }

    Магия указателей возведенная в степень магии массивов в степени магии ссылок.

    https://wandbox.org/permlink/8DygQ6oocrEY1K1M

    Elvenfighter, 11 Марта 2019

    Комментарии (23)
  4. Assembler / Говнокод #25249

    −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
    execute = 0
    i = 100
    while i < $
        load a byte from i
        if a = 0xc3
            execute = i
            i = $
        else
            i = i + 1
        end if
    end while
    
    if execute = 0
    display "ret not found", 13, 10
    execute = $
    ret
    end if

    Прежде чем объявлять подпрограмму, тсарь пройдётся по уже собранному коду в поисках нужных ему байт.

    3oJloTou_neTyx, 01 Января 2019

    Комментарии (23)
  5. Куча / Говнокод #24926

    −103

    1. 1
    'Докторинхо' и 'БагорСтретора'-а забанили (

    (╯︵╰,)

    kir_rik, 16 Октября 2018

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

    +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
    #include <iostream>
    #include <string>
    #include <cstdlib>
    #include <ctime>
    #define next ;
    #define zero 0
    #define one 1
    #define two 2
    #define three 3
    #define four 4
    #define five 5
    #define six 6
    #define seven 7
    #define eight 8
    #define nine 9
    #define dot .
    #define begin {
    #define end }
    #define open (
    #define close )
    #define sqopen [
    #define sqclose ]
    #define less <=
    #define xless <
    #define greater >=
    #define xgreater >
    #define isnt !=
    #define isequal ==
    #define mustbe =
    #define write cout
    #define plus +
    #define minus -
    #define multi *
    #define divby /
    #define incr +=
    #define decr -=
    using namespace std next
    
    string pswdGen open int quantity close begin
        srand open time open 0 close close next
        char chars sqopen sqclose mustbe "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890@\#\$\%\&\-\+\!\/\_" next
        string password next
        for(int i = zero next i xless quantity next i++) begin
            password incr chars sqopen rand open close % open sizeof open chars close divby sizeof open *chars close close sqclose next
        end
        return password next
    end
    int main open close begin
        int charNo next
        write << "How many characters do you want in the password?" << endl next
        cin >> charNo next
        write << "Your new password is: " << pswdGen open charNo close << endl next
        return zero next
    end

    По сути это тот же крестовый паролегенератор, но из-за дефайнов и от того символов можно отнести в кучу. И да, "Переведи на "зрз"" в сторону. Перевел вам за щеку, проверяйте

    shite, 08 Августа 2018

    Комментарии (23)
  7. Си / Говнокод #24378

    −1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    bool P(int *X, int k, int y, int N) // Поиск позиции для ферзя
    {
      int i = 0;
      while ((i<k) && (y != X[i]) && (abs(k - i) != abs(y - X[i]))) { i++; }
      if (i == k)
        return true;
      else if (i != k)
        return false;
      else
        return !true && !false;
    }

    Часть задачи о восьми ферзях. Обнаружена на Тостере.
    Обратите внимание на цикл («обнаружен бой — стоп»), и на аналог return (i==k).

    Mercury13, 12 Июня 2018

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

    −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
    SELECT DISTINCT comment_author
    FROM  `wp_comments` 
    WHERE comment_content LIKE  '%и т.д%'
    ORDER BY comment_date
    
    https://ideone.com/78q77K
    
    
    SELECT DISTINCT comment_author
    FROM  `wp_comments` 
    WHERE comment_content LIKE  '%итд%'
    ORDER BY comment_date
    
    https://ideone.com/bB9w3t

    Тут сразу палятся файки roskomgovno aka SemaReal aka barop aka huesto aka guestinho aka guesto

    minusinho, 28 Мая 2018

    Комментарии (23)
  9. Java / Говнокод #23967

    −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
    public bool WaitForElement(Action testMethod)
            {
                try
                {
                    testMethod();
                }
                catch (StaleElementReferenceException)
                {
                    testMethod();
                }
                catch (ElementNotVisibleException)
                {
                    return false;
                }
                catch (NoSuchElementException)
                {
                    return false;
                }
                return true;
            }

    http://software-testing.ru/forum/index.php?/topic/21965-borba-so-staleelementreferenceexception-element-is-no-longer-attached-to-the-dom/?p=138795
    "Не боян, а классика!"

    хуита, 20 Марта 2018

    Комментарии (23)
  10. PHP / Говнокод #23799

    0

    1. 1
    php.net/manual/ru/book.runkit.php

    Век живи, век удивляйся PHP

    dm_fomenok, 17 Февраля 2018

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

    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
    if (in_array($answ[0],$kb_name) and !in_array($answ[1],$kb_none)){
    						$randtext = array(
    							1 => 'Данная функция не была найдена в моей инструкции.',
    							2 => 'Возможно мой создатель ещё не сделал эту команду.',
    							3 => 'Мы все надеемся что эта команда скоро появится.',
    							4 => 'А ты точно уверен в своих желаниях?',
    							5 => 'Скорее всего ты хотел написать что я няша.',
    							6 => 'Вопряки всем стереотипам, у Type KB очень маленькая база данных для ответов.',
    							7 => 'Попробуй написать без ошибок. Лучше всего загляни в помощь.',
    							8 => 'Ой, а такой команды нет. Приношу свои извинения.',
    							9 => 'Ошибка stop 0x00000000001, команда не найдена!',
    							10 => 'KERNEL PANIC!!!'
    							);
    						apisayPOST($randtext[rand(1,count($randtext))],$toho,$torep);
    						unset($randtext);
    					}

    NodnolStudio, 19 Января 2018

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