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

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

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    public function renderJSON()
        {
            $this->checkError();
    
            return serialize($this);
        }

    Чтобы враг не догадался!

    zoorg, 06 Декабря 2021

    Комментарии (20)
  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. JavaScript / Говнокод #27681

    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
    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
    95. 95
    96. 96
    const range = (count) => Array.from(Array(count).keys());
    class Matrix {
    
        static Dot(A, B) {
            // Dot production
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != hB)
            {
                throw "A width != B height";
            }
    
            const C = range(hA).map((_, i) => range(wB).map((_, j) => 0));
    
            for (let i = 0; i < hA; ++i)
                for (let j = 0; j < wB; ++j) {
                    let sum = 0;
    
                    for (let k = 0; k < wA; ++k) {
                        const a = A[i][k];
                        const b = B[k][j];
                        sum += a * b;
                    }
    
                    C[i][j] = sum;
                }
    
            return C;                
        }
    
        static Mul(A, B) {
            // Dot production
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != wB || hA != hB)
            {
                throw "A width != B width, A height != B height";
            }
    
            const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] * B[i][j]));
            return C;
        }            
    
        static Add(A, B) {
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != wB || hA != hB)
            {
                throw "A width != B width, A height != B height";
            }
    
            const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] + B[i][j]));
            return C;
        }
    
        static Sub(A, B) {
            const wA = A[0].length;
            const hA = A.length;
            const wB = B[0].length;
            const hB = B.length;
    
            if (wA != wB || hA != hB)
            {
                throw "A width != B width, A height != B height";
            }
    
            const C = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] - B[i][j]));
            return C;
        }
    
            static Translate(A, shift) {
            const wA = A[0].length;
            const hA = A.length;
    
            const R = range(hA).map((_, i) => range(wA).map((_, j) => A[i][j] + shift));
            return R;                        
        }         
    
        static Sigmoid(A) {
            const wA = A[0].length;
            const hA = A.length;
    
            const R = range(hA).map((_, i) => range(wA).map((_, j) => 1 / (1 + Math.exp(-A[i][j]))));
            return R;                                        
        }
    //...
    }

    лаба по математике матрици :)

    ASD_77, 26 Сентября 2021

    Комментарии (20)
  5. bash / Говнокод #27653

    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
    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
    95. 95
    96. 96
    function error {
      printf "ERROR: $1\n" >&2 
    }
    
    function warning {
      printf "WARNING: $1\n"
    }
    
    function info {
      printf "INFO: $1\n"
    }
    
    function println {
      printf "$1\n"
    }
    
    function block {
      printf "\n$3\n$1 \t[$2]\n$3\n"
    }
    
    function fail {
      println "\n" 
      println "FAIL"$1
      println
    }
    
    function checkz {
      if [ -z $1 ]; then
        error "empty string"
        return 1
      fi  
      info "string \"$1\" \t[OK]"
      return 0
    }
    
    function checkx {
      if [ ! -x $1 ]; then
        error "$1 \t[NOT FOUND]"
        return 1
      fi  
      info "$1 \t[OK]"
      return 0
    }
    
    function checkb {
      if [ ! -b $1 ]; then
        error "$1 \t[NOT FOUND]"
        return 1
      fi  
      info "$1 \t[OK]"
      return 0
    }
    
    function checkc {
      if [ ! -c $1 ]; then
        error "$1 \t[NOT FOUND]"
        return 1
      fi  
      info "$1 \t[OK]"
      return 0
    }
    
    function checkf {
      if [ ! -f $1 ]; then
        error "$1 \t[NOT FOUND]"
        return 1
      fi  
      info "$1 \t[OK]"
      return 0
    }
    
    function checkd {
      if [ ! -d $1 ]; then
        error "$1 \t[NOT FOUND]"
        return 1
      fi  
      info "$1 \t[OK]"
      return 0
    }
    
    function checkd_mk {
      if [ ! -d $1 ]; then
        info "$1 \t[NOT FOUND]"
        info "$1 \t[MAKING...]"
        mkdir -p $1
        checkd $1
        return $?
      fi  
      info "$1 \t[OK]"
      return 0
    }
    
    function sized {
      sized=($(ls $1))
      return ${#sized[@]}
    }

    Вспомогательные функции проверки файлов и директорий, а также вывода ошибок

    somebyte, 09 Сентября 2021

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

    +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
    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
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    using System;
    
    using System.Collections.Generic;
    
    using System.ComponentModel;
    
    using System.Data;
    
    using System.Drawing;
    
    using System.Linq;
    
    using System.Text;
    
    using System.Threading.Tasks;
    
    using System.Windows.Forms;
    
    namespace Biblo
    
    {
    
    public partial class Form1 : Form
    
    {
    
    public Form1()
    
    {
    
    InitializeComponent();
    
    }
    
    private void Form1_Load(object sender, EventArgs e)
    
    {
    
    }
    
    private void label1_Click(object sender, EventArgs e)
    
    {
    
    }
    
    double a = 0, b = 0, c = 0;
    
    double f, g;
    
    private void button1_Click(object sender, EventArgs e)
    
    {
    
    a = Convert.ToDouble(maskedTextBox1.Text);
    
    b = Convert.ToDouble(maskedTextBox2.Text);
    
    c = Convert.ToDouble(maskedTextBox3.Text);
    
    f = (a - b) * c / 100;
    
    if (comboBox1.Text.Contains("12 месяцев"))
    
    {
    
    g = Math.Round((a + f) / 12);
    
    }
    
    if (comboBox1.Text.Contains("36 месяцев"))
    
    {
    
    g = Math.Round((a + f) / 36);
    
    }
    
    if (comboBox1.Text.Contains("5 лет"))
    
    {
    
    g = Math.Round((a + f) / 60);
    
    }
    
    if (comboBox1.Text.Contains("10 лет"))
    
    {
    
    g = Math.Round((a + f) / 120);
    
    }
    
    if (comboBox1.Text.Contains("20 лет"))
    
    {
    
    g = Math.Round((a + f) / 240);

    govnomasha, 12 Июля 2021

    Комментарии (20)
  7. Python / Говнокод #27499

    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
    import logging
    import requests
    from .. import loader, utils
    
    logger = logging.getLogger(__name__)
    
    def register(cb):
        cb(TagallMod())
    
    def chunks(lst, n):
        for i in range(0, len(lst), n):
            yield lst[i:i + n]
    
    class TagallMod(loader.Module):
    
        strings = {"name": "Tagall"}
    
        def __init__(self):
            self.config = loader.ModuleConfig("DEFAULT_MENTION_MESSAGE", "Привет", "Default message of mentions")
            self.name = self.strings["name"]
    
        async def client_ready(self, client, db):
            self.client = client
    
        async def tagallcmd(self, message):
            arg = utils.get_args_raw(message)
    
            logger.error(message)
            notifies = []
            async for user in self.client.iter_participants(message.to_id):
                notifies.append("<a href=\"tg://user?id="+ str(user.id) +"\">\u206c\u206f</a>")
            chunkss = list(chunks(notifies, 10))
            logger.error(chunkss)
            await message.delete()
            for chunk in chunkss:
                await self.client.send_message(message.to_id, (self.config["DEFAULT_MENTION_MESSAGE"] if not arg else arg) + '\u206c\u206f'.join(chunk))

    tars777, 06 Июля 2021

    Комментарии (20)
  8. JavaScript / Говнокод #27498

    +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
    class c1 {
        pin: number;
    
        hello() {
    	this.#hello();
        }
    
        #hello() {
            print("Hello World", this.pin);
    	this.pin = 20;
        }
    }
    
    function main() {
        const c = new c1();
        c.pin = 10;
        c.hello();
        print("Hello World", c.pin);
        delete c;
    
        print("done.");
    }

    Хорошие говно-новости по говно-помпилятору. Начал имплементировать классы. (когда меня это зае...т я еще не знаю, но чую что скоро)

    ASD_77, 05 Июля 2021

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

    0

    1. 1
    Definition WordUpperBound := 65536.

    Hijikata, 11 Мая 2021

    Комментарии (20)
  10. Go / Говнокод #27395

    +1

    1. 1
    2. 2
    3. 3
    if req.Lang != "" {
    	req.Lang = "EN"
    }

    Я сказал английский!

    [Поставленная задача: если пришёл запрос без поля, поставить значение по умолчанию]

    anon007, 06 Мая 2021

    Комментарии (20)
  11. JavaScript / Говнокод #27386

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    function main() {    
    	(function () {
    		print("Hello World!");
    	})();
    }

    а ваш С компилятор может так говнокодить? а мой компилятор может :)

    ASD_77, 30 Апреля 2021

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