StackOverflow.com

VN:F [1.9.22_1171]
Rating: 8.5/10 (13 votes cast)

Random snippets of all sorts of code, mixed with a selection of help and advice.

Go falling back on 500 HTTP status when explicitly setting a 409

19 June 2026 @ 8:07 am

Hoping a clever cookie can help me with this one. I have tried debugging with LLMs but they are coming up with all sorts of fancy nonsense. Problem: Go is sending a 500 status instead of a 409 inside a flow control block that catches SQL duplication errors, despite being told explicitly to send http.StatusConflict . Flow: I deliberately enter an email address that already exists SQL (postgres) catches this with a 23505 unique violation error and sends back ErrDuplicateEmail API handler catches this prints the error to the console and then sets the response status to 409 This is returned to the frontend (Svelte), but passes to the generic error handler. The problem is that we can't show our user that the email they're entering already exists. Troubleshooting steps I've taken: Svelte error mess

fopen consistently retuns Operation not permitted. MacOS 26,5 Xcode 26.2 (17C52)

19 June 2026 @ 7:30 am

I am using Xcode to develop an application written in C, not Swift, and I need to open a simple file not selected by the user. The code uses a simple fopen (fname,"r"). This always fails with errno==1 whose message is "operation not permitted. The file is located in a folder with no access control and I used terminal to change its access control to 777 with chmod. claude.ai suggested that I disable App Sandbox but this has no effect.

Exists query returns wrong result after updating to Spring Boot 4.1

19 June 2026 @ 7:20 am

After updating to Spring Boot 4.1 some of our tests fail. The test: @SpringBootTest @Transactional class SpringTestApplicationTests { @Autowired RoleRepository roleRepository; @Autowired UserRepository userRepository; Role role; @BeforeEach public void setUp() { role = new Role(); role.name = "Admin"; role = roleRepository.saveAndFlush(role); } // fails during second assert @Test void test_exists() { assertThat(roleRepository.isRoleReferencedByAnyUser(role.id)).isEqualTo(false); var user = new User(); user.name = "admin"; user.role = role; userRepository.saveAndFlush(user); assertThat(roleRepository.isRoleReferencedByAnyUser(role.id)).isEqualTo(true); } } The repository: public interface RoleRepository extends JpaRepository<Role, Long> { @Query(value = "select exists (se

Best way to start DSA for placements

19 June 2026 @ 7:13 am

I am a Computer Science student preparing for technical interviews and placements. I want to build a strong foundation in Data Structures and Algorithms (DSA), but I am unsure about the most effective approach. Currently, I know basic programming concepts and want to improve my problem-solving skills. There are many resources available like LeetCode, HackerRank, CodeChef, books, and courses, which makes it confusing to choose a structured path. I would like advice on: 1. Which topics should I learn first (arrays, strings, recursion, trees, graphs, dynamic programming, etc.)? 2. Should I focus more on understanding theory first or directly solving problems? 3. How many problems should I solve daily to make consistent progress? 4. What mistakes should beginners avoid while preparing DSA for placements? 5. Which platforms or resources provide the best interview-oriented practice? I am looking for a practical roadmap followed by de

How to store data in a simple console application in C

19 June 2026 @ 6:10 am

I am looking for a solution at HowTo store data in C. It is not a big deal, where people could say: "just use C++" or kind of something. It is just about storing students information. I know that C# has dictionarys or similar data storing "tools". The question is: HowTo store data in C in the most ethic way? Here is my code, if you have a general advice, you can share it with me. I am open for everything. Btw I am a beginner at C. #include <stdio.h> #include <stdbool.h> #include <string.h> bool running = true; int userInput; int listStudent() { printf("listing students..."); return 0; } void addStudent() { printf("Hello, we are adding Students\n"); return 0; } void removeStudent() { printf("removing Students...\n"); return 0; } struct Student { char firstname[10]; char surname[10]; int age; int id; }; struct Methods { char list[20]; char add[20]; char remove[20];

Error when running test cases: set_timeout(timeout)

19 June 2026 @ 4:09 am

enter image description here The test cases are provided by my prof. (We are not learning to write test cases. We are learning other content.) Every time I run the test, I get an error in set_timeout(timeout). Even if I write return 0, return None to every function, I still get the same error. I suppose there is a timeout, and then the timeout function in the test case is not successfully implemented, which raised the error. But how could the timeout occur when all return statements are 0 or None?

Installed dbt-core, but dbt --version yields error message

19 June 2026 @ 3:17 am

Context I have installed dbt-core v1.11 using uv and I'm now having an issue. When I run uv run dbt --version I get the following error message: user@host proj_dir % uv run dbt --version Traceback (most recent call last): File "<project_root>.venv/bin/dbt", line 4, in <module> from dbt.cli.main import cli File "<project_root>.venv/lib/python3.14/site-packages/dbt/cli/__init__.py", line 1, in <module> from .main import cli as dbt_cli # noqa ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<project_root>.venv/lib/python3.14/site-packages/dbt/cli/main.py", line 11, in <module> from dbt.adapters.factory import register_adapter File "<project_root>.venv/lib/python3.14/site-packages/dbt/adapters/factory.py", line 9, in <module> from dbt_common.events.functions import fire_event File &quo

Recommendation Needed: Thumbnail Generation and Bulk Download Strategy for Large File Storage (GCP VM + R2)

19 June 2026 @ 1:52 am

I am currently hosting my website on a Google Cloud Platform (GCP) Virtual Machine (VM), where users upload large datasets (approximately 20–50GB per upload) consisting of image files such as JPG, PSD, TIFF, etc., which are stored in an R2 bucket. I am facing two technical challenges and would like guidance on the best approach: Thumbnail Generation: I need an efficient and scalable way to generate thumbnails for large image uploads without impacting server performance. Bulk Download (ZIP Creation): When a user requests to download their complete dataset, I need to generate a ZIP file containing all related files. Since the datasets are very large, I am concerned about performance, memory usage, and processing time. Could you please suggest the best architecture or tools/services to handle these requirements efficiently? Ideally, I am looking for a solution that minimizes load

Why will my dropdown element stay down when hovering? [closed]

18 June 2026 @ 8:27 pm

I have all of my code on this website https://dev.mindaman.com On the website (which I strongly suggest using for the issue sampler), All of the headers can be hovered with the mouse and the dropdowns all show up, but when a user tries to interact with the dropdowns, they disappear and do not stay. This current set of code gives no errors or warnings related to the issue. I also provided a debug variable checker for the Shop dropdown in case if it is of use. I have tried changing the ID of the dropdown area into a class and controlling the movement that way while only having one ID for the whole element but that did not solve the issue. Please keep in mind that I am very unskilled at Web Design, especially backend design so please let me know if you can help!

How often do you use C++ attributes?

18 June 2026 @ 8:19 pm

I always forget that attributes like [[nodiscard]], [[assume]], [[likely]], and [[unlikely]], exist. I never use them. Every once in a while, I see somebody using them. Should I start using these whenever I can? How much of a difference does it really make? I'd like to hear your thoughts. A list of attributes is here: https://cppreference.com/cpp/feature_test