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.

Debian / Apache + Virtual Hosts / PHP-FPM: PHP files loaded from wrong directory

10 April 2026 @ 11:41 am

I have set up a Debian virtual machine with an Apache webserver, having multiple virtual hosts for different projects, using FCGI + PHP-FPM. The Apache is delivering his files for the virtual hosts correctly. But the PHP-FPM seems to use wrong root directories for others than the default virtual host. If i call the "index.php" for one of the subordered virtual host, the wrong one (that for the top level virtual host) is delivered. In its variables, it has a correctly adapted document root directory and the correct file name in the $_SERVER variable: 'DOCUMENT_ROOT' => '/var/www/certify', 'CONTEXT_DOCUMENT_ROOT' => '/var/www/certify', 'SCRIPT_FILENAME' => '/var/www/certify/index.php', ...but nevertheless the script file actually called is not at all the one depicted, but... /var/www/index.php If i call a uniquely named (and existing) file, for example "index2.php", i get...

Svelte 5: Fine grained reactivity for derived nested dictionary

10 April 2026 @ 11:38 am

I have a possibly large state of nested object in svelte 5, say like: let a = $state({foo: {bar: baz: {name: "x", value: 4}}, unrelated: 42}) and I want to derive from it a new variable b so that for any x and y, b[x][y].newValue = a[x][y].value * 2, so I would get here: b = {foo: {bar: baz: {newValue: 4}}) The problem with b = $derived(…) is that if a single element changes in a, it will recompute the whole value b, which does not scale. Any idea how to do it with fine-grained reactivity, so that changing a[x][y].name only changes a single of b? Ideally I'd like a solution that works without creating components since this is supposed to be defined in a class that components will load.

I want to write an System Monitering in C

10 April 2026 @ 11:17 am

Body: I want to write a simple system monitoring tool in C (something very basic like showing CPU and memory usage, maybe later disk and network) but I am not sure where to start. My environment: OS: Windows 11 Language: C (compiled with gcc) So far, I have: Basic knowledge of C (loops, functions, pointers, file I/O). I know there are commands like top, htop, and /proc files, but I do not understand how to read system metrics from C code. My questions are: What are the usual approaches to read CPU and RAM usage in C on Windows ? Are there any minimal examples or references that show how to read CPU usage and memory usage in C from Windows? What would be a reasonable first step or small milestone for a beginner-friendly system monitor project?

Outbound connectivity from optional Private subnet Azure virtual network

10 April 2026 @ 11:12 am

I created a virtual network today on April 10th 2026. While creating subnet, I see checkbox that says "Enable private subnet (no default outbound access)". enter image description here In my azure web app virtual net configuration I have checked the checkbox "Outbound internet traffic". enter image description here I tested the internet connectivity of my web app is working fine without having any NAT gateway and with setting private subnet. enter image description here My questions are: How my app service has internet connectivity despite having the Private subnet enabled? I have disabled private subnet for now. Is there any plan by Azure team to stop default outbound access in future? Is it recommended to go

ReDOS - Incorrect regular expression

10 April 2026 @ 11:11 am

In ReDOS test the following javascript snippet was given the flag What could be the fix to eliminate the ReDOS flag if (!id || !/^\d+$/.test(id)) return null;

C++/CMake/Vcpkg BCryptGenRandom Undefined Error [duplicate]

10 April 2026 @ 11:01 am

While building this project I get an error undefined reference to `BCryptGenRandom' I tried adding #include <bcrypt.h> in the main.cpp file and bcrypt to the target_link_libraries command in the CMakeLists.txt file but it didn't work. I also tried installing it into the project directory with vcpkg but it couldn't find anything. I tried putting bcrypt before the other libraries and just writing bcrypt instead of its path but nothing changed. main.cpp #include <iostream> #include <ixwebsocket/IXNetSystem.h> #include <ixwebsocket/IXWebSocket.h> #include <chrono> #include <thread> #include <tlhelp32.h> #include <sstream> using namespace std; struct EnumData { DWORD dwProcessId; HWND hWnd; }; BOOL CALLBACK EnumProc(HWND hwnd, LPARAM lParam) { EnumData& data = *(EnumData*)l

DataGrid with remote operations

10 April 2026 @ 10:52 am

with remoteOperations enable grouping. supports all data types, keep some custome templates, header filters should format correctly how to do this task using angular DevExtreme, node.js and mongodb it supports allversions and withot any errors

How to count how many consecutive days I had over an specific temperature? (in R)

10 April 2026 @ 10:17 am

I have created an indicator "hd" (heat day) when the temperature is over the 90th percentile of the distribution, and then I repeated the same instruction for a counter number of days (cd). temp <- temp %>% mutate(hd=if_else(tmean>p90,1,0), cd=if_else(tmean>p90,1,0)) Then I applied another line to count over this last variable (cd), and it didn't work temp <- temp %>% mutate(cd=if_else(hd==1, cd + lag(cd, default = 0), 0)) So I got something like this (I added what I want to have) Year Month Day Temperature p90 HD CD CD (correct) 1992 1 13 20.68 21.95 0 0 0 1992 1 14 20.82 21.95

Xcode Error: Library not found for -lPods | Linker command failed with exit code 1

10 April 2026 @ 10:06 am

I am encountering a linker error while trying to build my iOS project in Xcode. The build fails with the following two errors: Library not found for -lPods-SoulVerse Linker command failed with exit code 1 (use -v to see invocation)

Emergency Weather App Failure - Receiving emergency evacuation alert but not showing it

10 April 2026 @ 5:14 am

We're making an advanced weather app that displays emergency alerts. It uses the weather.com API and Supabase Realtime to receive emergency notifications. After finishing part of the frontend, we tested it, but it didn't work. Logs shown that the message was sent and received by the publishable key on the frontend, but no alert was displayed. We've double-checked the callback mechanism and used console.log, which verifies the function was executed. Still, it doesn't display the alert. Here's the callback: const chatChannel = supabase.channel(location) chatChannel .on('broadcast', { event: 'emergency' }, (payload) => { app.displayPush({ type: 'emergency', message: payload.message, locations: payload.locations, source: payload.source, id: payload.id }) }) .subscribe() And here's the minimal displayPush: