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.

STM32 + LoRa Slave hangs

8 February 2026 @ 9:40 am

I am developing a Master-Slave smart farming system. Master: ESP32 (running FreeRTOS) Slaves: STM32 (Sensor nodes and Actuator nodes) Communication: LoRa (p2p) The Workflow: The Master requests data; the Slave responds and then enters a low-power sleep mode. This works perfectly for "Status" requests. The Problem: The system hangs specifically during Actuator Control commands. When the Master sends an actuator_on/off command: The Slave receives the message and verifies the Hub ID. It toggles the GPIO for the actuator (relay/motor). It performs a short delay, checks the pin state to verify the action, and attempts to send an ACK via LoRa. It is then programmed to enter Sleep Mode. Symptoms:

WEBRTC| huge difference between ingress and egress

8 February 2026 @ 9:36 am

I am currently developing a cross-platform solution consisting of a mobile app and a Chrome extension that facilitates file transfers via WebRTC. I’ve noticed a significant performance anomaly when the connection is forced to use a TURN relay: there is a substantial discrepancy between ingress and egress throughput speeds. Is this level of asymmetry typical when routing through a relay server, or does it indicate a deeper configuration issue? Furthermore, could external factors—such as a weak cellular signal on the mobile end or aggressive ISP throttling of UDP traffic—be the primary catalyst for this imbalance? enter image description here

Black box and ball strip not auto updating, ball-by-ball not showing in real time

8 February 2026 @ 9:15 am

This provider uses a canonical event model, unified commit pipeline, version-based rendering, WebSocket-first hybrid fallback, and atomic UI updates. I am building a Flutter live cricket scoring app using WebSocket and Provider. The app has two main real-time widgets: Black Box – shows latest ball event (SIX, FOUR, WICKET, etc) Ball Strip – shows over-wise balls Both widgets should update automatically when new ball data comes from WebSocket. Problem: Sometimes both widgets stop updating even though the provider receives new data and notifyListeners() is called. Expected Result: UI should rebuild instantly on every new ball Black Box and Ball Strip should stay in sync No manual refresh should be required Actual Result: Provider state updates correctly (verified with debugPrint) Version count

Google Appscript (V8) function does not stop execution after return statement

8 February 2026 @ 8:37 am

Currently writing a small script to be utilized in a mileage sheet I'm making to track miles for my tax return. I've written a function that I intend to utilize on each cell in a column to return to the cell a value of either true or false. Currently my function runs. Doesn't give any syntax errors and through debug and logging I've determined that it reaches my return statements and functions as expected. Main issue is that it will hang once it reaches the statement until it eventually throws an error for exceeding maximum execution time. I don't see why exactly this isn't working as it's a very simple procedure. Here's the code: // region Logging: const logSeperator = "--------------------------------\n"; // endregion //region Constants const VacationDays = [ new Date("1/1/25"), new Date("1/20/25"), new Date("2/17/25"), new Date("5/26/25"), new Date("6/19/25"), new Date("7/

Convert pdf file to word file [closed]

8 February 2026 @ 7:53 am

I am trying to convert a pdf file to word file using python. I want to use this for commercial purpose. According to the license of pdf2docx python library, i have to opensource my code if I use pdf2docx for commercial purpose. So, I am not going to use pdf2docx library. I have used pypdf and it converts the file to docx file. My input pdf had text in two columns each page. The converted file does not have text in two columns and the images from the text disappeared. How should I convert pdf file to word file such that the layout and images in word file are same as in pdf file? I am using mac os.

Can I use unique_ptr with inherited classes?

8 February 2026 @ 5:58 am

Consider the following: struct A; struct B : public A; struct C : public A; class Foo { public: void someFunction() { if( cond1 ) a = new B; if( cond2 ) a = new C; } private: A *a; // std::unique_ptr<A> a; }; It’s easy and simple to use a raw pointer here. But is there a way to use a smart pointer (std::unique_ptr) in this case? If yes, how? What syntax should I use? Please provide a way for C++11 and later.

LINQ SingleOrDefault, but without throwing exceptions

7 February 2026 @ 10:58 pm

This question is about style and efficiency. I have a working solution to my problem, but I am searching for a nicer one. I have an array of file paths and I want to find their common parent folder. In case the files are not located in the same folder, I want to throw an exception and terminate the application. So my idea was to use the SingeOrDefault LINQ operator. This operator throws an exception if the sequence contains more than one elements. The exception message is too generic though, and I want to throw a more descriptive one. So I did this: static string GetCommonParentDirectory(string[] filePaths) { try { return filePaths .Select(p => Path.GetDirectoryName(p)) .Distinct(StringComparer.OrdinalIgnoreCase) .SingleOrDefault(); } catch (InvalidOperationException) //

How can I match attributes with a value of A, B, or C in a single uBlock Origin filter?

7 February 2026 @ 8:23 pm

I am trying to create a filter in uBlock Origin that blocks elements where an attribute value is equal to one of several different values. (A, B, or C). For example, let's say I want to block span elements where the author attribute was an exact match for "alice", "bob", or "carol". I could write separate rules for each author name: example.com##span[author="alice"] example.com##span[author="bob"] example.com##span[author="carol"] However, this becomes difficult to maintain when working with more complex filter rules or matching against a large list of values. (For example, blocking posts from 170 subreddits or

Struct with dynamically allocated array that works on host and device with Cuda

7 February 2026 @ 1:42 am

I would like to create a struct that can work on the host and device that stores an array that has been dynamically allocated (unknown size at compile time). This struct would be sent to a kernel so that every thread has a pointer to it. How could I get this to work? The constructor and destructor would need to be different for a host and device using new[] and cudaMalloc() respectively. How could this struct be cleanly sent in both directions without duplicate code every time I want to send the host version to the device by sending the inner array, and then sending a duplicate of the struct with a different pointer to the device array instead of the host array. I have tried something like this but to no avail: struct MyStruct { int array_size; int* array; MyStruct(int size) { array_size = size; array = new int[size]; } ~MyStruct() { delete[] array; array = null

How to fetch website permissions as a browser extension

6 February 2026 @ 9:51 pm

I'm writing my first browser extensions using Manifest Version 3. I'm trying to manipulate the website permissions, the same shown in the Firefox's Page Info: enter image description here I found the source code here: https://github.com/mozilla-firefox/firefox/blob/main/browser/base/content/pageinfo/permissions.js#L17 There is some interesting code browsing to resource:///modules/SitePermissions.sys.mjs too. Using the about:debugging in the Inspect button I'm able to access the browser global object. There are several interesting settings on