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

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    void main()
    {
    	unsigned char c=0;
    	for (int c = 0;c < 256; c++) {
    		cout << "the value of '" << c << "' is: " << int(c) << '\n';
    		
    	}
    	
    }

    Ой, а чойта оно повесилося и пикает?

    untitled_001, 12 Апреля 2021

    Комментарии (17)
  3. JavaScript / Говнокод #27300

    0

    1. 1
    2. 2
    3. 3
    // These are equivalent:
    fn`some string here`;
    fn(['some string here']);

    Джаваскриптеры переизобрели руби (ладно-ладно, скрестили с FormattableString из шарпа)

    https://styled-components.com/docs/advanced#tagged-template-literals

    Fike, 16 Марта 2021

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

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    // https://github.com/google/ruy/blob/2887692065c38ef6617f423feafc6b69dd0a0681/ruy/pack_avx2_fma.cc#L66
    
    inline void Pack8bitColMajorForAvx2Packer(
        const std::int8_t* src_ptr, std::int8_t input_xor,
        const std::int8_t* zerobuf, int src_stride, int remaining_src_cols,
        int src_rows, std::int8_t* packed_ptr, std::int32_t* sums_ptr,
        std::int8_t* trailing_buf) {
      using Layout = PackImpl8bitAvx2::Layout;
      RUY_DCHECK_EQ(Layout::kCols, 8);
      RUY_DCHECK_EQ(Layout::kRows, 4);
      // Each Layout::Rows is 4 contiguous input, contiguous packed elements.
      // We process 8 of these chunks at a time, padding short input chunks.
      constexpr int kNumRowChunks = 8;
      constexpr int kNumChunkedSrcRows = kNumRowChunks * Layout::kRows;
    
      const std::int8_t* src_ptr0 = src_ptr;
      const std::int8_t* src_ptr1 = src_ptr0 + src_stride;
      const std::int8_t* src_ptr2 = src_ptr1 + src_stride;
      const std::int8_t* src_ptr3 = src_ptr2 + src_stride;
      const std::int8_t* src_ptr4 = src_ptr3 + src_stride;
      const std::int8_t* src_ptr5 = src_ptr4 + src_stride;
      const std::int8_t* src_ptr6 = src_ptr5 + src_stride;
      const std::int8_t* src_ptr7 = src_ptr6 + src_stride;
      std::int64_t src_inc0 = kNumChunkedSrcRows;
      std::int64_t src_inc1 = kNumChunkedSrcRows;
      std::int64_t src_inc2 = kNumChunkedSrcRows;
      std::int64_t src_inc3 = kNumChunkedSrcRows;
      std::int64_t src_inc4 = kNumChunkedSrcRows;
      std::int64_t src_inc5 = kNumChunkedSrcRows;
      std::int64_t src_inc6 = kNumChunkedSrcRows;
      std::int64_t src_inc7 = kNumChunkedSrcRows;
      // Handle cases where source does not have Layout::kCols (8) columns.
      if (remaining_src_cols < 8) {
        if (remaining_src_cols <= 0) {
          src_ptr0 = zerobuf;
          src_inc0 = 0;
        }
        if (remaining_src_cols <= 1) {
          src_ptr1 = zerobuf;
          src_inc1 = 0;
        }
        if (remaining_src_cols <= 2) {
          src_ptr2 = zerobuf;
          src_inc2 = 0;
        }
        if (remaining_src_cols <= 3) {
          src_ptr3 = zerobuf;
          src_inc3 = 0;
        }
        if (remaining_src_cols <= 4) {
          src_ptr4 = zerobuf;
          src_inc4 = 0;
        }
        if (remaining_src_cols <= 5) {
          src_ptr5 = zerobuf;
          src_inc5 = 0;
        }
        if (remaining_src_cols <= 6) {
          src_ptr6 = zerobuf;
          src_inc6 = 0;
        }
        src_ptr7 = zerobuf;
        src_inc7 = 0;
      }
    
      const std::int8_t zero_point = zerobuf[0];
    
      if (sums_ptr) {
        // i: Layout::kCols.
        for (int i = 0; i < 8; ++i) {
          sums_ptr[i] = 0;
        }
      }
      std::int32_t sums_adjustment = 0;
      const __m256i ones_16bit = _mm256_set1_epi16(1);
      __m256i sums_4x2_32bit_lo = _mm256_set1_epi32(0);
      __m256i sums_4x2_32bit_hi = _mm256_set1_epi32(0);
    
      // The overall packing effectively pads the source rows to
      // (src_rows + 63) & ~63. The iteration over k may skip when m=1, and then we
      // only pack for (src_rows + 31) & ~31. When there is an incomplete
      // destination block, this is stored into trailing_buf instead of packed_ptr.
      for (int k = 0; k < src_rows; k += kNumChunkedSrcRows) {
        // Available source rows.
        // If this is less than 0 (for m=1), we skip, having filled trailing
        // buffer for m=0. Also, if source rows is zero on m=1, then we filled
        // exactly to the end of the column in the packed buffer.
        const int available_src_rows = src_rows - k;
        // Effectively,
        // available rows = std::max(0, std::min(8, src_rows - k));
        // treat each case separately.
        if (available_src_rows >= kNumChunkedSrcRows) {
          if (sums_ptr) {
            __m256i t0, t1, t2, t3, t4, t5, t6, t7;
            __m256i r0, r1, r2, r3, r4, r5, r6, r7;
            const __m256i input_xor_v = _mm256_set1_epi8(input_xor);
    
            t0 = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(src_ptr0));
            t4 = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(src_ptr4));
            t1 = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(src_ptr1));

    Интересно, они это вручную всё писали, или какой-то хуйней генерировали?

    j123123, 08 Февраля 2021

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    Я вот смотрю на Ричарда Столлмана... Вижу, как он всю жизнь рвёт на себе жопчик за халявное ПО...
    И думаю: а что сделал ОН? Он написал "Photoshop"? Создал "Windows"? Разработал хоть что-то?
    Знает ли он, что такое многочасовой, многодневный, многомесячный, а иногда и многолетний труд разработки?
    Всё его достижение - это ТЕКСТ лицензии "GNU". Всё.
    В чём смысл Ричарда Столлмана?

    И, кстати, нахуй вообще нужны лицензии на халявное ПО?

    rotoeb, 30 Сентября 2020

    Комментарии (17)
  6. Си / Говнокод #26982

    +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
    /* https://habr.com/ru/company/piter/blog/491996/
    
    Пусть в Python такая штука и называется генератором, в языке C++ она
    называлась бы корутиной. Пример взят с этого сайта: https://masnun.com/2015/11/13/python-generators-coroutines-native-coroutines-and-async-await.html
    
    def generate_nums():
         num = 0
         while True:
              yield num
              num = num + 1	
    
    nums = generate_nums()
    	
    for x in nums:
         print(x)
    	
         if x > 9:
    */
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdint.h>
    #include <stdbool.h>
    
    #define START 0
    #define YIELD 1
    
    typedef struct 
    {
      uint8_t jmpto;
      int num;
    } coroutine_state;
    
    
    int generate_nums(coroutine_state *state)
    {
      switch(state->jmpto)
      {
        case START: break;
        case YIELD: goto yield;
      }
      while (true)
      {
        state->jmpto = YIELD; return state->num; yield: // какая питушня
    
        state->num = state->num + 1;
      }
    }
    
    
    
    
    int main(void)
    {
      int x;
      coroutine_state st = {START, 0};
      while(true)
      {
        x = generate_nums(&st);
        printf("%d\n", x);
    
        if (x > 9)
        {
          break;
        }
      }
      return EXIT_SUCCESS;
    }

    Попробовал переписать эту ко-ко-корутину c питуха на Си - получилась какая-то херня нечитаемая. что еще раз доказывает, что корутины нахуй не нужны

    К тому же в крестопарашном говне они требуют хип, а это нахуй не нужно на самом-то деле.

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

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    #include <stdlib.h>
    
    void main()
    {
        a: ; malloc(1); goto a;
    }

    GDMaster, 23 Сентября 2020

    Комментарии (17)
  8. Python / Говнокод #26880

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    >>> def f(positional_only, /, regular, *varargs, kw_only, **kw_varargs):
        print(positional_only, regular, varargs, kw_only, kw_varargs)
    
    f(1, 2, 3, 4, 5, kw_only='kw_only', kw_var1='var1', kw_var2='var2')
    # 1 2 (3, 4, 5) kw_only {'kw_var1': 'var1', 'kw_var2': 'var2'}

    Блядь, как всё сложно…

    https://www.python.org/dev/peps/pep-0570/

    gost, 18 Августа 2020

    Комментарии (17)
  9. Си / Говнокод #26780

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    The count is coded into a one-octet number using the following
    formula:
    
       #define EXPBIAS 6
           count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
    
    The above formula is in C, where "Int32" is a type for a 32-bit
    integer, and the variable "c" is the coded count, Octet 10.

    Стандарт PHGP, набайтоёблено где не ждали. Казалось бы, в чем сложность отвести один октет на базу, а другой на сдвиг? Но сишнику проще даже не объяснить происходящее в стандарте, а просто кинуть код, типа, и так понятно же.

    https://tools.ietf.org/html/rfc4880#page-12

    Fike, 30 Июня 2020

    Комментарии (17)
  10. Куча / Говнокод #26741

    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
    #lang racket
    
    (require racket/syntax)
    
    (define-syntax (_total stx)
      (syntax-case stx ()
        [(_total item price amount)
         (let ([make-id
                (lambda (template . ids)
                  (let ([str (apply format template (map syntax->datum ids))])
                    (datum->syntax stx (string->symbol str))))])
           (with-syntax ([total-item-price (make-id "~a-price" #'item)]
                         )
             #'(begin
                 (total-item-price price amount)
                 )))]
        )
      )
    
    (define-syntax-rule (total item price amount)
      (cond [(eq? item 'apple) (_total apple price amount)]
            [(eq? item 'grape) (_total grape price amount)]
            [else (_total general price amount)]
            )
      )
      
    
    (define (apple-price price amount)
      (* price (- amount (/ amount 2)))
      )
    
    (define (grape-price price amount)
      (* price (if (> amount 1) (/ (* amount 4) 5) amount))
      )
    
    (define (general-price price amount)
      (* amount price)
      )
    
    (define apples '(apple 10 4))
    (define grapes '(grape 20 3))
    (define other '(peach 30 1))
    
    (foldl (λ (lst result)
             (+ result (total (car lst) (cadr lst) (caddr lst)))
             )
           0
           (list apples grapes other)
     )

    Когда у тебя есть macroмолоток, всё остальное кажется гвоздями.

    Desktop, 07 Июня 2020

    Комментарии (17)
  11. Куча / Говнокод #26537

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    PREVIEW:
        https://postimg.cc/67RGYQf8
    PATH:
        http://fanserials.auction/49075-razraby-1-sezon-1-seriya.html

    Фарадея золочёная клетка
    Маяковского помятый пиджак

    bot, 29 Марта 2020

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