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 can I tell where large copies are happening in Lean 4?

10 December 2025 @ 10:30 pm

In Lean 4, values are reference-counted and logically immutable. Operations such as Array.set logically return a new array, but the implementation instead modifies the value in place if its reference count is 1. (See the Lean Language Reference, "Arrays"; or "Functional but in-place." in section 3 of this paper.) I gather this is a key feature of the language. Users are supposed to know about it and rely on it. I have doubts about my ability to predict when a value's refcount will be 1. The performance stakes are high—the difference between a single memory write and copying an O(n) data structure. Suppose my program is slow. How can I tell where large copies are happening?

How to pass tmpfs mount options (e.g., exec/noexec) using Docker SDK for Python?

10 December 2025 @ 10:23 pm

I'm using the Docker SDK for Python: https://docker-py.readthedocs.io/en/6.0.1/api.html?highlight=mount#docker.types.Mount, and I'm trying to create a tmpfs mount with custom mount options. With the Mount class: class Mount(target, source, type='volume', read_only=False, consistency=None, propagation=None, no_copy=False, labels=None, driver_config=None, tmpfs_size=None, tmpfs_mode=None) I can set tmpfs_size and tmpfs_mode, but I don't see any way to set other tmpfs mount flags such as exec or noexec. My understanding is that Docker mounts tmpfs as noexec by default, which prevents running executables from that directory. Question: Is it really not possible to pass additional tmpfs options (l

what's wrong whith my script? youtube_transcript_api

10 December 2025 @ 10:22 pm

what's wrong whith my script? I installed the following on my Windows 10 system in Powershell... a virtual Python environment (venv) then upgraded Python then installed youtube-transcript-api created a urls.txt file with the YT URLs created the script “download_transcripts.py” Run in venv. It seems nothing is being loaded. # download_transcripts.py from youtube_transcript_api import YouTubeTranscriptApi from youtube_transcript_api.transcript import TranscriptList import re import os # --- Konfiguration --- URLS_FILE = "urls.txt" OUTPUT_DIR = "transcripts" # --------------------- def extract_video_id(url): """Extrahiert Video-ID aus YouTube-URL""" # Muster für verschiedene URL-Formate (watch?v=, youtu.be/, embed/, etc.) pattern = r"(?:v=|\/)([0-9A-Za-z_-]{11}).*" match =

Google maps, AdvancedMarkerElement not working

10 December 2025 @ 10:05 pm

Pretty simple code. I have a new google cloud key. I load the JavaScript asynchronously and wait for it, but when I try to create a single marker, I get "This page can't load Google Maps Correctly. HTML <html> <head> <title>Add junk Map</title> <link rel="stylesheet" href="app.css" type="text/css" /> </head> <body> <!--The div element for the map --> <div id="map_canvas"></div> <script> (g => { var h, a, k, p = "The Google Maps JavaScript API", c = "google", l = "importLibrary", q = "__ib__", m = document, b = window; b = b[c] || (b[c] = {}); var d = b.maps || (b.maps = {}), r = new Set, e = new URLSearchParams, u = () => h || (h = new Promise(async (f, n) => { await (a = m.createElement("script")); e.set("libraries", [...r] + ""); for (k in g

Exercise in parallel programming using BackgroundWorker [closed]

10 December 2025 @ 10:02 pm

The task is to numerically determine the integral value for the given functions: y=2x2+7x y=2x2 y=2x-3 The user should select the appropriate function after starting the application, and the calculations should be performed for three x ranges: 1: from 0 to 10, 2: from 3 to 12, 3: from 5 to 14 Calculations should be made using trapezoids as approximating elements. Calculations for each range should be performed simultaneously but in separate threads using the BackgroundWorker class. The application should inform the user about the progress of calculations in 10% steps and should allow interruption of the operation (stopping calculations). Finally, the application should display a final information on the screen for each interval separately. Use the interface implementation ;and the DoWork method can be passed using the RunWorkerAsync method of the BackgroundWorker class that takes a parameter. Therefore, i need help breaking this down for a beginner in parallel programming and coding

React useEffect with div reference dependency updated on first setState in component

10 December 2025 @ 10:01 pm

Here is minimal component code. I can't figure out why Container ref effect is being called twice. First when div is actually created, second time when increment button is pressed for the first time. Subsequent increments do not update div. Also, second time effect is called, div is the same. React: 19.2.0 let stored: HTMLDivElement | null = null; function RefUpdated() { const containerRef = useRef<HTMLDivElement | null>(null); const [counter, setCounter] = useState(0); useEffect(() => { console.log("App mounted"); return () => { console.log("App unmounted"); } }, []); useEffect(() => { console.log("Container ref", stored === containerRef.current, containerRef.current); stored = containerRef.current; }, [containerRef.current]); return ( <div id="container" ref={containerRef}> <p>Counter: {counter}</p> <p> &l

Passing a temporary into a coroutine by const reference

10 December 2025 @ 9:04 pm

Assume that we have a potentially dangerous code that passes a const reference to a coroutine: #include <boost/asio.hpp> #include <iostream> namespace asio = boost::asio; using asio::awaitable; using asio::use_awaitable; class Param { public: Param(int val) : m_val(val) { std::cout << "Param constructor " << m_val << std::endl; } void func() const { std::cout << "Param func " << m_val << std::endl; } ~Param() { std::cout << "Param destructor" << m_val << std::endl; } int m_val; }; awaitable<void> func(const Param& param) { param.func(); co_return; } awaitable<void> caller_func() { co_await func(15); } int ma

How to find corrupted date entry when date column type is (object) [closed]

10 December 2025 @ 4:32 pm

I am trying to convert a column of time stamps that are currently of type object to proper datetime. When using pd.to_datetime() on the column I got this error OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 2821-11-10, at position 1818 I just want to find that value and correct it ie. should be 2021-11-10. But I can't find a way to search for that entry. The column is too large to physically look at every entry. Any tips?

How to generate a link inside a footnote with Apache POI?

10 December 2025 @ 3:22 pm

I am able to create footnotes, and I'm able to make links, but when I try to make a link inside a footnote Word refuses to open the resulting document. Here's a minimal example that reproduces the problem: import java.io.File; import java.io.FileOutputStream; import org.apache.poi.xwpf.usermodel.XWPFAbstractFootnoteEndnote; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFHyperlinkRun; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFRelation; import org.apache.poi.xwpf.usermodel.XWPFRun; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHyperlink; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR; public class Test { public static void main(String[] argv) throws Exception { XWPFDocument document = new XWPFDocument(); XWPFParagraph para = document.createParagraph(); XWPFRun tmpRun = para.createRun(); tmpRun.setText("LALA

React native timer not resetting once the timer has completed counting down

10 December 2025 @ 1:01 pm

I'm building a React Native App to run a pomodoro style focus timer based on a training course. All the other behaviours that are expected when the timer has completed are running, but the timer continues to show "00:00" and when you press start, the timer immediately completes. The default timing set to 6 seconds which is what I want the timer to revert to. The following is my App.js code (Note: The example code given also has a blank in th "onTimerEnd" prop import React, { useState } from 'react'; import { StyleSheet, Text, View, Platform } from 'react-native'; import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; import { Focus } from './src/features/Focus.js'; import { Timer } from './src/features/Timer.js'; import { colors } from './src/utils/colors'; export default function App() { const [currentSubject, setCurrentSubject] = useState('test'); return (