1. Список говнокодов пользователя j123123

    Всего: 335

  2. Куча / Говнокод #25340

    +1

    1. 1
    https://i.imgur.com/7uRLULs.mp4

    Аппаратная нейросеть в мозгах петуха совершила ошибку классификации.

    j123123, 30 Января 2019

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

    +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
    void add_SSE(uint8_t a[static 7], uint8_t b[static 7], uint8_t out[static 7])
    {
      uint64_t a_64 = 0;
      uint64_t b_64 = 0;
      for (size_t i = 0; i < 7; i++) // можно наанроллить
      {
        a_64 |= (uint64_t)a[i] << (i*9);
        b_64 |= (uint64_t)b[i] << (i*9);
      }
      
      uint64_t c_64 = a_64 + b_64;
      
      for (size_t i = 0; i < 7; i++) // можно наанроллить
      {
        out[i] = (uint64_t)c_64 >> (i*9);
      }
    }

    SSE

    j123123, 28 Января 2019

    Комментарии (32)
  4. Java / Говнокод #25332

    +3

    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
    // https://github.com/TigerVNC/tigervnc/blob/8c6c584377feba0e3b99eecb3ef33b28cee318cb/java/com/jcraft/jsch/Buffer.java#L65-L85
    
      public void putInt(int val) {
        tmp[0]=(byte)(val >>> 24);
        tmp[1]=(byte)(val >>> 16);
        tmp[2]=(byte)(val >>> 8);
        tmp[3]=(byte)(val);
        System.arraycopy(tmp, 0, buffer, index, 4);
        index+=4;
      }
      public void putLong(long val) {
        tmp[0]=(byte)(val >>> 56);
        tmp[1]=(byte)(val >>> 48);
        tmp[2]=(byte)(val >>> 40);
        tmp[3]=(byte)(val >>> 32);
        System.arraycopy(tmp, 0, buffer, index, 4);
        tmp[0]=(byte)(val >>> 24);
        tmp[1]=(byte)(val >>> 16);
        tmp[2]=(byte)(val >>> 8);
        tmp[3]=(byte)(val);
        System.arraycopy(tmp, 0, buffer, index+4, 4);
        index+=8;
      }

    Жабовское байтоебство (судя по всему это такой ntohl) из реализации VNC.
    Вот интересно, в жабке-то unsigned типов нет нихера, но почему-то сделали unsigned двоичный сдвиг (>>>), который работает для этих встроенных signed типов как если б это были unsigned. А как насчет unsigned умножения и деления (сложение и вычитание - то один хер, без разницы, если у нас two's complement)?

    j123123, 28 Января 2019

    Комментарии (58)
  5. C++ / Говнокод #25327

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    https://www.opennet.ru/opennews/art.shtml?num=50026
    
    После двух лет разработки компания The Qt Company представила
    компактный встроенный http-сервер для Qt, доступный для
    разработчиков приложений в виде класса QHttpServer. Сервер
    пока развивается как экспериментальный проект Qt Labs, но
    запланирован для включения в основной состав Qt 6.

    Вот жеж этим [censored] делать нехер. Вы уже в Qt встроили жабаскрипт ( https://doc.qt.io/qt-5/topics-scripting.html ), и даже встроили браузер, но вам этого мало, вы еще и вебсервер встроили. Встройте еще туда и PHP, чтоб вообще всё возможное говно в себя вобрать

    j123123, 26 Января 2019

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

    +4

    1. 1
    2. 2
    Yandere Simulator
    https://f0ck.me/b/09d3f680.mp4

    j123123, 22 Января 2019

    Комментарии (14)
  7. C++ / Говнокод #25319

    +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
    // https://www.tutorialspoint.com/Read-a-character-from-standard-input-without-waiting-for-a-newline-in-Cplusplus
    
    
    
    // A portable solution doesn't exist for doing this. On windows, you can use the getch() function from the conio(Console I/O) library to get characters pressed. For example,
    
    #include<iostream>
    #include<conio.h>
    using namespace std;
    int main() {
        char c;
        while(1){ // infinite loop
            c = getch();
            cout << c;
        }
    }
    
    // This will output whatever character you input to the terminal. Note that this will only work on windows as the conio library exists only on windows. On UNIX, you can achieve this by entering in system raw mode. For example,
    
    #include<iostream>
    #include<stdio.h>
    int main() {
        char c;
       // Set the terminal to raw mode
        system("stty raw");
        while(1) {
            c = getchar(); 
            // terminate when "." is pressed
            if(c == '.') {
                system("stty cooked");
                exit(0);
            }  
            std::cout << c << " was pressed."<< std::endl;
        }
    }

    Вариант под UNIX еще и очень секурный, ЕВПОЧЯ

    j123123, 22 Января 2019

    Комментарии (39)
  8. Си / Говнокод #25307

    −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
    void sort8(uint64_t a[8])
    {
      uint64_t a0;
      uint64_t a1;
      uint64_t a2;
      uint64_t a3;
      uint64_t a4;
      uint64_t a5;
      uint64_t a6;
      uint64_t a7;
     
      SORT2(a[0], a[1], a0, a1);
      SORT2(a[2], a[3], a2, a3);
      SORT2(a[4], a[5], a4, a5);
      SORT2(a[6], a[7], a6, a7);
    
      uint64_t a_tmp[8];
    
      MERGE_2_4(a0, a1, a2, a3, a_tmp[0], a_tmp[1], a_tmp[2], a_tmp[3]);
      MERGE_2_4(a4, a5, a6, a7, a_tmp[4], a_tmp[5], a_tmp[6], a_tmp[7]);
    
      uint64_t *ptra1 = &a_tmp[0];
      uint64_t *ptra2 = &a_tmp[4];
      
      for (size_t i = 0; i < 4; i++)
      {
        if (*ptra1 < *ptra2)
        {
          a[i] = *ptra1;
          ptra1++;
        }
        else
        {
          a[i] = *ptra2;
          ptra2++;
        }
      }
    
      for (size_t i = 4; i < 8; i++)
      {
        if (ptra1 == &a_tmp[4])
        {
          while (ptra2 != &a_tmp[8])
          {
            a[i++] = *ptra2;
            ptra2++;
          }
          break;
        }
        
        if (ptra2 == &a_tmp[8])
        {
          while (ptra1 != &a_tmp[4])
          {
            a[i++] = *ptra1;
            ptra1++;
          }
          break;
        }
    
    
        if (*ptra1 < *ptra2)
        {
          a[i] = *ptra1;
          ptra1++;
        }
        else
        {
          a[i] = *ptra2;
          ptra2++;
        }
    
      }
    }

    Мерж сорт, специализированный на 8 элементов. Вот доказательство корректности https://paste.debian.net/hidden/cce6d31a/

    j123123, 13 Января 2019

    Комментарии (137)
  9. Assembler / Говнокод #25239

    +2

    1. 1
    2. 2
    3. 3
    https://www.researchgate.net/publication/325358150_cQASM_v10_Towards_a_Common_Quantum_Assembly_Language
    
    cQASM v1.0: Towards a Common Quantum Assembly Language

    The quantum assembly language (QASM) is a popular intermediate representation used in many quantum compilation and simulation tools to describe quantum circuits. Currently, multiple different dialects of QASM are used in different quantum computing tools. This makes the interaction between those tools tedious and time-consuming due to the need for translators between theses different syntaxes. Beside requiring a multitude of translators, the translation process exposes the constant risk of loosing information due to the potential incompatibilities between the different dialects. Moreover, several tools introduce details of specific target hardware or qubit technologies within the QASM syntax and prevent porting the code to other hardwares. In this paper, we propose a common QASM syntax definition, named cQASM, which aims to abstract away qubit technology details and guarantee the interoperability between all the quantum compilation and simulation tools supporting this standard. Our vision is to enable an extensive quantum computing toolbox shared by all the quantum computing community.

    Вот это я понимаю, а то вон там мелкософт какие-то говношарпы придумывает очередные:

    https://docs.microsoft.com/en-us/quantum/language/?view=qsharp-preview


    Нахер ваши шарпы с вашим сраным дуднетом и прочей такой хуйней, даешь Assembler.

    j123123, 28 Декабря 2018

    Комментарии (187)
  10. Си / Говнокод #25229

    +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
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    #define SQARESZ 3
    
    
    void rotateclockwise(char *ptra, size_t sz)
    {
        char (*a_ar)[sz] = (void *)ptra;
        char b_ar[sz][sz];
        for (size_t y = 0; y < sz; y++)
        {
            for (size_t x = 0; x < sz; x++)
            {
                b_ar[y][x] = a_ar[sz-1-x][y];
            }
        }
        memcpy(a_ar, b_ar, sz*sz);
    }
    
    void print_ar(char *ptra, size_t sz)
    {
        char (*a_ar)[sz] = (void *)ptra;
        for (size_t y = 0; y < sz; y++)
        {
            for (size_t x = 0; x < sz; x++)
            {
                printf("%i ", a_ar[y][x]);
            }
            printf("\n");
        }
    }
    
    int main()
    {
        char a[SQARESZ][SQARESZ] =
        {
          {1,2,3},
          {4,5,6},
          {7,8,9}
        };
        
        print_ar((char *)a, SQARESZ);
        printf("\n");
        rotateclockwise((char *)a, SQARESZ);
        
        print_ar((char *)a, SQARESZ);
        printf("\n");
        rotateclockwise((char *)a, SQARESZ);
        
        print_ar((char *)a, SQARESZ);
        printf("\n");
        rotateclockwise((char *)a, SQARESZ);
        
        print_ar((char *)a, SQARESZ);
        printf("\n");
        rotateclockwise((char *)a, SQARESZ);
        
        print_ar((char *)a, SQARESZ);
        printf("\n");
    
        return 0;
    }

    https://habr.com/post/317300/ В C++17 до сих пор нет нормальных многомерных массивов, которые были в Fortran начиная с Fortran 90

    > UPD от 2016-12-10 14:03. Посмотрел на этот коммент от @selgjos, поэкспериментировал с компилятором и понял, что с помощью C99 VLA всё-таки можно добиться нужного мне эффекта.
    > В общем, окей, в C есть нужные мне массивы. Как и в Fortran. А в C++ их по-прежнему нет.

    j123123, 26 Декабря 2018

    Комментарии (144)
  11. Assembler / Говнокод #25228

    +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
    /*
    x86-64 clang (trunk) -O3
    https://godbolt.org/z/t8NDGG
    
    #include <inttypes.h>
    
    uint32_t saturation_add(uint32_t a, uint32_t b)
    {
        const uint64_t tmp = (uint64_t)a + b;
        if (tmp > UINT32_MAX)
        {
            return UINT32_MAX;
        }
        return tmp;
    }
    */
    
    saturation_add:
            mov     edx, esi
            mov     eax, edi
            add     edi, esi
            add     rax, rdx
            mov     edx, 4294967295
            cmp     rax, rdx
            mov     eax, -1   // ЗАЧЕМ???
            cmovbe  eax, edi
            ret

    https://en.wikipedia.org/wiki/Saturation_arithmetic
    Почему компиляторы до сих пор такое говно

    j123123, 26 Декабря 2018

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