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.

ThinkPad T470s Hard Shutdown Instead of Switching Batteries (Ubuntu 24.04 & Windows 10)

1 May 2026 @ 11:12 pm

I am experiencing a persistent power issue with my Lenovo ThinkPad T470s. The laptop performs a "hard shutdown" (sudden power off) when one battery dies, instead of switching to the second battery. This happens on both Ubuntu 24.04 and Windows 10. System Specs: Model: ThinkPad T470s BIOS Version: N1WET76W (1.55) Power: 65W Original Adapter & USB-C PD Charger Dual Boot: Ubuntu 24.04 / Windows 10 Technical Data (Power Statistics): Both batteries show significant wear, which might be contributing to the voltage drop during handover: Battery 0 (Internal): Energy (design): 23.5 Wh Energy when full: 10.8 Wh (~46% Health) Status when issue occurs: "Waiting to charg

Disabling skybox or black background

1 May 2026 @ 10:28 pm

I'm new in programming with android. I'm making a game based in compose but for a 3d dice I'm experimenting with sceneview (helped with IA) but I don't know what to make, I tried all but when I launch the dice (code down bellow) it appears with a black background, I just want it to be transparent so I can see my compose layers bellow. I tried changing the background in the SceneView to blue, and it appears in blue for a moment before going again to black. Maybe is pretty obvious what is wrong here but I can't figure it out. Any help would be appreciated, Thanks! fun Dice3DScene(result: Int, isRolling: Boolean, modifier: Modifier = Modifier) { val engine = rememberEngine() val modelLoader = rememberModelLoader(engine) val environmentLoader = rememberEnvironmentLoader(engine) var modelNode by remember { mutableStateOf<ModelNodeImpl?>(null) } var prevFrameTime by remember { mutableStateOf<Long?>(null) } va

NestJS + TypeORM multiple database connections error: "Cannot find connection default"

1 May 2026 @ 10:18 pm

I’m trying to build a single NestJS application that serves as a REST API for multiple small projects, each using its own MySQL database. Each project is organized in its own module with separate entities, services, and controllers. I want to keep the databases isolated (different credentials and schemas), so I configured multiple connections in ormconfig.json like this: [ { "name": "project1", "type": "mysql", "host": "localhost", "port": 3306, "username": "...", "password": "...", "database": "...", "entities": ["project1/*.entity.ts"] }, { "name": "project2", "type": "mysql", "host": "localhost", "port": 3306, "username": "...", "password&quo

Crash in Napi::Function::New(env, FunctionName) call

1 May 2026 @ 10:18 pm

I am working on an Electron project with node-api (for C++ addons). The app crashes, even after a full-build. The problem that I am facing occurs within the C++ template addon that I have made. I have added extensive logging in order to figure out where the error occurs, and narrowed it down to the helloFunc = Napi::Function::New(env, HelloWorld); call within [addon.cpp] (because the "Creating helloFunc..." log appears in the terminal, but the "Created helloFunc." log doesn't). However, the try/catch blocks that I added around this line aren't logging anything, so I assume some memory access error is occuring at the OS-level, and the Napi::Object Init function is abruptly ending at the relevant line, so all later lines containing the std::cout logs aren't running. In regards to this, my question is: Why is the line `Napi::Function::New(env, HelloWorld)` even causing a memory access error? Any a

Unreal Engine 5 prerendered backgrounds

1 May 2026 @ 10:17 pm

I'm trying to set up pre-rendered backgrounds in Unreal Engine with a material applied to a plane where I set a scalar parameter to the pixel depth offset. Everything works and there is depth, but the character's shadows are not visible, and when I go behind objects the character is still visible. How can I configure it better? The proxy mesh is placed in front of the plane in hidden in game mode because it would otherwise cover the material. Let me know, thanks. enter image description here

Tkinter Label Class not placing label on window

1 May 2026 @ 8:59 pm

I am trying to create a class to put tkinter headings onto a window however for some reason it will not place them. I have tried to move the .place around and out of the class and it doesn't seem to work. I would prefer using place as it is the method I am most comfortable with I'd really appreciate any help The class and window are in different files and the class is imported Below is the class class make_label: def __init__(self, place, text, font_size, x_value, y_value): #self.name = name self.place = place self.text = text self.font_size = font_size self.x_value = x_value self.y_value = y_value def make_label(self): new_label = Label(self.place, text = self.text, font=("Century Schoolbook", self.font_size)) new_label.place( x = self.x_value, y = self.y_value) Below is the code

bash kernel dies in jupyter notebook

1 May 2026 @ 8:45 pm

I am trying to use a bash kernel in jupyter notebooks and am receiving the following error: Connection failed A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration. I have tried the following workflow. From python command prompt: conda create --name bash_env --clone arcgispro-py3 conda install -c conda-forge bash_kernel python -m bash_kernel.install However, no matter what I try, I get a not connected error. I'm on Windows 11. jupyter kernelspec list returns: .net-csharp C:\Users\myusername\AppData\Roaming\jupyter\kernels\.net-csharp .net-fsharp C:\Users\myusername\AppData\Roaming\jupyter\kernels\.net-fsharp .net-powershell C:\Users\myusername\AppData\R

What is best, React or Flutter?

1 May 2026 @ 6:35 pm

What is best, keeping an app written in React or change the app to Flutter?

Is CPU allowed to perform a speculative execution on nullptr branch conditions?

30 April 2026 @ 10:35 am

CPU often performs speculative execution on code branches like if ( a > b) And discards the result in case of misprediction. However let's consider the following: int* ptr = nullptr; //do some work if (ptr != nullptr) { std::cout << *ptr << std::endl; } else { // do something else } Can CPU speculate on such condition? How does it happen? In this case misprediction would result in dereferencing nullptr and UB. Logically that would exclude possibility of discarding wrong result since the program has crashed. If speculative execution of such branch is allowed, is it always assumes that there is nullptr (to avoid UB) and jumps to else branch? Or it can speculate for both conditions (== nullptr and != nullptr) depending on euristics? If it can speculate on dereferencing nullptr, what are the mechanics allowing CPU to avoid UB?

Fastest way to read from disk to buffer in 2026 (linux/unix)

29 April 2026 @ 11:58 am

I'm looking for best practices to read from disk to memory with the lowest latency. I looked into memory mapped io, io_uring, DMA, tokio::fs::read etc. but I have difficulties piecing the puzzle together. I have different questions: What is the fastest way to read from different hardware as spinning disk, SSD and NVME How can i make my read operation trigger DMA if available? Do reads by tokio::fs::read automatically do that? When would i use memory mapped io vs traditional reading methods? Can i speed up my read with parallel threads and fseek (reading multiple chunks at a time)? What optimisations does the kernel make that I don't need to replicate? For example, how does caching play into reading and writing? Interesting reads so far: DiskIO overall: