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

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

    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
    ВЫБРАТЬ РАЗЛИЧНЫЕ
    	ВЫРАЗИТЬ(Работы.Ссылка КАК Документ.ЗаказНаряд) КАК СсылкаЗН,
    	ДЦ.Ссылка КАК ДилерскийЦентр
    ИЗ
    	Документ.ЗаказНаряд.Работы КАК Работы
    		ЛЕВОЕ СОЕДИНЕНИЕ Справочник.CRM_ДилерскиеЦентры КАК ДЦ
    		ПО (ЛОЖЬ)
    ГДЕ
    	Работы.Ссылка.ДатаЗакрытия >= &ДатаНачала
    	И Работы.Ссылка.ДатаЗакрытия < &ДатаОкончания
    	И ДЦ.Ссылка.ПометкаУдаления = ЛОЖЬ
    ;

    Язык запросов 1С. При таком соединение запрос запрос всегда будет пустым.

    NioGoth, 29 Августа 2019

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

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    $products = $this->cart->getProducts();
    foreach ($products as $product) {
    	$product_total = 0;
    	foreach ($products as $product_2) {
    		if ($product_2['product_id'] == $product['product_id']) {
    			$product_total += $product_2['quantity'];
    		}
    	}
    ....
    }

    Поечему опенкарт так странно вычисляет количество товаров в корзине? неужели нет способа изящней?

    pseudoJun, 14 Августа 2019

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    $id=$id-1;
    	$id++;
    	$id=(int)$id;
    	Дальше в sql запрос ее конкотенируют.

    ОМГ, я даже представить не могу для чего нужны первые 3 строки в совокупности в 3-й..

    stainer, 30 Июля 2019

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

    +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
    /* Create a JSON object from JSON data stream. The stream should be opened and configured. All other behavior of this method is the same as the JSONObjectWithData:options:error: method.
         */
    open class func jsonObject(with stream: InputStream, options opt: ReadingOptions = []) throws -> Any {
        var data = Data()
        guard stream.streamStatus == .open || stream.streamStatus == .reading else {
             fatalError("Stream is not available for reading")
         }
         repeat {
             var buffer = [UInt8](repeating: 0, count: 1024)
             var bytesRead: Int = 0
             bytesRead = stream.read(&buffer, maxLength: buffer.count)
             if bytesRead < 0 {
                 throw stream.streamError!
             } else {
                 data.append(&buffer, count: bytesRead)
             }
         } while stream.hasBytesAvailable
         return try jsonObject(with: data, options: opt)
    }

    Потоковое чтение JSON от авторов "iСделаль"

    Desktop, 07 Июля 2019

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    var type = shape switch
    {
      Rectangle((0, 0), 0, 0) => "Point at origin",
      Circle((0, 0), _) => "Circle at origin",
      Rectangle(_, var w, var h) when w == h => "Square",
      Rectangle((var x, var y), var w, var h) =>
        $"A {w}×{h} rectangle at ({x},{y})",
      _ => "something else"
    };

    https://habr.com/ru/post/454446/#comment_20232586

    Какой бароп )))

    OCETuHCKuu_nemyx, 02 Июня 2019

    Комментарии (23)
  7. 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)
  8. 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)
  9. 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)
  10. Куча / Говнокод #24926

    −103

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

    (╯︵╰,)

    kir_rik, 16 Октября 2018

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