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.

C++ Loop skips condition of getline [duplicate]

21 April 2026 @ 7:20 pm

#include <iostream> #include <vector> #include <string> using namespace std; void print_student_table(vector<string> names, vector<int> scores); int main() { vector<string> names; vector<int> scores; string n; int s; cout << "Enter student score, followed by name, one per line. Ctrl-D when done. \n"; //gets input for each user while(true){ cin >> s; if(getline(cin, n)) { names.push_back(n); scores.push_back(s); } else { break; } } print_student_table(names, scores); } //prints items in each vector void print_student_table(vector<string> names, vector<int> scores) { for (int i = 0; i < scores.size(); ++i) { cout << scores[i] << " " << names[i] << endl; } } I have troublesho

Building monorepo with multiple node.js projects with pnpm

21 April 2026 @ 7:14 pm

I am looking for best practices or good example (e.g. popular repository on GitHub) of building project with pnpn (and specifically pnpm-workspace.yaml full content) for project with multiple subprojects package.json in monorepo, like the one below my-monorepo/ ├── pnpm-workspace.yaml # Defines subproject locations ├── apps/ # Directory for applications │ └── web-app/ │ └── package.json │ └── Dockerfile │ └── web-app2/ │ └── package.json │ └── Dockerfile │ └── web-app3/ │ └── package.json │ └── Dockerfile └── packages/ # Directory for shared libraries └── ui-components/ └── package.json

Prevent soft keyboard briefly dropping when focus lost because a button was pressed

21 April 2026 @ 7:08 pm

I have implemented a search facility on text in an html textarea. When a button is pressed, the search text is found in the text, the textarea is scrolled to bring the found text into view, the textarea is focussed, and the found text is selected using setSelectionRange. Each subsequent press of the button shows the next occurrence of the searched for text. In Firefox, and the Firefox derivative Waterfox, the soft keyboard pops up on the first click and remains solidly in place for all subsequent clicks. In Chrome, and the derived DuckDuckGo browser, the soft keyboard drops briefly on each subsequent click before coming back up. I have tried using an event-listener as suggested here, but the keyboard still briefly drops. Clearly Mozilla have spotted this problem and implemented a fi

How to filter llvm tests by name

21 April 2026 @ 6:55 pm

I want to run only a few tests from the check-llvm-codegen-aarch64 target which has over 3000 tests. During development, only a handful of them are failing so I just want to quickly iterate on them rather than waiting on all 3000 to finish. Test harness like gtest has --gtest_filter but I can't find anything with ninja builds in llvm lit tests.

Loaded 3D models have inconsistent sizes — how can I normalize their scale? [closed]

21 April 2026 @ 6:43 pm

I’m working on a Unity app where users can load their own 3D models at runtime (currently testing with prefabs/AssetBundles). The issue I’m running into is that every model comes in at a completely different size. Some are tiny, others are huge, even though I’m applying the same transform scale. Here’s basically what I’m doing: GameObject model = Instantiate(loadedPrefab); model.transform.position = Vector3.zero; model.transform.localScale = Vector3.one; That works fine technically, but visually the sizes are all over the place. I’m guessing this is because the models were created in different tools (like Blender) with different units or export settings. What I want is simple: no matter what model the user loads, it should appear at a consistent size in the scene (for example, all models should roughly fit into the same “space”). I tried manually tweaking the scale, but obviously that’s not practical since every model is different. S

AKS deployment consistently fail due to readiness probe status code 500

21 April 2026 @ 5:48 pm

While we are doing the recent deployment testing on one of our .NET code implementation over a web application, we found that the readiness probe consistently starts to fail with code 500. Here is the definition of our readiness probe. readinessProbe: httpGet: path: /page/ping.aspx port: 443 scheme: HTTPS initialDelaySeconds: 15 timeoutSeconds: 2 periodSeconds: 5 successThreshold: 1 failureThreshold: 12 No matter what graceful value we assign to the probe, it will fail on our deployments with latest implementation on the readiness probe. The Ping.aspx.cs body is below: /// <summary> /// Page load event handler. /// </summary> /// <param name="sender">The event sender object.</param> /// <param name="e">The event arguments.</param> protected void Page_Load(object sender,

Given this single-sided amplitude spectrum

21 April 2026 @ 4:41 pm

Given this single-sided amplitude spectrum, can we conclude the signal is non-periodic despite having discrete peaks? This two opinions First see its periodic as it contains five peaks that refer to composite periodic signal Second see that that question ask only for the whole signal not separate components so the continuous spectrum in frequency domain refers to non periodic signal enter image description here

Python Get Request URL returning errors compared to hard-coded URL [closed]

21 April 2026 @ 2:01 pm

I'm trying to pass parameters into a REST Get URL to pull data from NOAA's NCEI API and while hard-written URLs work, the URLs I am creating with parameters are not, even though when I print them both they are identical. I paraphrased the errors because there were so many but I took out what I think are the key parts. A few errors come up: AttributeError, InvalidURL, and MissingSchema. EDIT: I boiled this down to the code here, instead of an issue loading the data into a dataframe because the error I was getting when trying to load the request_ROC data into a dataframe was "Invalid file path or buffer object type: <class 'requests.models.Response'>", so I needed to test getting any response from creating the URL with parameters which doesn't seem to be working. Code: url_test = 'https://www.ncei.noaa.gov/access/servi

Can NASM behave like a 8086 assembler? It accepts 32-bit addressing modes even with CPU 8086

21 April 2026 @ 1:37 pm

How do I make NASM behave like a 1980 assembler that know only about 8086 and nothing about later processors, and reject or at least warn about anything that requires a later CPU? I tried giving the following directives at the very beginning of my input file bits 16 ; already the default for flat-binary output cpu 8086 but still (with these two directives) NASM does not complain upon encountering the following instruction which uses 386 features: (ESI being a 32-bit register, and 32-bit address-size in general): add ax,[esi] ; 32-bit address-size instruction accepted by NASM 3.01 Then (still with two directives as above) NASM does complain about for example add eax, ecx ; 32-bit operand-size instruction rejected by NASM 3.01 What am I missing? Background: I am very new to assembly and wanting to learn about x86 assembly, starting by reading a book fr

Get Start date of a current partnership

21 April 2026 @ 11:59 am

I need to get the start dates of a partnership in different disciplines where the partnership previously existed but the individuals participated with other partners then resumed their partnership. I need to get the start dates of the current partnership ignoring the previous ones. I've included queries to create a sample table & insert relevant data. I'm trying to avoid creating datatables & looping so would like to get the results using a query if that's possible. This is on MS sql server express. CREATE TABLE tblPartnerships ( Couple_Idx int IDENTITY(1,1) PRIMARY KEY, MaleID int, FemaleID int, Ball_Start date, Lat_Start date, Smth_Start date, Rhm_Start date ) INSERT INTO tblPartnerships (MaleID, FemaleID, Ball_Start, Lat_Start, Smth_Start, Rhm_Start) VALUES (1,4,('2026-02-19'),('2026-02-19'),Null,Null), (1,4,('2025-02-18'),('2025-02-18'),Null,Null), (1,4,('2024-01-18'),('2024-01-18'),Nul