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.

Imports e package em vermelho sem motivo

26 March 2026 @ 9:19 pm

Estou fazendo um projeto web com Spring Boot (API REST) e tudo estava normal; depois que mudei a senha do meu banco de dados e atualizei o arquivo application.properties (para usar a nova senha), todos os imports e packages do meu projeto estão vermelhos, como se estivessem com erro, mas na realidade o banco continua funcionando e fazendo o crud normalmente, a aplicação também continua rodando sem nenhuma mensagem de erro, mas a estética visual com os nomes vermelhos me dá aflição kkkkkk. Alguém já teve esse problema? É um bug? Como resolver? Help

Databricks Truncates Rows Greater Than 64k in SQL

26 March 2026 @ 9:12 pm

SQL query should give a result of 100,000 rows but the output is truncated and only displays 64,000 rows. How do I correct this to show 100,000 rows.

What is the correct way to initialize a Data property in a model object in SwiftData / CloudKit?

26 March 2026 @ 8:55 pm

I have a model class in my app which uses SwiftData / CloudKit: @Model final class Project { var name: String = "" var avatarData: Data? var hasAvatar: Bool = false ... As you can see there is an optional avatarData property for the user to store an image in Project. I've included a hasAvatar bool so that I can tell the difference between the user having not set an avatar vs CloudKit not loading the avatarData. This way works but obviously it's annoying having to manage two variables. I've thought about doing it this way: @Model final class Project { var name: String = "" var avatarData: Data = Data() ... Which is obviously simpler, if avatarData is nil then CloudKit hasn't loaded it, if it's empty then the user never set an avatar. But I'm just confused. I know in SwiftData / CloudKit, you have to

Autofill multiple entries for Combobox

26 March 2026 @ 8:51 pm

I have a user form that uses a combo box to record the employee associated with a given task. I have a section of code that extracts employee entries from other tasks, and adds them to the combobox items, which means for the box will autofill for the employee name. Occasionally, we have multiple people work on the same task, and I am wondering if there is a way to make the combobox autofill another instance after a list separator. For example, if the employees are John Doe and Joe Public, I would enter them into the combobox as "J. Doe, J. Public". The box will autofill J. Doe, but I would have to manually type out J. Public. Is there a way to fix that so it will autofill both?

Code composition in service layer influences trait satisfaction in Axum handlers

26 March 2026 @ 8:48 pm

I'm developing pretty simple CRUD REST API in Rust using Axum framework. It has layers of handlers and services - handlers calls services using Arc. I've encountered following compilation error during development of generate_unique_slug function. Error is: error[E0277]: the trait bound `fn(State<Arc<AppState>>, ..., ..., ...) -> ... {create}: Handler<_, _>` is not satisfied --> src/mgmt/server.rs:48:18 | 48 | post(branch::create).get(branch::list), | ---- ^^^^^^^^^^^^^^ the trait `axum::handler::Handler<_, _>` is not implemented for fn item `fn(State<Arc<AppState>>, UserId, Path<...>, ...) -> ... {create}` | | | required by a bound introduced by this call | = note: Consider using `#[axum::debug_handler]` to improve the error message = help: the following other types implement trait `axum::handler::Ha

ImportError despite successful installation in Python 3.9 venv

26 March 2026 @ 8:26 pm

I'm working in a Python 3.9 virtual environment on Ubuntu 20.04, and I'm getting an ImportError even though the package installed fine with pip. What I've done: Set up a clean venv: python -m venv venv source venv/bin/activate Installed the package: pip install asyncpg Confirmed the install: pip list Verified the Python path: which python # /path/to/venv/bin/python which pip # /path/to/venv/bin/pip Package is present in site-packages. Error: ImportError: cannot import name 'asyncpg' from 'asyncpg' Code: import asyncpg async

Passing the size of a VLA as a pointer reference

26 March 2026 @ 8:15 pm

Can you pass the size of an variable length array, VLA, as an element in a large struct and use it as size for the VLA? void foo(largeStructType* largeStructPtr, int arr[largeStructPtr->size]) However one AI agents complains that in C99 the size of VLA can only be a constant or a functions parameter directly, not to be deference. I mistrust that comment. This works and gcc compiles it with -std=c99. Try to understand and read the C-standard but I can't come to any conclusion if its valid or not. Can this community bring some light if this is okay according to the standard?

SQL Server ON VPS With Multi-Tenant, Multi Db Architecture

26 March 2026 @ 7:27 pm

Need help on a scalable cheap solution - I'm building an Access Db to run with a SQL Server back-end hosted on a VPS. I am trying to decide on the architecture to use. When I say multi-tenant I mean I have a single-instance of SQL Server; hosted on a Virtual Private Server (VPS). A Tenant will consist of several different customers accessing the same db. I think Azure will be too expensive & only god knows what the actual fee will be in the end once using. I imagine to have considerable transfer & most customers will be on a Dynamic IP address so their firewall is not going to be of use. Also if it did take-off I think I'm limited to circa 300 concurrent sessions with Azure. I've not finished designing but each user will be returning tens of thousands of records hourly with quite a few calculated columns in views... Have researched for 3 weeks & I need to make a decision: I use an API with oAuth 2.0 Authentication to authenticate the user. They are then a

Classification template

26 March 2026 @ 7:06 pm

What do you think a bout this classification template --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- import pandas as pd from sklearn.model_selection import train_test_split from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline from sklearn.impute import SimpleImputer from sklearn.preprocessing import OneHotEncoder, StandardScaler from sklearn.metrics import accuracy_score from sklearn.linear_model import LogisticRegression from sklearn.ensemble import RandomForestClassifier from sklearn.neighbors import KNeighborsClassifier from sklearn.tree import DecisionTreeClassifier # Load data train = pd.read_csv("train.csv") test = pd.read_csv("tes

Improve the performance of code that builds an object by comparing two objects

26 March 2026 @ 6:36 pm

I need a faster way to build one object from another in PowerShell. I have a PowerShell array of Strings with 10,000 hostnames: $hostnames = @("server1","server2","server3"..."server10000") And a PowerShell array of custom objects with NoteProperty "hostname" and "IP". Both Note Properties are Strings. The array has 50,000 elements. $inventory[0].name="server1" $inventory[0].ip="10.0.0.1" $inventory[1].name="server2" $inventory[1].ip="10.0.0.2" I need to build a new object of the elements in $inventory but only for the matching elements in $hostnames. I wrote this code: $newList = @() foreach($name in $hostnames){ $newList += $inventory | Where-Object {$_.name -eq $name} } This code works...eventually. With 10k elements in $hostnames, it has to cycle through the 50k elements