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.

narrowing warnings while initializing an array

6 December 2025 @ 5:50 am

I have a class that I'm using across a somewhat large project, and it has a set of functions which need to take, as one argument, an array-like argument full of integral values. The size of the array has to match a template parameter in the class. Here's a simplified analog: template<std::size_t N> struct mystruct { void func(const std::array<std::size_t,N>&) { // code } }; int main() { mystruct<2> ms; ms.func({1,2}); return 0; } This compiles without issue. However, if I do something like this: int n = 3; ms.func({n,n}); I get a warning warning: narrowing conversion of ‘n’ from ‘int’ to ‘long unsigned int’ [-Wnarrowing] Fair enough. I think this warning should be taken seriously, and I do not want to use the -Wnarrowing option globally. Does anyone know if this warning can be turned off for just one function? If I try this,

How to implement free WhatsApp notifications internally without external APIs?

6 December 2025 @ 5:45 am

I’m trying to build a health-monitoring system in Python that needs to send alert messages through WhatsApp. The problem is that my company doesn’t allow any third-party services or paid APIs, and they want the solution to be completely free. We are using SQL Server as the database (already licensed by the company). I only know a bit of Python, so I’m not sure what options I have without using third-party tools like Twilio or Meta’s Cloud API. Is there any way to send WhatsApp messages directly from Python under these restrictions? Or are there alternative approaches I should consider? Any ideas, suggestions, or guidance would really help. Thank you!

vba, assign a function param to a local variable

6 December 2025 @ 5:39 am

This is an embarrassingly basic question to have to ask, but I'm getting incredibly frustrated by VBA and it's unhelpful errors and poor documentation, and I need help. All I want to do is copy the value of a function parameter into a local variable. It's such a fundamental programming concept but with VBA I can't get it to co-operate. It just gives me 'BASIC runtime error, argument is not optional', pointing at that line, and I'm finding nothing helpful through google to figure out what simple mistake I'm making. I've stripped the function down to the following example: Public Sub IHateYouVBA(ByVal row As Integer) Dim test as Integer, test2 as Integer test = 1 test2 = 2 test = test2 test = row End Sub The error points to the last line. As you can see, it's perfectly happy creating local variables, assigning values to them, and even copying the value from one to the other. But as soon as I ask it to copy the function

want to Swift Popup massage quite using outer screen clicked

6 December 2025 @ 5:31 am

I am learning swiftUI ant I have shown a add new note using $isAlertShowing now I want to close that small screen when User click to outer screen of that popup not using any cancel button or like that. using click on outer screen.

How to properly configure transaction isolation levels when using columnstore indexes in PolarDB MySQL IMCI?

6 December 2025 @ 5:08 am

I've been working with PolarDB MySQL IMCI for a few days now and have successfully implemented columnstore indexes on several analytical tables. I've read through the transaction isolation documentation, but I'm still unsure about the proper configuration for my mixed workload. From what I understand in the documentation: Columnstore indexes officially support READ_COMMITTED and REPEATABLE_READ isolation levels For REPEATABLE_READ, you need to use a custom read-only endpoint that only connects to nodes with columnstore indexes There's a parameter called imci_ignore_unsupported_isolation_level that can help with compatibility for tools like Metabase I'm using a PolarDB cluster with one primary node and two read-only nodes, and I've created a custom endpoint for my analytical queries as recommended. My specific questions: For the imci_ignore_unsupported_isolation_level=ON setting, does this simply downgrade unsupported isolation levels

Rs232 Checksum calculation

6 December 2025 @ 4:47 am

I am try to calculate the RS232 Crc checksum for the rs232 frame following is the sample rs232 protocol frame 01 37 37 1D 30 30 33 1D 30 03 34 37 33 39 37 04 Here 37 37 is the slave id that is 77 and 34 37 33 39 37 is the crc checksum (47397) i am unable find the method to get this crc checksum, please guide me to get the crc checksum algorithm the following is the 2nd sample 01 37 37 1D 30 30 34 1D 30 03 31 34 36 35 33 04

Review FMCG business inventory system DB design normalization and ERD

6 December 2025 @ 4:43 am

My case study project inventory system tracks stock and updates stock after every sale of a FMCG (Fast-moving consumer goods) business. Since it is FMCG, they get stock by consignment and the database should be able to track if there are payments overdue and how much needs to be paid to suppliers. ERD after being normalized. enter image description here What are problems with my FMCG business inventory system DB design normalization and ERD?

trouble in microsoft input method

6 December 2025 @ 3:58 am

I'm using the Microsoft Input Method Editor (Chinese simplified) right now and my goal is to enter a back slash in chinese mode, but instead of the backslash I get a chinese comma instead. In my case the key on my keyboard that would allow me to enter a backslash has both the chinese comma and the backslash character printed on. Assuming it works the same as other keyboards I just have to use a modifyer key like Ctrl, Alt or Shift to access it. A different approach was to switch to english mode in the OS or the keyboard. But this way I have to constantly switch back and fourth. Which should not be necessary. This handycap forces me to use a copy&paste approach where I have to store a backslash in my clipboard. I was also willing to explore the option of using some shortcuts but in the end I treat the situation as a bug. Firstly, I tried to write some script in Auto Hot Key, which doesn't work. Then I tried to use Powertoy keyboard manager, turns out t

Java - Resize JFrame When Moving to New Screen

6 December 2025 @ 2:10 am

I have two monitors with different resolutions. I would like for a JFrame to dynamically resize when dragged to a different monitor. This has proven surprisingly difficult. Here is a reproducible example. When dragging to a new frame, the label will update, but the frame will not change size. I've tried various combinations of revalidation, repainting, everything I can think of. Any help is appreciated. import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; import java.awt.Dimension; import java.awt.GraphicsDevice; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; public class ResizeTest extends JFrame { private GraphicsDevice currentScreen; public ResizeTest() { currentScreen = getGraphicsConfiguration().getDevice(); JLabel screenLabel = new JLabel(currentScreen.getIDstring()); getContentPane().add(sc

I have a problem with the request module in Automate Boring Stuff With Python - Chapter 13

6 December 2025 @ 1:50 am

I am new to python and programming in general and I got to Chapter 13 of Automate The Boring Stuff With Python which teaches Web Scraping, I succeeded in some projects but I'm having trouble getting the HTML from pypi.org, the task is to get the response from a search page in there and open the first few links, I can do it if I manually download the page as a .html file but i can't do it through the URL. Here is the code that's supposed to work: import requests, sys, webbrowser, bs4 print('Searching...') # Display text while downloading the search results page. res = requests.get('https://pypi.org/search/?q=' + ' '.join(sys.argv[1:])) res.raise_for_status() # Retrieve top search result links. soup = bs4.BeautifulSoup(res.text, 'html.parser') # Error happens here # Open a browser tab for each result. link_elems = soup.select('.package-snippet') # Returns an empty list num_open = min(5, len(link_elems)) for i in range(num_o