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.

Using a C++ const reference from a return value

26 February 2026 @ 12:08 pm

I have trouble understanding the c++ documentation. Will this cause a dangling pointer or is it safe to do? I don't trust ai-geneerated information. #include <iostream> #include <vector> #include <string> std::vector<std::string> getFruits() { std::vector<std::string> fruits = {"apple", "banana", "cherry"}; return fruits; } int main() { const std::vector<std::string>& result = getFruits(); std::cout << result[0]<< "\n"; return 0; }

ASP.NET Web API Publish Fails with Build failed. Check the Output window for more details

26 February 2026 @ 12:07 pm

I am trying to publish my ASP.NET Web API project, but the publish process fails with the following error: 2/26/2026 12:33:17 PM System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details. --- End of inner exception stack trace --- ---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details.<--- The publish operation stops immediately and does not provide detailed information in the publish window. The only message displayed is: Microsoft.WebTools.Shared.Exceptions.WebToolsException: Build failed. Check the Output window for more details. I have checked: The Error List window The Output window Cleaned and rebuilt the solution Restarted Visual Studio Create a new web However, I

Visual Studio 2017/2019: OutOfMemoryException error during Rebuild

26 February 2026 @ 12:06 pm

My projects on Visual Studio Community 2017 and 2019 suddenly having OutOfMemoryException error during Rebuild. I have already tried these but issue wasn't resolved. 1. Uninstalling and reinstalling these IDEs and all Visual Studio SDKs but the didn't resolve the issue. 2. Deleted the folders .vs, bin, obj from the project folders before solution Rebuild. 3. Deleted .IdentityService folder from the Windows AppData folder before solution Rebuild. My machine's memory has 16GB. Before, even at 80 - 90% usage, I didn't have the error.** VS Community 2019** 1>------ Rebuild All started: Project: [PROJECT NAME], Configuration: Debug Any CPU ------ 1>C:\[PROJECT DIRECTORY]\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.CSharp.Core.targets(67,5): error : 1>C:\[PROJECT DIRECTORY]\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.CSharp.Core.targets(67,5): error : Unhandled

Terraform how to disable sharedAccessKey only for one storage account

26 February 2026 @ 12:00 pm

I have a bunch of storage accounts but I want to disable shared access key only for one and keep the rest as is at least for now. I have set this line to my storage account module: shared_access_key_enabled = var.sharedAccessKeyEnabled and set it to true as default. but I am still greeted with the error "unexpected status 403 (403 Key based authentication is not permitted on this storage account.)" Is there a way to set aad auth to only one storage account? All the examples I have found set the aad auth to whole provider.

PostgreSQL trigger causing infinite recursion when updating same table - how to prevent trigger from firing recursively?

26 February 2026 @ 11:58 am

I'm implementing an audit trail system using PostgreSQL 14 triggers, but I'm encountering infinite recursion when my trigger updates the same table it's monitoring. My table structure: CREATE TABLE products ( product_id SERIAL PRIMARY KEY, product_name VARCHAR(100), price NUMERIC(10,2), last_modified TIMESTAMP, modified_by VARCHAR(50), version INTEGER DEFAULT 1 ); My trigger function: CREATE OR REPLACE FUNCTION update_product_metadata() RETURNS TRIGGER AS $$ BEGIN NEW.last_modified := NOW(); NEW.version := OLD.version + 1; INSERT INTO product_audit (product_id, old_price, new_price, changed_at) VALUES (NEW.product_id, OLD.price, NEW.price, NOW()); UPDATE product_summary SET total_value = total_value - OLD.price + NEW.price, last_update = NOW() WHERE category_id = NEW.category_id; RETURN NEW; END; $$ LANGUAGE plpgsql;

Android Studio, implicit intent can not invoke a specific activity

26 February 2026 @ 11:57 am

I want to invoke the ThirdActivity of my app ActivityTest by button of FirstActivity in the same app, with implicit intent with uri object, like the link https://www.google.com, but I can only open it with the built-in browser. my code of ThirdActivity in AndroidManifest.xml is like this: <activity android:name=".ThirdActivity" android:exported="true" > <intent-filter tools:ignore="AppLinkUrlError"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="https" /> </intent-filter> </activity> and my code in the same app of FirstActivity is like this: val intent = Intent(Int

Sets in python and transformation a list into a set

26 February 2026 @ 11:54 am

import random as rd rd.seed(0) list_1= [] list_2= [] for i in range(12): list_1.append(rd.randrange(0, 60)) list_1 for j in range(25): list_2.append(rd.randrange(0,60)) list_2 repeaterive_numbers= [] for i in list_2: if i in list_1: repeaterive_numbers.append(i) set(repeaterive_numbers) when I run this code in jupyter, returns an error: # 'set' object is not callable... can anybody help me?

Bricks Builder + ACF

26 February 2026 @ 11:50 am

I have a custom post type for a business partner page I then created a bricks template page for that post type. So its all dynamic. At the moment, you attach a WordPress user with a consultant role to the business partner post type via an acf relationship field. this works but its not user friendly going to each individual user and connecting them to the business partner page, rather than just connecting all the users to the business page in one place I also need to be able to order these consultants manually, not via the bricks built in order methods. I am testing the user field from acf and it returns the user object/array/id. I'm not sure which is best for what i need. But I'm struggling to display the info that's attached to those users. keep in mind these users also have custom acf fields like a qr code image I'm trying whatever i can to display it. i have the user field in a repeater and query looping through it. then tried to query on users

How to automate documentation screenshots so they stay up to date?

26 February 2026 @ 11:45 am

I maintain documentation for a web app and need to keep ~30 screenshots current. Every UI change means manually opening the page, resizing to the correct viewport, finding the element, taking a screenshot, cropping, and replacing the old file. I've tried scripting this with Playwright: const { chromium } = require('playwright'); (async () => { const browser = await chromium.launch(); const page = await browser.newPage(); await page.setViewportSize({ width: 1280, height: 720 }); await page.goto('https://myapp.com/dashboard'); await page.locator('.stats-panel').screenshot({ path: 'docs/images/dashboard.png' }); // ... repeat for 30+ screenshots with different URLs, selectors, viewports await browser.close(); })(); It works but doesn't scale. Each screenshot needs different URLs, viewports, selectors, and some need pre-actions (clicking tabs, dismissing popups, waiting for data). I'm maintaini

how to remove white space from pdf and bill printing in Electron js

26 February 2026 @ 11:43 am

i am trying to make thermal bill print also same time i am trying to save as pdf but as you can see there is white space in pdf how to solve this const result = await window.electronAPI.print({ content: htmlContent, settings: { silent: false, // Show dialog for user confirmation printBackground: true, deviceName: defaultPrinterName || undefined, // Use user's choice or let main process auto-detect margins: { marginType: 'none' }, pageSize: { width: 80000 }, fileName: pdfFileName, landscape: false, color: true, forcePDF: billData.forcePDF || false } }) enter image description here