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

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

    −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
    #include <stdio.h>
    #include <stdlib.h>
    
    
    int main(int argc, char *argv[])
    
    //типа explode в php;
    {
    int i=0;
    //char s=';';
    char s=argv[2][0];
    
    i=100;
    //char** data;
    //data=(char**)malloc(i+1);
    char data[1000][1000];
    char* str;
    str=malloc(i+1);
    str=argv[1];
    printf("%s\n",str );
    int n=0;
    int m=0;
    
    
    while (*str) {
    if (*str==s)
    {m++;n=0;str++;continue;};
      data[m][n]=*str;
      str++;n++;
    
    };
    printf("%s\n",data[0] );
    
    }

    Типа explode в php
    Кто-нить знает как это заставить работать с
    //char** data;
    //data=(char**)malloc(i+1);
    ??

    killer1804, 03 Сентября 2019

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

    −103

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

    (╯︵╰,)

    kir_rik, 16 Октября 2018

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