1. Си / Говнокод #27807

    +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
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    // https://github.com/j123123/sexpr_parse/blob/584fc23de71bebe02545214f819e16b720a2c1e2/my_struct_utils.c#L119
    
    blob *
    blob_scan_fromstream
    (
      FILE *stream
    )
    {
      size_t st_len = 0;
      size_t st_alloc;
      uint8_t *st = NULL;
    
      while(true)
      {
        const int fg = getc(stream);
        if(fg == EOF)
        {
          PRV_ERR_MACRO();
        }
        uint8_t c = fg;
        if(!isprint(fg))
        {
          PRV_ERR_MACRO();
        }
        switch(c)
        {
          case '\\':
            {
              int c2 = getc(stream);
              switch(c2)
              {
                case 'x':
                  {
                    int c3[2] =
                    {
                      getc(stream),
                      getc(stream)
                    };
                    uint8_t tmp[2];
    
                    for(size_t i = 0; i < 2; ++i)
                    {
                      switch(c3[i])
                      {
                        case '0' ... '9':
                          tmp[i] = c3[i]-'0';
                          break;
                        case 'a' ... 'f':
                          tmp[i] = c3[i]+10-'a';
                          break;
                        case 'A' ... 'F':
                          tmp[i] = c3[i]+10-'A';
                          break;
                        default:
                          PRV_ERR_MACRO();
                      }
                    }
                    M_PUSH(tmp[1] | tmp[0] << 4);
                  }
                  break;
                case '\\':
                  M_PUSH('\\');
                  break;
                case 't':
                  M_PUSH('\t');
                  break;
                case 'n':
                  M_PUSH('\n');
                  break;
                case '"':
                  M_PUSH('"');
                  break;
                default:
                  PRV_ERR_MACRO();
              }
            }
            break;
    //      case '\t':
    //      case '\n':
    //        PRV_ERR_MACRO();
    //        break;
          case '"':
            goto end;
          default:
            M_PUSH(c);
        }
      }
    
    end:
      ;
      blob *tmp = blob_init(st_len, st);
      PRV_FREE(st);
      return tmp;
    }

    Эта вот хрень вычитывает из "FILE *" одно "слово".

    j123123, 09 Ноября 2021

    Комментарии (97)
  2. Куча / Говнокод #27806

    −2

    1. 1
    Узнал, что доблестный Робин-гуд был активным гомо, чья пассивная банда резала и жгла натурастов за их "натурастность"..

    Мой мир никогда не будtт прежним.

    MaaKut, 08 Ноября 2021

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

    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
    class RayTracer {
        private maxDepth = 5;
    
        private intersections(ray: Ray, scene: Scene) {
            let closest = +Infinity;
            let closestInter: Intersection = undefined;
            for (let i in scene.things) {
                let inter = scene.things[i].intersect(ray);
                if (inter != null && inter.dist < closest) {
                    closestInter = inter;
                    closest = inter.dist;
                }
            }
    
            return closestInter;
        }
    
        private testRay(ray: Ray, scene: Scene) {
            let isect = this.intersections(ray, scene);
            if (isect != null) {
                return isect.dist;
            } else {
                return undefined;
            }
        }
    
        private traceRay(ray: Ray, scene: Scene, depth: number): Color {
            let isect = this.intersections(ray, scene);
            if (isect === undefined) {
                return Color.background;
            } else {
                return this.shade(isect, scene, depth);
            }
        }
    
        private shade(isect: Intersection, scene: Scene, depth: number) {
            let d = isect.ray.dir;
            let pos = Vector.plus(Vector.times(isect.dist, d), isect.ray.start);
            let normal = isect.thing.normal(pos);
            let reflectDir = Vector.minus(d, Vector.times(2, Vector.times(Vector.dot(normal, d), normal)));
            let naturalColor = Color.plus(Color.background,
                this.getNaturalColor(isect.thing, pos, normal, reflectDir, scene));
            let reflectedColor = (depth >= this.maxDepth) ? Color.grey : this.getReflectionColor(isect.thing, pos, normal, reflectDir, scene, depth);
            return Color.plus(naturalColor, reflectedColor);
        }
    
        private getReflectionColor(thing: Thing, pos: Vector, normal: Vector, rd: Vector, scene: Scene, depth: number) {
            return Color.scale(thing.surface.reflect(pos), this.traceRay({ start: pos, dir: rd }, scene, depth + 1));
        }
    
        private getNaturalColor(thing: Thing, pos: Vector, norm: Vector, rd: Vector, scene: Scene) {
            const addLight = (col: Color, light: Light) => {
                let ldis = Vector.minus(light.pos, pos);
                let livec = Vector.norm(ldis);
                let neatIsect = this.testRay({ start: pos, dir: livec }, scene);
                let isInShadow = (neatIsect === undefined) ? false : (neatIsect <= Vector.mag(ldis));
                if (isInShadow) {
                    return col;
                } else {
                    let illum = Vector.dot(livec, norm);
                    let lcolor = (illum > 0) ? Color.scale(illum, light.color)
                        : Color.defaultColor;
                    let specular = Vector.dot(livec, Vector.norm(rd));
                    let scolor = (specular > 0) ? Color.scale(Math.pow(specular, thing.surface.roughness), light.color)
                        : Color.defaultColor;
                    return Color.plus(col, Color.plus(Color.times(thing.surface.diffuse(pos), lcolor),
                        Color.times(thing.surface.specular(pos), scolor)));
                }
            }
            //return scene.lights.reduce(addLight, Color.defaultColor);
            let resColor = Color.defaultColor;
            for (const light of scene.lights) {
                resColor = addLight(resColor, light);
            }
    
            return resColor;
        }
    
        render(scene: Scene, screenWidth: number, screenHeight: number) {
            const getPoint = (x: number, y: number, camera: Camera) => {
                const recenterX = (x: number) => (x - (screenWidth / 2.0)) / 2.0 / screenWidth;
                const recenterY = (y: number) => - (y - (screenHeight / 2.0)) / 2.0 / screenHeight;
                return Vector.norm(Vector.plus(camera.forward, Vector.plus(Vector.times(recenterX(x), camera.right), Vector.times(recenterY(y), camera.up))));
            }
    
            for (let y = 0; y < screenHeight; y++) {
                for (let x = 0; x < screenWidth; x++) {
                    let color = this.traceRay({ start: scene.camera.pos, dir: getPoint(x, y, scene.camera) }, scene, 0);
                    let c = Color.toDrawingColor(color);
                    //ctx.fillStyle = "rgb(" + String(c.r) + ", " + String(c.g) + ", " + String(c.b) + ")";
                    //ctx.fillRect(x, y, x + 1, y + 1);
    		// next line eats stack (or memory?)
    		print(`<rect x="${x}" y="${y}" width="1" height="1" style="fill:rgb(${c.r},${c.g},${c.b});" />`);
                }
            }
        }
    }
    
    
    function defaultScene(): Scene {

    шас я вас залью кодик т.к. все не влазит ловите код на https://pastebin.com/qMZmnCqT так вот это вот компилиться и работает на новом компиляторе

    ASD_77, 08 Ноября 2021

    Комментарии (20)
  4. Куча / Говнокод #27803

    −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
    a     G    a      G C         G C
    Deszcze niespokojne      potargaly sad
    a               G     F      G    a
     А my na tej wojnie ladnych pare lat
          a                       b      a          b
    Do domu wrocimy, w piecu napalimy, nakarmimy psa
           a                     B7 e           B7     e    a E7 a
    Przed noca zdazymy, tylko zwyciezymy, a to wazna gra
    a       G      a  G C               G  C
    Na niebie obloki,     po wsiach pelno bzu,
    a                   G       F     G       a
     Gdziez ten swiat daleki, pelen dobrych snow
          a                           b     a             b
    Powrocimy wierni my czterej pancerni, "Rudy" i nasz pies
            a                  B7    e         B7     e
    My czterej pancerni powrocimy wierni po wiosenny bez.

    HE_OTBE4Au_YE6KY, 07 Ноября 2021

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

    +3

    1. 1
    Пиздец-оффтоп #33

    #4: https://govnokod.ru/26689 https://govnokod.xyz/_26689
    #5: https://govnokod.ru/26784 https://govnokod.xyz/_26784
    #5: https://govnokod.ru/26839 https://govnokod.xyz/_26839
    #6: https://govnokod.ru/26986 https://govnokod.xyz/_26986
    #7: https://govnokod.ru/27007 https://govnokod.xyz/_27007
    #8: https://govnokod.ru/27023 https://govnokod.xyz/_27023
    #9: https://govnokod.ru/27098 https://govnokod.xyz/_27098
    #10: https://govnokod.ru/27125 https://govnokod.xyz/_27125
    #11: https://govnokod.ru/27129 https://govnokod.xyz/_27129
    #12: https://govnokod.ru/27184 https://govnokod.xyz/_27184
    #13: https://govnokod.ru/27286 https://govnokod.xyz/_27286
    #14: https://govnokod.ru/27298 https://govnokod.xyz/_27298
    #15: https://govnokod.ru/27322 https://govnokod.xyz/_27322
    #16: https://govnokod.ru/27328 https://govnokod.xyz/_27328
    #17: https://govnokod.ru/27346 https://govnokod.xyz/_27346
    #18: https://govnokod.ru/27374 https://govnokod.xyz/_27374
    #19: https://govnokod.ru/27468 https://govnokod.xyz/_27468
    #20: https://govnokod.ru/27469 https://govnokod.xyz/_27469
    #21: https://govnokod.ru/27479 https://govnokod.xyz/_27479
    #22: https://govnokod.ru/27485 https://govnokod.xyz/_27485
    #23: https://govnokod.ru/27493 https://govnokod.xyz/_27493
    #24: https://govnokod.ru/27501 https://govnokod.xyz/_27501
    #25: https://govnokod.ru/27521 https://govnokod.xyz/_27521
    #26: https://govnokod.ru/27545 https://govnokod.xyz/_27545
    #27: https://govnokod.ru/27572 https://govnokod.xyz/_27572
    #28: https://govnokod.ru/27580 https://govnokod.xyz/_27580
    #29: https://govnokod.ru/27738 https://govnokod.xyz/_27738
    #30: https://govnokod.ru/27751 https://govnokod.xyz/_27751
    #31: https://govnokod.ru/27754 https://govnokod.xyz/_27754
    #32: https://govnokod.ru/27786 https://govnokod.xyz/_27786

    nepeKamHblu_nemyx, 06 Ноября 2021

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

    −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
    _                         _
        |_|                       |_|
        | |         /^^^\         | |
       _| |_      (| "o" |)      _| |_
     _| | | | _    (_---_)    _ | | | |_ 
    | | | | |' |    _| |_    | `| | | | |
    \          /   /     \   \          /
     \        /  / /(. .)\ \  \        /
       \    /  / /  | . |  \ \  \    /
         \  \/ /    ||Y||    \ \/  /
           \_/      || ||      \_/
                    () ()
                    || ||
                   ooO Ooo

    Битч

    nepekam, 06 Ноября 2021

    Комментарии (4)
  7. Куча / Говнокод #27799

    −2

    1. 1
    мдеее

    мдеее

    digitalEugene, 06 Ноября 2021

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

    +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
    #include <stdio.h>
    
    #define new(class) _##class##_##new
    #define impl(class, method) _##class##_##method
    struct Calculate
    {
    	int(*getOne)(struct Calculate*);
    };
    
    int impl(Calculate, getOne)(struct Calculate* this) { return 1; }
    void* new(Calculate)(void)
    {
    	struct Calculate* class = malloc(sizeof(struct Calculate));
    	class->getOne = impl(Calculate, getOne);
    	return class;
    }
    
    struct CalculateProxy
    {
    	struct Calculate;
    };
    
    int impl(CalculateProxy, getOne)(struct Calculate* this)
    {
    	printf("Method call!\n");
    	return impl(Calculate, getOne)(this);
    }
    
    void* new(CalculateProxy)(void)
    {
    	struct CalculateProxy* class = malloc(sizeof(struct CalculateProxy));
    	class->getOne = impl(CalculateProxy, getOne);
    	return class;
    }
    
    int main(void)
    {
    	struct Calculate* calc = new(CalculateProxy)();
    	printf("%X!\n", calc->getOne(calc));
    }

    жавашок попросил реализовать паттерн прокси на Си

    digitalEugene, 06 Ноября 2021

    Комментарии (149)
  9. C++ / Говнокод #27796

    −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
    #include <iostream>
    #include <cmath>
    #include <signal.h>
    
    #define lovu struct
    #define cpp ptrdiff_t
    struct forever{};
    
    lovu forever hactehbka(void) {return {};}
    int love(void) {return 0;}
    void bacbka(void) {}
    auto bormand = (cpp(hactehbka) + cpp(bacbka)) != cpp(love);
    int main(void)
    {
        if(bormand)
            kill(bormand, SIGINT);
    
        auto sad = cpp(bacbka) - cpp(love),
            chance = cpp(love) - cpp(hactehbka),
            never = cpp(bacbka) - cpp(hactehbka);
        auto usocute = [chance, never, sad](void) -> void
        {
            putchar(sad * (chance - never / chance / 2) - sad / chance);
            putchar(sad * (chance - never / chance / 2) + sad / chance);
        };
        auto mydear = [chance, sad, never](void) -> void
        {
            putchar(sad * chance / (never / chance) + never / chance / 2 + (never + cpp(love) / (never / chance) - cpp(hactehbka) / (never / chance)) + never - (never / chance * 1.5));
            putchar(9 * chance + never / chance);
            putchar(std::abs(cpp(signal) - cpp(hactehbka) + chance * 2 + never * 3 + sad - 9) / std::pow(never / chance, 3));
        };
    
        putchar(sad * (chance - never / chance / 2));
        usocute();
        putchar(never * (chance - never / chance) + sad - (sad / (cpp(love) - cpp(hactehbka))) * (never / chance * 1.5));
        mydear();
        putchar(chance * 10 + never / chance);
        usocute();
        putchar((chance + never / chance / 2) * 10 + (never / chance) * 2);
        auto ohyes = 69.8886;
        putchar(ohyes);
        putchar(chance * 10 + never / chance);
        putchar(chance + never / chance / 2);
        putchar(never * (chance - never / chance) + sad - (sad / (cpp(love) - cpp(hactehbka))) * (never / chance * 1.5));
        mydear();
        for(auto&& c : {1.5f, 3.f, 6.5f})
            putchar(ohyes + M_PI + never / chance * c);
        putchar(ohyes);
        putchar(chance + never / chance * 1.5);
        return 0;
    }

    BACbKA, 05 Ноября 2021

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

    +1

    1. 1
    npm install

    очередной npm пакет с трояном

    https://www.bleepingcomputer.com/news/security/popular-coa-npm-library-hijacked-to-steal-user-passwords/

    Her, 05 Ноября 2021

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