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 implement member functions for a C++ class that stores a positive integer as a string

11 January 2026 @ 3:09 pm

I’m working on a C++ assignment where I need to implement several member functions for a class called customPositiveInt. The class stores a positive integer as a string and tracks the number of digits. The class definition is provided, and I am not allowed to modify it. Getter functions are already implemented, so I do not need to write those. I’m unsure about the correct and idiomatic way to implement these functions—especially the operator>> and operator+. What would a clean implementation of these methods look like? Here is the provided class definition: enter image description here enter image description here enter image description here I need to implement the foll

How do you implement a virtual waiting room? [closed]

11 January 2026 @ 3:07 pm

I’m currently working on a sports event ticketing website. The app is deployed on a shared cloud server (not a VPS). For example, an event has a quota of 200 tickets, but the number of daily users can reach up to 1,000. How do you handle race conditions and prevent double entries when 1,000 users try to buy tickets at the same time while only 200 tickets are available? I have an idea to implement a virtual waiting room, where the server processes incoming requests one by one. Each IP address can only make one active request at a time. Once a request is completed, the next request in the queue will be processed. An analogy would be like a cake shop: The shop sells only 200 cakes per day The shop capacity is 50 people at a time Each customer can buy only 1 cake 1,000 people are waiting outside So, the first 50 customers enter the shop, get served, and receive their cak

Generating clangd error on `using` line without actually instantiating the type

11 January 2026 @ 2:51 pm

I would like to see a clangd error on "using MyStruct" instead of in static_assert. Right now it is not generating any errors because MyStruct is not instantiated. If it is, I get a clangd error on the static_assert. How I am really using this is for my users to define MyStruct using MyStructTemplate. I would like them to know there is an error on their code, and not in my code (MyStructTemplate), and was wondering if there is any suggestion on how I can do this best. Ideally I want to only be touching my code (MyStructTemplate), and I don't want my user to instantiate MyStruct because it will take up space. template <int... Is> struct MyStructTemplate { static_assert(!((Is == 1) || ...)); }; using MyStruct = MyStructTemplate<1, 2, 3>;

Why does std::print segfaults when using a string parameter?

11 January 2026 @ 2:43 pm

Consider the following code: #include <print> int main() { std::println("hello from {}", "me"); return 0; } On x86-64 this outputs hello from me. But on ARM64 it segfaults. ASM generation compiler returned: 0 Execution build compiler returned: 0 Program returned: 135 Program terminated with signal: SIGBUS If I make the string parameter permanent by putting it in a constexpr, the same error happens: #include <print> int main() { static constexpr auto name = "me"; std::println("hello from {}", name); return 0; } I'm using ARM64 gcc trunk with --std=c++23. The godbolt link to reproduce is here: https://godbolt.org/z/ss7xq87rG How do I pass strings as parameters to the st

Matplotlib error ValueError3171581 while plotting data

11 January 2026 @ 2:41 pm

So im trying to get data from a csv and got an error while parsing maybe, could you take a look? import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy import stats # Load data df = pd.read_csv("MyData.csv") # Remove index column if "Unnamed: 0" in df.columns: df = df.drop(columns=["Unnamed: 0"]) df.head() maybe i did an error allready here?

Why pandas module is not found even though, it is already installed?

11 January 2026 @ 2:27 pm

I want to run a dummy code on python to test the pandas library. Even though there is pandas package in the pip list of the Python virtual environment, it still shows the error that says "C:\Users\Youseng Taiheng\AppData\Local\Microsoft\WindowsApps\python3.13.exe" "c:/Users/Youseng Taiheng/OneDrive/Desktop/vscode/python/pandnew.py" Traceback (most recent call last): File "c:\Users\Youseng Taiheng\OneDrive\Desktop\vscode\python\pandnew.py", line 1, in <module> import pandas as pd ModuleNotFoundError: No module named 'pandas' my python code import pandas as pd df = pd.DataFrame([[1,2,3],[4,5,6],[7,8,9]], columns = ["A", "B","C"]) print(df) pip list of my venv (there is pandas library in there) Packag

Flutter web deployed on firebase is unable to receive any data though database streams

11 January 2026 @ 2:11 pm

I am trying to deploy a flutter web application on firebase. In this minimum working example a stream from a collection should be returned and simply displayed. When run locally, the object is correctly displayed but when run deployed on firebase hosting, the stream hangs indefinitely with only the CircularProgressIndicator being displayed. import 'package:amateur_arena/firebase_options.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/material.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); runApp(MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { final db = FirebaseFirestore.instance; return MaterialApp( the

Tell me if any same codes written 2 or 3 times

11 January 2026 @ 2:10 pm

[/Script/Engine.RendererSettings] r.AFME.Enable=5 r.Kuro.AFME.Enable=1 r.SupportStationarySkylight=1 r.Mobile.SSR=2 r.SSFS.HighQuality=1 r.SSFS.FullPrecision=1 r.SSFS.PassAmount=10 r.SSFS.Format=1 r.SSFS.LuminanceWeighting=1 [SystemSettings] r.Mobile.DeviceEvaluation=5 r.Mobile.DeviceEvaluation.EnableOverride=1 r.Mobile.DeviceEvaluation.ForceMaxQuality=1 r.Mobile.DeviceEvaluation.OverrideProfile=Android_VeryHigh r.EnableLensflareSceneSample=1 r.DepthOfFieldQuality=3 r.SceneColorFringeQuality=3 r.Tonemapper.GrainQuantization=0 r.Tonemapper.Quality=2 r.DetailMode=3 r.MaterialQualityLevel=2 r.ViewDistanceScale=2 foliage.DensityType=2 grass.CullDistanceScale=9 foliage.LODDistanceScale=9 r.LandscapeLODDistributionScale=10.0 r.LandscapeLODBias=-3 r.Mobile.SSAO=3 r.Water.WaterMesh.LODCountB

Failure to Detect <img> Tags When Bulk Downloading Copyright-Free Images

11 January 2026 @ 1:49 pm

The bulk image downloader fails to detect <img> tags on the target website, resulting in zero or incomplete image extraction, even though images are visibly loading in the browser. I am trying to download an image from manga website but the images are unable to downloaded here is the example script code which I have develop using python import requests import os def download_image(image_url, save_dir="images", filename=None): """ Downloads an image from a given URL and saves it locally. :param image_url: Direct image URL :param save_dir: Directory to save the image :param filename: Optional custom filename """ # Create directory if it doesn't exist os.makedirs(save_dir, exist_ok=True) # Set headers to avoid basic bot blocking headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" } try:

Should I return a cleanup callback in useEffectEvent for compactness?

11 January 2026 @ 12:20 pm

I'm wondering whether I can return useEffectEvent-related cleanup logic so the useEffect callback invokes them at the end of the component's lifecycle. Here's a somewhat hamfisted example (based on this part of the official documentation) just to demonstrate what I mean: import { useEffect, useContext, useEffectEvent } from 'react'; function Page({ url }) { const { items } = useContext(ShoppingCartContext); const numberOfItems = items.length; const onNavigate = useEffectEvent((visitedUrl) => { logVisit(visitedUrl, numberOfItems); return myLogCleanup; // some method which does some logging-related cleanup, just for the sake of the example }); useEffect(() => onNavigate(url), [url]); // we return a cleanup callback here } I think genera