1. C# / Говнокод #28642

    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
    97. 97
    98. 98
    class StargateSimulator
    {
        static bool shieldEnabled = false;
    
        static void Main()
        {
            Console.WriteLine("Stargate Simulator");
            Console.WriteLine("------------------");
    
            // Check for zero point module
            Console.Write("Zero Point Module detected. Proceed with simulation? (y/n) ");
            string response = Console.ReadLine();
            if (response.ToLower() != "y")
            {
                Console.WriteLine("Simulation cancelled.");
                return;
            }
    
            // Enable shield
            Console.Write("Enable gate shield? (y/n) ");
            response = Console.ReadLine();
            if (response.ToLower() == "y")
            {
                EnableShield();
            }
    
            // Enter gate address
            Console.Write("Enter gate address: ");
            string address = Console.ReadLine();
            if (address.Length != 6 && address.Length != 8)
            {
                Console.WriteLine("Invalid address length.");
                return;
            }
    
            // Dial gate
            Dial(address);
    
            Console.WriteLine("Simulation complete.");
        }
    
        static void Dial(string address)
        {
            // Check for valid address
            if (address.Length != 6 && address.Length != 8)
            {
                Console.WriteLine("Invalid address length.");
                return;
            }
    
            // Check for energy source
            Console.Write("Energy source detected. Proceed with dialing? (y/n) ");
            string response = Console.ReadLine();
            if (response.ToLower() != "y")
            {
                Console.WriteLine("Dialing cancelled.");
                return;
            }
    
            // Dial gate
            Console.WriteLine("Dialing gate...");
            if (shieldEnabled)
            {
                Console.WriteLine("Gate shield is active.");
            }
            Console.WriteLine("Chevron 1 encoded.");
            Console.WriteLine("Chevron 2 encoded.");
            Console.WriteLine("Chevron 3 encoded.");
            Console.WriteLine("Chevron 4 encoded.");
            Console.WriteLine("Chevron 5 encoded.");
            Console.WriteLine("Chevron 6 encoded.");
            if (address.Length == 8)
            {
                Console.WriteLine("Chevron 7 encoded.");
                Console.WriteLine("Gate engaged.");
            }
            else
            {
                Console.WriteLine("Gate engaged.");
            }
        }
    
        static void EnableShield()
        {
            // Check for available power
            Console.Write("Power levels stable. Activate gate shield? (y/n) ");
            string response = Console.ReadLine();
            if (response.ToLower() != "y")
            {
                Console.WriteLine("Shield activation cancelled.");
                return;
            }
    
            // Activate shield
            Console.WriteLine("Shield activated.");
            shieldEnabled = true;
        }
    }

    Симулятор наборного устройства звездных врат.

    P.S. За Канон-френдли не отвечаю, т.к. фанат серии но любитель немножко поизвращаться над ЛОРом...

    DartPower, 19 Марта 2023

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

    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
    namespace TimeMachineSimulator
    {
        class Program
        {
            static void Main()
            {
                Console.WriteLine("Welcome to the Time Machine Simulator!");
                TimeMachine machine = new();
                while (true)
                {
                    Console.WriteLine("What would you like to do?");
                    Console.WriteLine("1. Travel in time");
                    Console.WriteLine("2. Show current time");
                    Console.WriteLine("3. Show travel history");
                    Console.WriteLine("4. Exit");
                    string input = Console.ReadLine();
                    Console.WriteLine();
                    switch (input)
                    {
                        case "1":
                            Console.Write("Enter the number of years to travel: ");
                            int years = int.Parse(Console.ReadLine());
                            try
                            {
                                machine.Travel(years);
                                Console.WriteLine("Travel successful.");
                            }
                            catch (TimeMachineException e)
                            {
                                Console.WriteLine(e.Message);
                            }
                            break;
                        case "2":
                            Console.WriteLine("Current time: " + machine.GetCurrentTime());
                            break;
                        case "3":
                            List<DateTime> history = machine.GetTravelHistory();
                            Console.WriteLine("Travel history:");
                            foreach (DateTime time in history)
                            {
                                Console.WriteLine(time);
                            }
                            Console.WriteLine();
                            break;
                        case "4":
                            Console.WriteLine("Thank you for using the Time Machine Simulator! Press any key to exit...");
                            Console.ReadKey();
                            return;
                        default:
                            Console.WriteLine("Invalid input. Please try again.");
                            break;
                    }
                }
            }
        }
    
        public class TimeMachineException : Exception { public TimeMachineException(string message) : base(message){}}
    
        public class TimeMachine
        {
            private DateTime currentTime;
            private readonly List<DateTime> travelHistory;
            public TimeMachine()
            {
                this.currentTime = DateTime.Now;
                this.travelHistory = new List<DateTime>();
            }
            public void Travel(int years)
            {
                DateTime futureTime = this.currentTime.AddYears(years);
                if (futureTime > DateTime.Now)
                {
                    throw new TimeMachineException("Cannot travel to the future!");
                }
                this.currentTime = futureTime;
                this.travelHistory.Add(futureTime);
            }
            public DateTime GetCurrentTime()
            {
                return this.currentTime;
            }
            public List<DateTime> GetTravelHistory()
            {
                return this.travelHistory;
            }
        }
    }

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

    DartPower, 19 Марта 2023

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

    0

    1. 1
    namespace NardeGame { public class NardeGame { static void Main() { Console.WriteLine("Welcome to Narde Game!"); NardeGame game = new(); game.Play(); Console.WriteLine("Thank you for playing Narde Game! Press any key to exit..."); Console.ReadKey(); } private readonly Player player1; private readonly Player player2; private readonly Board board; public NardeGame() { player1 = new Player("Armen"); player2 = new Player("Suren"); board = new Board(); } public void Play() { while (!board.IsGameOver()) { Player currentPlayer = board.GetTurn() == Turn.WHITE ? player1 : player2; Console.WriteLine("It's " + currentPlayer.GetName() + "'s turn."); Console.WriteLine(board); int from, to; do { Console.Write("Enter the starting point of your move: "); from = int.Parse(Console.ReadLine()); Console.Write("Enter the ending point of your move: "); to = int.Parse(Console.ReadLine()); } while (!Board.IsValidMove(from, to, currentPlayer.GetColor())); Board.MakeMove(from, to); board.NextTurn(); } Console.WriteLine("Game over."); Console.WriteLine(board); Console.WriteLine(board.GetWinner().GetName() + " won!"); } } public enum Color { WHITE, BLACK } public enum Turn { WHITE, BLACK } public class Player { private readonly string name; private readonly Color color; public Player(string name) { this.name = name; color = name == "Armen" ? Color.WHITE : Color.BLACK; } public string GetName() { return name; } public Color GetColor() { return color; } } public class Board { private readonly int[] points; private Turn turn; public Board() { points = new int[24] { 2, 0, 0, 0, 0, -5, 0, 3, 0, 0, 0, -5, 5, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, -2 }; turn = Turn.WHITE; } public bool IsGameOver() { int whiteCount = 0; int blackCount = 0; for (int i = 0; i < 24; i++) { if (points[i] > 0) { whiteCount += points[i]; } else if (points[i] < 0) { blackCount -= points[i]; } } return whiteCount == 0 || blackCount == 0; } public Player? GetWinner() { int whiteCount = 0; int blackCount = 0; for (int i = 0; i < 24; i++) { if (points[i] > 0) { whiteCount += points[i]; } else if (points[i] < 0) { blackCount -= points[i]; } } if (whiteCount > blackCount) { return new Player("Armen"); } else if (blackCount > whiteCount) { return new Player("Suren"); } else { return null; } } public Turn GetTurn() { return turn; } public void NextTurn() { turn = turn == Turn.WHITE ? Turn.BLACK : Turn.WHITE; } public static bool IsValidMove(int from, int to, Color color) { return true; } public static void MakeMove(int from, int to) { } public override string ToString() { string output = ""; for (int i = 0; i < 24; i++) { output += points[i] + " "; } return output.TrimEnd(); } } }

    Армяне играют в однострочные нарды... :)

    DartPower, 19 Марта 2023

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

    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
    namespace ParticleAccelSim
    {
        public class Particle
        {
            public double X { get; set; } // координата частицы по оси x
            public double Y { get; set; } // координата частицы по оси y
            public double VX { get; set; } // скорость частицы по оси x
            public double VY { get; set; } // скорость частицы по оси y
            public double Mass { get; set; } // масса частицы
            public double Charge { get; set; } // заряд частицы
    
            public Particle(double x, double y, double vx, double vy, double mass, double charge)
            {
                X = x;
                Y = y;
                VX = vx;
                VY = vy;
                Mass = mass;
                Charge = charge;
            }
        }
    	
        public class ParticleAccelerator
        {
            private List<Particle> particles = new List<Particle>(); // список всех частиц
            private double timeStep = 0.01; // размер шага при моделировании
    
            public void AddParticle(Particle p)
            {
                particles.Add(p);
            }
    
            public void RunSimulation(int numSteps)
            {
                for (int i = 0; i < numSteps; i++)
                {
                    foreach (Particle p in particles)
                    {
                        // вычисляем силы, действующие на частицу
                        double ax = 0;
                        double ay = 0;
    
                        foreach (Particle other in particles)
                        {
                            if (other != p)
                            {
                                double dx = other.X - p.X;
                                double dy = other.Y - p.Y;
                                double r = Math.Sqrt(dx * dx + dy * dy);
                                double f = (p.Charge * other.Charge) / (r * r); // закон Кулона
    
                                ax += f * dx / r;
                                ay += f * dy / r;
                            }
                        }
    
                        // вычисляем новое положение и скорость частицы
                        p.VX += ax * timeStep / p.Mass;
                        p.VY += ay * timeStep / p.Mass;
                        p.X += p.VX * timeStep;
                        p.Y += p.VY * timeStep;
                    }
                }
            }
        }
    }

    Исходный код симулятора ускорителя частиц, например "Большой адронный коллайдер". Просьба не запускать этот код, т.к. я уже пару дней назад запустил, а сегодня уже не могу понять правильно говорить "Возможность этого резиста крайне мала" или "Вероятность этого резиста крайне мала"... ТАК ЧТО БУДЬТЕ ОСТОРОЖНЫ! Можно сломать нашу реальность!

    DartPower, 19 Марта 2023

    Комментарии (2)
  5. Python / Говнокод #28638

    0

    1. 1
    AttributeError: type object 'datetime.datetime' has no attribute 'from_timestamp'. Did you mean: 'fromtimestamp'?

    ISO, 19 Марта 2023

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

    0

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

    #38: https://govnokod.ru/27833 https://govnokod.xyz/_27833
    #39: https://govnokod.ru/27862 https://govnokod.xyz/_27862
    #40: https://govnokod.ru/27869 https://govnokod.xyz/_27869
    #41: https://govnokod.ru/27933 https://govnokod.xyz/_27933
    #42: (vanished) https://govnokod.xyz/_27997
    #43: https://govnokod.ru/28042 https://govnokod.xyz/_28042
    #44: https://govnokod.ru/28080 https://govnokod.xyz/_28080
    #45: https://govnokod.ru/28086 https://govnokod.xyz/_28086
    #46: https://govnokod.ru/28105 https://govnokod.xyz/_28105
    #47: https://govnokod.ru/28166 https://govnokod.xyz/_28166
    #48: https://govnokod.ru/28229 https://govnokod.xyz/_28229
    #49: https://govnokod.ru/28298 https://govnokod.xyz/_28298
    #50: https://govnokod.ru/28308 https://govnokod.xyz/_28308
    #51: https://govnokod.ru/28329 https://govnokod.xyz/_28329
    #52: https://govnokod.ru/28340 https://govnokod.xyz/_28340
    #53: (vanished) https://govnokod.xyz/_28346
    #54: https://govnokod.ru/28353 https://govnokod.xyz/_28353
    #55: https://govnokod.ru/28361 https://govnokod.xyz/_28361
    #56: https://govnokod.ru/28383 https://govnokod.xyz/_28383
    #57: https://govnokod.ru/28411 https://govnokod.xyz/_28411
    #58: https://govnokod.ru/28454 https://govnokod.xyz/_28454
    #59: https://govnokod.ru/28472 https://govnokod.xyz/_28472
    #60: https://govnokod.ru/28540 https://govnokod.xyz/_28540
    #61: https://govnokod.ru/28548 https://govnokod.xyz/_28548
    #62: https://govnokod.ru/28555 https://govnokod.xyz/_28555
    #63: https://govnokod.ru/28573 https://govnokod.xyz/_28573
    #64: https://govnokod.ru/28584 https://govnokod.xyz/_28584
    #65: https://govnokod.ru/28599 https://govnokod.xyz/_28599
    #66: https://govnokod.ru/28609 https://govnokod.xyz/_28609
    #67: https://govnokod.ru/28615 https://govnokod.xyz/_28615

    nepeKamHblu_nemyx, 18 Марта 2023

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

    0

    1. 1
    Плохие новости, Говнокод скоро закроется. Ищите более уютную борду.

    Начитайте искать уже сичас.

    Lure_Of_Chaos, 15 Марта 2023

    Комментарии (26)
  8. Куча / Говнокод #28633

    +6

    1. 1
    Логика работы бота для создания активности.

    ...Часто бывает ситуация, когда обсуждение в ветке достигает некоторого ситуационного апогея, когда вопрос, быть может, уже решен и никто из юзеров больше не хочет добавлять ответы, чтобы не портить общую картину завершенности.

    Особенно опасна такая ситуация на небольших форумах, где тем - две-три и - обчелся, ибо ведет к охлаждению интереса к ним у юзеров и запустеванию. В целях борьбы с этим явлением, на форумах обязательно имеются разделы "флудильня" и подобные, где пользователи могли бы пообщаться на нейтральные темы, но ввиду вышеописанного принципа эта мера также не является эффективной.

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

    1. Бот бот-батбот-батбот "прошевеливает пламень уст" в замершей ветке, анализируя дату последнего коммента и отвечая на него комментарием, который будет являться своеобразным эвентом - сигналом, подталкивающих пользователей к общению.
    2. Поскольку по статистике человек запоминает последнюю сказанную собеседником фразу (а читатель - последнее предложение в абзаце), несложно было разработать незамысловатый алгоритм, который парсит комментарии и сортирует по дате. Комментарии дифференцируются на пригодные - в последнем предложении есть по крайней мере один глагол, - и непригодные, т.е. не содержащие глаголов.

    3. Из фразы в случайном порядке вычленяется глагол. Затем, при использовании таблицы спряжений, глаголу придается изъявительное наклонение единственного числа прошедшего времени (нашёл, сделал, обработал, уснул, купил). Далее бог составляет вопросительное предложение по схеме частица+вопросительное наречие+глагол, например, "ну как, сделал?", которое бот постит в ответ на последний комментарий.

    guest6_uebok, 14 Марта 2023

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

    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
    /**
         * Hash a value according to FraudRecord specifications
         *
         * @param string $value
         * @param bool $prepare password is treated differently
         * @return string
         */
        function hash($value, $prepare = true)
        {
            if($prepare) {
                $value = trim($value);
                $value = strtolower($value);
                $value = str_replace(" ", "", $value);
            }
    
            for($i = 0; $i < 32000; $i++)
                $value = sha1("fraudrecord-".$value);
            return $value;
        }

    Безопасность в безопасности от безопасности

    https://github.com/splitice/fraudrecord-api/blob/master/src/Splitice/FraudRecord/FraudRecordApi.php#L58

    bot, 13 Марта 2023

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

    −2

    1. 1
    Бесконечный оффтоп имени Борманда #10

    #1: https://govnokod.ru/25864 https://govnokod.xyz/_25864
    #2: https://govnokod.ru/25921 https://govnokod.xyz/_25921
    #3: https://govnokod.ru/26544 https://govnokod.xyz/_26544
    #4: https://govnokod.ru/26838 https://govnokod.xyz/_26838
    #5: https://govnokod.ru/27625 https://govnokod.xyz/_27625
    #6: https://govnokod.ru/27736 https://govnokod.xyz/_27736
    #7: https://govnokod.ru/27739 https://govnokod.xyz/_27739
    #8: https://govnokod.ru/27745 https://govnokod.xyz/_27745
    #9: https://govnokod.ru/28307 https://govnokod.xyz/_28307

    nepeKamHblu_nemyx, 12 Марта 2023

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