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

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

    −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
    else if (BallToDown(paddle_2, paddle_2_pos, new Rectangle((int)ball_pos.X, (int)ball_pos.Y, ball.Width, ball.Height)))
                {
                    Paddle_s.Play();
                    ballSpeed = new Vector2(9.0f, 4.5f);
                }
                /*Левая Ракетка*/
                //Ограничения по Оси Y
                if (paddle_2_pos.Y < 0)
                    paddle_2_pos.Y = 0;
                else if (paddle_2_pos.Y > Window.ClientBounds.Height - paddle_2.Height)
                    paddle_2_pos.Y = Window.ClientBounds.Height - paddle_2.Height;
                //Управление Ракеткой
                if (Keyboard.GetState().IsKeyDown(Keys.W))
                    paddle_2_pos.Y -= speed;
                else if (Keyboard.GetState().IsKeyDown(Keys.S))
                    paddle_2_pos.Y += speed;
                /*Правая Ракетка*/
                //Ограниччения по Оси Y
                if (paddle_1_pos.Y < 0)
                    paddle_1_pos.Y = 0;
                else if (paddle_1_pos.Y > Window.ClientBounds.Height - paddle_1.Height)
                    paddle_1_pos.Y = Window.ClientBounds.Height - paddle_1.Height;
                //Управление Ракеткой
                if (Keyboard.GetState().IsKeyDown(Keys.Up))
                    paddle_1_pos.Y -= speed;
                else if (Keyboard.GetState().IsKeyDown(Keys.Down))
                    paddle_1_pos.Y += speed;
                base.Update(gameTime);
            }
    
            protected override void Draw(GameTime gameTime)
            {
                GraphicsDevice.Clear(Color.Black);
                spriteBatch.Begin();
                spriteBatch.Draw(paddle_1, paddle_1_pos, Color.White);
                spriteBatch.Draw(paddle_2, paddle_2_pos, Color.White);
                spriteBatch.Draw(ball, ball_pos, Color.White);
                spriteBatch.End();
    
                base.Draw(gameTime);
            }
            public bool BallToUp(Texture2D paddle, Vector2 paddle_pos, Rectangle ballRect)
            {
                /*Создаётся прямоугольник размером 1/3 от всей ракетки*/
                Rectangle paddleRect = new Rectangle((int)paddle_pos.X, (int)paddle_pos.Y, paddle.Width, (int)paddle.Height / 2);
                return ballRect.Intersects(paddleRect);
            }
            public bool BallToDown(Texture2D paddle, Vector2 paddle_pos, Rectangle ballRect)
            {
                /*Создаётся прямоугольник размером 1/3 от всей ракетки*/
                Rectangle paddleRect = new Rectangle((int)paddle_pos.X, (int)paddle_pos.Y + (paddle.Height / 2), paddle.Width, (int)paddle.Height / 2);
                return ballRect.Intersects(paddleRect);
            }
        }
    }

    Недавно начал программировать на C#, Решил написать Пин-Понг на моногейм, Плучилось нечто но работает отлично: отрывок кода сверху

    APV, 28 Июля 2020

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    List<UserScoreDTO> userScores = users.stream()
                    .map((u) -> ScoreUtils.aggregateUserAndFlagData(u, maxTestScore))
                    .collect(toList());
    
    return userScores.stream();

    Collect to List<UserScoreDTO> then stream the list to Stream<UserScoreDTO>

    johann, 08 Июля 2020

    Комментарии (4)
  4. Python / Говнокод #26777

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    # while 1 через for
    
    shits = ['говно']
    
    for shit in shits:
    	print('Говно')
    	shits.append('говно')

    Прост while 1 через for

    lpjakewolfskin, 28 Июня 2020

    Комментарии (4)
  5. JavaScript / Говнокод #26722

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    吾有一術。名之曰「斐波那契」。欲行是術。必先得一數。曰「甲」。乃行是術曰。
    	若「甲」等於零者乃得零也
    	若「甲」等於一者乃得一也
    	減「甲」以一。減「甲」以二。名之曰「乙」。曰「丙」。
    	施「斐波那契」於「乙」。名之曰「丁」。
    	施「斐波那契」於「丙」。名之曰「戊」。
    	加「丁」以「戊」。名之曰「己」。
    	乃得「己」。
    是謂「斐波那契」之術也。
    
    施「斐波那契」於十二。書之。

    文言 wenyan-lang
    Числа Фибоначчи.

    https://github.com/wenyan-lang/wenyan

    jojaxon, 01 Июня 2020

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

    +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
    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
    class Person {
        protected name: string;
        constructor(name: string) { this.name = name; }
    }
    
    class Employee extends Person {
        private department: string;
    
        constructor(name: string, department: string) {
            super(name);
            this.department = department;
        }
    
        public get ElevatorPitch() {
            return `Hello, my name is ${this.name} and I work in ${this.department}.`;
        }
    }
    
    const howard = new Employee("Howard", "Sales");
    console.log(howard.ElevatorPitch);
    
    //===============================================>>>>>>>>>>>>>>>>>>
    
    #ifndef TEST_H
    #define TEST_H
    #include "core.h"
    
    using namespace js;
    
    class Person;
    class Employee;
    
    class Person : public object, public std::enable_shared_from_this<Person> {
    public:
        string name;
    
        Person(string name);
    };
    
    class Employee : public Person, public std::enable_shared_from_this<Employee> {
    public:
        string department;
    
        Employee(string name, string department);
        virtual any get_ElevatorPitch();
        Employee(string name);
    };
    
    extern std::shared_ptr<Employee> howard;
    #endif
    
    #include "test.h"
    
    using namespace js;
    
    Person::Person(string name) {
        this->name = name;
    }
    
    Employee::Employee(string name, string department) : Person(name) {
        this->department = department;
    }
    
    any Employee::get_ElevatorPitch()
    {
        return "Hello, my name is "_S + this->name + " and I work in "_S + this->department + "."_S;
    }
    
    Employee::Employee(string name) : Person(name) {
    }
    
    std::shared_ptr<Employee> howard = std::make_shared<Employee>("Howard"_S, "Sales"_S);
    
    void Main(void)
    {
        console->log(howard->get_ElevatorPitch());
    }
    
    int main(int argc, char** argv)
    {
        Main();
        return 0;
    }

    Было делать нехрен в жизни и решил наговнокодить транспайлер с TypeScript в С++

    https://github.com/ASDAlexander77/TypeScript2Cxx

    ASD_77, 05 Мая 2020

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

    +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
    <?php
    
    function qes2_key ( $key = null ) {
        $key = str_split( $key );
        $keycount = count( $key );
        $xspos = 1;
        $summ = 0;
        foreach( $key as $letter ) {
            $summ += ord( $letter ) * 2 + $xspos + ( $keycount / $xspos );
            $xspos++;
        }
        $summ = explode('.', $summ );
        return $summ[0];
    }
    	
    function qes2_encrypt ( $input, $key ) {
        $input = str_split( $input );
        $icount = count( $input );
        $rsumm = qes2_key( $key );
        $result = '';
        $xspos = 1;
        $xsdisp = 1;
        foreach( $input as $letter ) {
            $char = ord( $letter ) + ( $rsumm * $xspos ) - $xsdisp ;
            $result .= chr( $char );
            $xspos++;
            $xsdisp += 1;
        }
        return $result;
    }
    	
    function qes2_decrypt ( $input, $key ) {
        $input = str_split( $input );
        $icount = count( $input );
        $rsumm = qes2_key( $key );
        $result = '';
        $xspos = 1;
        $xsdisp = 1;
        foreach( $input as $letter ) {
            $char = ord( $letter ) - ( $rsumm * $xspos ) + $xsdisp ;
            $result .= chr( $char );
            $xspos++;
            $xsdisp += 1;
        }
        return $result;
    }

    qes2a encryption (c)

    govnokoduser2000, 27 Апреля 2020

    Комментарии (4)
  8. PHP / Говнокод #26370

    +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
    public function cutPoly($business_id)
        {
            $done = [];
            $red = Isochrone::where('business_id', $business_id)->where('color', 'red')->selectRaw('id, color, ST_AsText(path) as p_path')->get()->first();
            $blue = Isochrone::where('business_id', $business_id)->where('color', 'blue')->selectRaw('id, color, ST_AsText(path) as p_path')->get()->first();
            $green = Isochrone::where('business_id', $business_id)->where('color', 'green')->selectRaw('id, color, ST_AsText(path) as p_path')->get()->first();
            if ($red && $blue) {
                if (!$red['p_path'] || !$blue['p_path']) {
                    $done['red'] = 'already';
                } else {
                    $isoString = 'POLYGON((';
                    $blue_path = $blue['p_path'];
                    $red_path = $red['p_path'];
                    if (!array_key_exists('lat', $blue['p_path'][0])) {
                        $blue_path = $blue['p_path'][0];
                    }
                    if (!array_key_exists('lat', $red['p_path'][0])) {
                        $red_path = $red['p_path'][0];
                    }
                    $isoString .= implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $red_path))
                    . '),('.
                        implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $blue_path))
                        .'))';
                    Isochrone::where('business_id', $business_id)->where('color', 'red')->update(['path' => \DB::raw("ST_GeomFromText('$isoString')")]);
                    $done['red'] = 'ok';
                }
            } else if ($red && $green) {
                if (!$red['p_path'] || !$green['p_path']) {
                    $done['red'] = 'already';
                } else {
                    $isoString = 'POLYGON((';
                    $green_path = $green['p_path'];
                    $red_path = $red['p_path'];
                    if (!array_key_exists('lat', $green['p_path'][0])) {
                        $green_path = $green['p_path'][0];
                    }
                    if (!array_key_exists('lat', $red['p_path'][0])) {
                        $red_path = $red['p_path'][0];
                    }
                    $isoString .= implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $red_path))
                    . '),('.
                        implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $green_path))
                        .'))';
                    Isochrone::where('business_id', $business_id)->where('color', 'red')->update(['path' => \DB::raw("ST_GeomFromText('$isoString')")]);
                    $done['red'] = 'ok green';
                }
            }
            if ($blue && $green) {
                if (!$blue['p_path'] || !$green['p_path']) {
                    $done['blue'] = 'already';
                } else {
                    $isoString = 'POLYGON((';
                    $green_path = $green['p_path'];
                    $blue_path = $blue['p_path'];
                    if (!array_key_exists('lat', $green['p_path'][0])) {
                        $green_path = $green['p_path'][0];
                    }
                    if (!array_key_exists('lat', $blue['p_path'][0])) {
                        $blue_path = $blue['p_path'][0];
                    }
                    $isoString .= implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $blue_path))
                    . '),('.
                        implode(',', array_map(function ($entry) {
                            return $entry['lat'] . ' ' . $entry['lng'];
                        }, $green_path))
                        .'))';
                    Isochrone::where('business_id', $business_id)->where('color', 'blue')->update(['path' => \DB::raw("ST_GeomFromText('$isoString')")]);
                    $done['blue'] = 'ok';
                }
            }
            return $done;
        }

    Он же через час - три дня будет разбиратся что написал

    websbkinfo, 21 Января 2020

    Комментарии (4)
  9. PHP / Говнокод #26366

    0

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (!$resp || !is_array($resp) || array_key_exists('error', $resp)) {
                    // TODO: what to do?
                } else {
                    Log::channel('caridis')->info("***********************NEW_DELIVERY");
                    Log::channel('caridis')->info([$order]);
                    $order->caridis_id = $resp['data']['id'];
                }

    // TODO: what to do?
    сука????

    websbkinfo, 20 Января 2020

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

    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
    public class C1834 { }
    class C1835 extends  C1834 { }
    
    public class C1836 {
    
       public void m5(ArrayList<? extends C1834> strList)
        {
            List<? extends C1834> list = new ArrayList<>();
            list.add(new C1835());
       }
    
    }

    АААА... кто-нибудь знает почему нельзя добавить объект С1835 в список? Как это обойти?

    mozga, 12 Декабря 2019

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

    0

    1. 1
    2. 2
    3. 3
    string log = pair;
    log += ":";
    log += new string(Convert.ToChar(32), 21 - pair.Length); /*spaces*/

    m_sandman, 25 Октября 2019

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