Captain Obvious

 The 2nd Monitor

General discussion about codereview.stackexchange.com - Welcom...
16:11
0
Q: Markdown parser library in C

QuantaFor a side project, I needed a markdown parser and I decided to roll my own. It is a SAX-style parser, i.o.w. you can hook into parser events on consumer side and do whatever you want with the content. markdown-parser.h #include <stddef.h> #include <stdio.h> #include <string.h> #include <stdbool.h>...

12:48
0
Q: Tell me your opinion (performance, problems) about this simple properties system

Lion KingI tried to create a simple properties system to use in my projects. I aim to make that system simple to be good at performance and have fewer problems, if any. // Properties class template <typename T> class Property { T m_value; public: void operator=(const T& val) { m_value = v...

yst 21:45
0
Q: Runtime agnostic WebSocket server

guest271314A runtime agnostic WebSocket server. Tested with node, deno, bun, tjs, and chrome, see https://gist.github.com/guest271314/d330c7cea513f12ef7bf523c56431453. Do I want feedback about any or all facets of the code? any aspect of the code posted is fair game for feedback and criticism. // JavaScri...

yst 19:30
0
Q: rock paper scissors NOT using rnd()

nikx0918Here is the question I was trying to answer: [11] Write a program that plays the game “Rock, Paper, Scissors.” If you are not familiar with the game do some research (e.g., on the Web using Google). Research is a common task for programmers. Use a switchstatement to solve this exercise. Also, the...

yst 18:45
0
Q: Shared-Memory Queue Implementation in C

Yukun JiangRecently I am working on implementing a shared-memory based IPC message queue in C programming language on Linux system. A few design choices I've made include The queue will have only 1 producer, possibly 1 or more consumers. (Currently my implementation is only 1 producer 1 consumer yet) The q...

yst 13:29
0
Q: Class for validating code in different Conda environments with PyTorch

SindikHi! I wrote the Validator class. (In the project, the presented code is located at the path ".../validator/init.py") It is needed for testing code in different virtual Conda environments, in the virtual environments PyTorch with the necessary versions are prepared in advance. The code works prope...

Fri 16:25
0
Q: Code made for collecting links from a website in python

enigmatic jamI'm a complete beginner in python and and used ai to create this code but i dont know if its good or bad or if it can be improved or if it should be rewritten from beginning for it to be good. i would appreciate if you could help me. this is for collecting links for an app called manga manager it...

Thu 22:21
0
Q: SystemVerilog: blinker

K_TI built this simple blinker in SystemVerilog and would very much like some help to make better: control.sv module control ( input clk, input button_0, input button_1, output [2:0] led ); localparam WAIT_TIME = 13500000; reg [2:0] ledCou...

Thu 15:57
0
Q: Video to ASCII Generation (Low Contrast Output)

Krish VijI am developing a application that lets u convert short videos to ascii my problem is that the ascii is looking washed, greyed and not much color grading and contrast i want a crisp and sharp output (as its an app) Below are basically the main problem Very subtle color variations - Most of the im...

Wed 08:39
0
Q: F# - Recursively find the first available item in a range definition

Parsa99I have the following EF Core table: [PrimaryKey(nameof(Name))] public class Scope { public required string Name { get; set; } public required IPNetwork Network { get; set; } public required IPAddress From { get; set; } public required IPAddress To { get; set; } public required...

Tue 14:37
0
Q: Optimizing this function to reduce dead band when reading a pressure transducer that has calibration device under test information

Lenny CunninghamWhen reading a pressure transducer, I'm currently using the following code to apply the "device under test data" from the calibration report. How can it determine which range segment of calibration data the output voltage is with in, without a for loop each fetch? The application is using a web w...

Mon 21:16
0
Q: Console-based Casino Game in C++

ineedahamI made a casino game that runs in the console for my grade 10 final project, and I received a 93% as my grade. I'm looking for feedback in areas such as syntax, user experience, and efficiency. I would like to know where I'm doing good, and where I need improvement. I am relatively novice in C++ ...

Jul 21 15:15
0
Q: Style taking applying control's DataContext property as converter input

Eric EggersIn my Avalonia app using the MVVM Community Toolkit, I want to have a number of buttons in multiple user controls in my application to have as their content a PathIcon with a TextBlock underneath. I want to create a style to apply to the buttons that sets the color of the PathIcon and the text ba...

Jul 20 05:45
0
Q: Repository with SQLite in Python

viuserThis repository class is supposed to be used for saving information extracted from RAR, SFV archives or files that contain the hash sum in their filenames. The abstract parent class can be found here). For now, only save/update and load are implemented. As strategy, I took the union of all fields...

Jul 19 21:29
0
Q: My shared_ptr implementation

QuasarI would like to ask for a code review of my shared_ptr<T> implementation for design, code style. Any nitpicks will extremely useful for me. The features supported by my implementation are as follows: make_shared<T> for a scalar-type T that performs no more than a single memory allocation. Suppor...

Jul 17 15:09
0
Q: Third way to place queens and rooks with the higher score (extension of the queen problem)

brunoHere is a third implementation, the second is in my question Place queens and rooks with the higher score (extension of the queen problem) and an initial one is in my answer for the question N queen problem-like (+rooks and a different goal) written by someone else, where I answered. Goal (unchan...

Jul 17 14:02
0
Q: Swift for CLI tools (traversing directories, reading text files)

flitzerTo compare ergonomics and performance of some languages for my hobby projects, I have written a simple lines of code counter in Swift, Go, Rust and Python. It scans a given directory tree for source code files and then prints a summary of the number of files, lines of code and lines of comments. ...

Jul 17 12:31
0
Q: A Pacman clone in Javascript with binary heap and A*-based AI

coderodderodde's Pacman clone I have this clone implementation of Pacman. It looks pretty much like the original, yet I had to impose some relaxations as I am not sufficiently masochistic to implement all the stuff. The Pacman is controlled via arrow keys, or WASD. All the code is in a GitHub repository. ...

Jul 17 09:54
0
Q: Parsing HTTP headers in C

Mehan AlaviI'm new to C and just finished K&R. This is a code that I've written to parse headers of a HTTP request. I want to know if my code: Is safe? (after all this is C) Does proper exit on failure? Are the ways that exitLog and exitNullPointer functions exit considered good practice? Has good implemen...

Jul 17 03:11
0
Q: Blazor web app using .NET 9: SQLDbSettings Code Optimization

DevQtI am developing a Blazor web app using C# .NET 9 in Visual Studio Code. I am using SQL Server 2017. This project is intended for internal company use. In the Program.cs file: //other configurations here builder.Services.AddDbContextFactory<SQLServerContext>(options => options.UseSqlServer(bui...

Jul 16 19:42
0
Q: Algorithm to calculate jewish Shabbat sundown on Fridays (example Berlin)

dragonessfor jewish sundown the sun has to be 8° below the horizon. And on Friday evening candles are lit 18 Minutes before jewish sundown. Example: on Friday the 18th July 2025 Chabbat homepage says: 21:19 o'clock is sundown and 21:01 o'clock is candle lighting for Berlin. The times my code calculates is...

Jul 16 04:23
0
Q: El For dentro de mi funcion principal Main no funciona en el orden que deberia

Jared McCarthyEl codigo funciona y me da la informacion de 2/3 funciones pero la de Clasificacion() donde calcula si el alumno es A, B, C, D o F simplemente no me la muestra cuando la uno en la funcion principal. Ademas en el Output me aparecen las notas y nombre es estudiantes pero desordenado, y no con el fo...

Jul 15 20:09
0
Q: My openprocessing.org program won’t pause when I want it to

Will.Octagon.GibsonI am new to programming using the site openprocessing.org. The code given below that I wrote doesn’t quite do what I want it to do. I want it to do the following: Display a red circle Wait until I tap anywhere on my iPad screen Erase the red circle Pause for a few seconds Draw a white circle I...

Jul 15 13:01
0
Q: Code to add order orderitems and payment details

yodaThis is order, orderitems and payment linked by foreign key. Controller: @PatchMapping("/orders/buy/{salesJourneyId}") @Operation(summary = "To create either card or cash order in cash-hub for BUY flow", description = "To create either card or cash order in cash-hub for BUY flow") public ...

Jul 15 11:31
0
Q: Vite ReactJS Case opener

nwmI build project Case opening simulator in React JS + tailwind. I am looking for maybe another way to implement the structure of code and tell me if I've done something wrong, what I should do better or to add something more. For now ItemsList is only for testing. I'm planning to move it to JSON ...

Jul 15 07:45
0
Q: How to speed up telegram userbot in python

voippI have a telegram userbot, monitoring certain group topic and answering certain messages. I want it to be faster than human, now it's surprisingly not. But I need to speed up its reaction, any tips? from pyrogram import Client, filters from decouple import config from pyrogram.types import Messag...

Jul 15 07:23
0
Q: Builder pattern in Rust

kiner_shahI tried to implement Builder pattern, a popular design pattern for constructing objects consisting of different components, in Rust. Here is my attempt: #[derive(Debug)] enum WheelConfiguration { TwoWheeler, ThreeWheeler, FourWheeler, FourPlusWheeler, } #[derive(Debug)] enum Engi...

Jul 15 06:38
0
Q: Ruby Array#own_uniq method

michael.zechI have implemented my own version of Ruby's Array uniq-method (Ruby docs - Class array) as a monkey patch on Array. Method-impl.: require 'set' class Array def own_uniq uniq = Set.new self.each { uniq.add(it) } uniq.to_a end end Usage: require_relative "own_uniq.rb" example = [...

Jul 14 18:44
0
Q: Rendering data from mutiple models using controller and send to a single view

nischalinnI have a master page, where I need to render data from multiple models. I have made a prototype of that page to show only the required conditions. What is the best approach for controller to retrieve data from multiple models and send to view page? Here is the code of how I do it, and please sugg...

Jul 14 16:51
0
Q: Higher-kinded types in Rust

nicotyAs a small personal exercise, I'm trying to implement a notion of higher-kinded types in Rust using type-level defunctionalisation based on the "Lightweight higher-kinded polymorphism" paper. Here's some of the work I've done so far: // Type-level application. // \* -> * trait Kind<A> { type ...

Jul 14 16:51
0
Q: SimpleStackMachine.java - A virtual stack machine written in Java

coderoddeIn this post, I present my most recent result, a stack-based virtual machine programmed in Java. Frankly, I am lazy to write the unit tests since I am pretty much burned out with it. The full repository is in GitHub. Code io.github.coderodde.simple.stack.machine.CodeBuilder.java: package io.githu...

Jul 13 22:25
0
Q: Lock free Leaky Bucket Rate Limiter

Pritish NayakI want to validate my solution for a lock-free leaky bucket rate limiter. Given a queuing capacity and rate limit per second, it should queue requests till capacity is reached and it should allow only certain number of requests per second. Extra constraints: No explicit queue. No locks. No backgr...

Jul 13 19:24
0
Q: Place queens and rooks with the higher score (extension of the queen problem)

brunoGoal This is a bit of a continuation of the question N queen problem-like (+rooks and a different goal). The goal is to quickly place Q queens and R rooks on a chessboard with a side of Q+R squares, of course without the queens and rooks being able to attack each other, to obtain the maximum sum ...

Jul 13 16:00
0
Q: Weakly-Referencing Tree Structure in Python

BetterBuiltFoolFor another project of mine, I decided that it would be handy to have a tree structure to dictate hierarchy between pieces of data, but I didn't want to unnecessarily keep that data alive if it would have otherwise expired. I searched the standard library and PyPI, but didn't find any relevant pa...

Jul 13 15:37
0
Q: Rotary Encoder Controller C++

herrgrossI built a controller with 3 rotary encoders to control various parameters of a program i wrote to control a motor. The controller delivers data via usb through serial (Arduino). Originally I used OSC to move the data to the motorprogram, so I implemented the controller as an OSC server and the mo...

Jul 13 04:19
0
Q: Does anyone see any issues with this lock class in performance

Short IntI've created a generic lock class with a timeout and EventHandlers. I'm asking here for any improvements in performance or techniques. using System; using System.Threading; public class GenericLock<T>(T value) where T : notnull { public DateTime StartTime { get; private set; } public Dat...

Jul 12 21:09
0
Q: WebRTC Data Channel over WHATWG Streams

guest271314There's been talk about implementing WebRTC Data Channel over WHATWG Streams for a while https://github.com/w3c/webrtc-pc/issues/1732 https://github.com/w3c/webrtc-nv-use-cases/issues/44 https://github.com/w3c/webrtc-rtptransport/issues/8 https://www.w3.org/2023/12/05-webrtc-minutes.html#t14 AF...

Jul 12 11:21
0
Q: Spring Boot RabbitMQ Publisher Configuration for Sending JSON Messages

Tala KafafiThe publisher class: @Service public class RabbitMQPublisher { private static final Logger LOGGER = LoggerFactory.getLogger(RabbitMQPublisher.class); private final RabbitTemplate rabbitTemplate; @Value("${message.broker.rabbitmq.consumer-update-queue}") private String topic; public RabbitMQPubl...

Jul 10 15:40
0
Q: Calculating volume expressions of \$n\$ -dimensional balls in Java - follow-up 2

coderodde(See the previous iteration.) This time, I have refactored my code a bit. It follows immediately: Code io.github.coderodde.math.simulation.volumes.NdimensionalBallVolumes.java: package io.github.coderodde.math.simulation.volumes; public class NdimensionalBallVolumes { private static final i...

Jul 9 09:17
0
Q: Game Design Patterns Command implementation

Hrant NurijanyanStarted reading the GameProgrammingPatterns book and wanted to implement the Command pattern. namespace bebop::patterns { struct Command { using Fn = void (*)(void*); // Command return type is void Fn exec; // The function to be executed when execute() is called void* m_ctx; /...

Jul 7 15:16
0
Q: I feel that these kind of lock is too much in 2025

Eduardo MolteniIs there a way to simplify this? I'm using .net Framework 4.8 (classic, not Core) private static readonly object AppConfigLock = new object(); private static bool _ready = false; private static AppConfig _Config; public static AppConfig Config { get { if (_Conf...

Jul 7 09:14
0
Q: Segment Tree implementation for a challenge

turralI have solved a typical segment-tree problem, which lets you update one single value to another in the array, or to get, from i to j, the sum of each element multiplicated by an integer B to the power of j-i-k, being i <= k <= j the index of the new element, k=0 i and k=j-i being j, all of that m...

Jul 6 18:22
0
Q: How to optimiza a N queen problem-like (+rooks and a different goal)

turralThe problem is: You have Q queens and R rooks on a board with sides of length (R+Q) ≤ 8, and you have to place all the pieces so that none attack any other piece. Each square on the board has a score assigned to it, which you obtain by placing a piece in that square. Your goal is to determine the...

Jul 6 09:52
0
Q: kNN algorithm in C

Super TuxI've been learning C for a while and I decided to make a simple kNN program. What can i do to improve the program? Am i doing memory management right? Can the structure of the code be improved in general? Link to code in github: https://github.com/KRsupertux/projects/blob/main/C/kNN/main.c #include

Jul 6 07:17
0
Q: Json powered C++ CLI Engine

Hrant NurijanyanI decided to create cli(s) in C++. For instance a music player which will play music from my library via commands player play muse or player shuffle. Another idea is to create a todo list for that day... during online meetings you want to take notes(todos) so you open up your terminal and type to...

Jul 6 06:55
0
Q: Calculating volume expressions of n -dimensional balls in Java - follow-up

coderoddeIntro (The previous/initial iteration is there.) This time, I have incorporated a nice answer by Martin R. Updated code package io.github.coderodde.math.simulation.volumes; public class NdimensionalBallVolumes { private static final int LARGEST_N = 10; public static voi...

Jul 6 02:30
0
Q: Looking for front webdev guidance

Savage_2010sThis is my 1st static website. I started making it from scratch, without using Wordpress or Figma. Just pure HTML+CSS, but soon I realized my fonts werent responsive, so I found there are css variables, and now they are used in the ":root" element to set things like colors and fonts. So I went to...

Jul 5 15:47
0
Q: React reorderable list

Tom Hulton-HarropI've been playing around more and more with React recently, and wound up wanting to create a fully animated reorderable list. You can get idea about what it looks like here. It's a self contained little demo with hard-coded sizes/values, but it does handle a bunch of minor edge cases. The code li...

Jul 5 12:50
0
Q: Python OOP - optimising a game of hangman

user30970420I am currently learning object oriented programming in Python. I attempted writing an OOP program for hangman, and while the program is functional, I just ended up writing a very long class method. Any suggestions on how to improve the code to make it more pythonic, and some resources that can he...

Jul 5 10:37
0
Q: Calculating volume expressions of \$n\$-dimensional balls in Java

coderoddeIntro This time I have a Java program that prints some expression denoting the volumes of $n$-dimensional balls. All the math behind this is there. Code package io.github.coderodde.math.simulation.volumes; public class NdimensionalBallVolumes { private static final int LARGEST_N = 10; ...