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.

How to handle asynchronous JSON schema parsing changes from a dynamic sports API endpoint in JavaScript?

30 May 2026 @ 11:04 am

I am developing a client-side web application that needs to fetch live sports telemetry directly from an infrastructure pipeline hosted on a custom domain. When I make an asynchronous GET request to the endpoint domain at https://tennis-api.com/, the browser blocks the network transport handshake and prints a CORS error to the developer console stating that no Access-Control-Allow-Origin header is present on the requested resource. Here is the exact network execution block I am using inside my front-end controller script: async function initiateDataIngest() { const targetEndpoint = "https://tennis-api-host.p.rapidapi.com/matches/live"; const fallbackEndpoint = "https://tennis-api.com/a

What's the purpose of `body_add_gg`?

30 May 2026 @ 10:30 am

After this question, I don't understand what the purpose of body_add_gg is anymore. Can't you just do this? library(officer) library(ggplot2) plt <- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) + geom_point() officer::read_docx() |> officer::body_add_plot( value = plot_instr(print(plt)) ) |> print(target = "export.docx")

C++ lambda init capture of a std::array

30 May 2026 @ 10:06 am

I would like to have an initialized std::array in the capture list of my lambda, let's just write the code it will be obvious: auto CountsDifferentiator = [previous = std::array<long long, 8>{}](std::array<int, 8> current) mutable { fmt::print("{}\t{} \n", previous, current); std::array<int,8> difference; for (unsigned j = 0; auto& d : difference) { d = current[j] - previous[j] + (current[j] - previous[j] < 0)*(1<<24) ; previous[j] = current[j]; ++j; } return difference; }; gcc complains with a "warning: captures will be by reference, not copy" which makes me thinks that something is just not right, despite the function seems to do its job just calling it few times. Will "previous" be just a separate copy than the "temporary" std::array<long long, 8>{} used to ensure the proper initializa

Java Spring Boot response entity with map

30 May 2026 @ 9:43 am

I have the following code that creates a ResponseEntity for the response of a Spring app. Is there any more efficient way of doing this method? @GetMapping"/api/payments/reservation/{idReservation}") public ResponseEntity<Map<String, Object>> obtenerPagoReal(@PathVariable("idReservation") int idReservation) { Payment pay = dao_interface.findByIdReserva(idReservation); Map<String, Object> response = new HashMap<>(); if (pago!=null) { response.put("status", "success"); response.put("code", 200); response.put("message", "Payment done"); response.put("data", pay); return ResponseEntity.ok(response); } else { response.put("status", "error"); response.put("code", 404);

How do I revive vibe code that was automated by Claude

30 May 2026 @ 9:40 am

Are there any recommendations from the group here? What are the best practices to have a type of quality assurance, security review, type of verification when you do vibe coding? Context is the following: I have developed with Claude a simple trading bot that is selling and buying stocks on a certain logic but I found out that this logic has a flaw and Claude code never revealed it to me. For example it defined its own rule: if it doesn't find the last price of a stock, it assumes a certain price and then just places an order. My question is: any experiences or clear recommendations on what I can do if I have created a new program or piece of code to verify this from a third-party instance, a different AI, or it is human?

How to safely update a shared resource map under high concurrency in Java without performance loss?

30 May 2026 @ 8:23 am

I am currently developing a backend feature where multiple worker threads need to track and update the access frequency of shared resources in memory. Initially, I used a standard HashMap, but I quickly ran into concurrent modification issues and incorrect data due to the lack of thread safety during simultaneous reads and writes. To fix this, I wrapped it using Collections.synchronizedMap, but now I am experiencing a noticeable performance bottleneck as the thread count scales up. Here is a simplified version of my current thread-safe implementation: public class ResourceTracker { private final Map<String, Integer> accessMap = Collections.synchronizedMap(new HashMap<>()); public void registerAccess(String resourceId) { Integer currentCount = accessMap.get(resourceId); if (currentCount == null) { accessMap.put(resourceId, 1); } else {

PHP Parse error: syntax error, unexpected single-quoted string

30 May 2026 @ 6:03 am

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php')" After running the above command I have encountered the below-mentioned error: PHP Parse error:  syntax error, unexpected single-quoted string "composer-setup.php", expecting ")" in Command line code on line 1 Guide me how to solve this.

Struggling to understand the foundations of programming

30 May 2026 @ 1:23 am

After much research, im still confused as to actual foundation of oop programming. Tutorials teach me how to program, how to do things, but when i create a blank project, im extremely lost on how to actually build without following a guide. Im so lost that i cant even describe what im exactly struggling with. I am using C# with various game engines to learn, primarily with unity. But forget that im struggling to grasp the basic concept of programming in general.

Swashbuckle.AspNetCore 10.1.7: OpenApiSecuritySchemeReference works but responses like 401 show as “Undocumented” in Swagger UI

29 May 2026 @ 11:09 pm

I'm using Swashbuckle.AspNetCore version 10.1.7 with the new OpenAPI setup in .NET. My Swagger security configuration looks like this: services.AddSwaggerGen(options => { options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Name = "Authorization", In = ParameterLocation.Header, Type = SecuritySchemeType.Http, Scheme = "Bearer", BearerFormat = "JWT" }); options.AddSecurityRequirement(document => new OpenApiSecurityRequirement { [new OpenApiSecuritySchemeReference("Bearer", document)] = [] }); }); This part works correctly and the authentication button appears in Swagger UI. However, I have an issue with response documentation. When an endpoint returns 401 Unauthorized (due to [Authorize]), Swagger UI shows it as: 401 �

How can I avoid using LLMs as a software developer?

29 May 2026 @ 9:39 pm

Introduction I've been developing software very successfully for many years. The reason I have chosen this profession is multifold: I'm a creative person and I need to create things I have an insatiable drive to think Financial compensation one may expect for doing this I can do my thing without constantly socializing with superficial small-talk The drive to solve real-world problems and to be a force for the better To work from home It has been a great ride to do this and I achieved quite a lot of things. Yet, the industry gradually deteriorated. I do know that sometimes libraries and APIs are needed, but I witnessed too many times the drive to use some library only to solve some problem we could have otherwise easily solved, which to me meant that the specific decision was "going with the vibes" rather than a rational choice. Sure thing, there