Random snippets of all sorts of code, mixed with a selection of help and advice.
`perl -0pe` wants `.\n^`, not `.$\n^`
18 April 2026 @ 4:12 pm
I am confused.
cat << EOF > test.txt
this
is
a
text
file
EOF
cat test.txt | perl -0pe 's/.\n^text/hellohello/smg'
works, but
cat test.txt | perl -0pe 's/.$\n^text/hellohello/smg'
doesn't.
Annoyingly https://regex101.com/ doesn't detect this quirk. Is it to do with -0? And why would $\n^ syntax (which is usually perfectly fine) be wrong anyway?
How to yield a reference to internally pinned data in a custom Stream implementation? (Lifetime mismatch with GATs)?
18 April 2026 @ 4:03 pm
I am building a high-performance asynchronous zero copy parser in Rust. My goal is to read byte blocks from the underlying asynchronous reader into an internal buffer, parse them, and then generate references to the parsed data through a custom Stream implementation. To avoid unnecessary allocation, I strictly cannot clone data.
The following is the required behavior: I want my ChunkParser to act as a stream, generating&[u8] borrowed from the parser's internal buffer (or custom slice type).
However, I encountered a classic "stream iterator" lifetime issue that became complicated due to the Pin mechanism required by the Stream feature.
Here is the minimum reproducible example (MRE) of my current method:
use std::pin::Pin;
use std::task::{Context, Poll};
use futures::Stream; // Using futures = "0.3"
struct ChunkParser {
buffer: Vec<u8>,
// In reality, there is an inner AsyncRead here
}
impl ChunkParser {
f
Tkinter button does not display text after being pressed
18 April 2026 @ 4:01 pm
I defined a function and to test it I previously had a print statement, and it worked with the user input that it gets from the entries, but it only prints in the terminal, not on the screen. Here is my code now:
import tkinter as tk
import math
from tkinter import *
window = tk.Tk()
window.title('Mortgage Calculator')
# How much is the property?
property_price = tk.Label(
window, text="How much is the property? ", font=("Arial", 11))
property_price.pack(pady=10)
property_price_entry = tk.Entry(window, font=("Arial", 11))
property_price_entry.pack(pady=10)
# How much do you want to pay as a downpayment?
property_deposit = tk.Label(
window, text="How much do you want to pay as a downpayment? ", font=("Arial", 11))
property_deposit.pack(pady=10)
property_deposit_entry = tk.Entry(window, font=("Arial", 11))
property_deposit_entry.pack(pady=10)
# How many years are you paying off your mortgage?
years_of
Class template argument deduction (CTAD) failing with error: deduced class type ... in function return type on a templated class [duplicate]
18 April 2026 @ 3:47 pm
In the following c++ code (compiled with g++ 10.2.0), the declaration of myManager_not_ok produces the error: deduced class type ‘Manager’ in function return type while the other, quasi identical, declarations do not.
Is this a c++ feature or a g++ problem?
/* using: g++ --version (GCC) 10.2.0
g++ -std=c++17 deduced_class_type_in_function_return_type.cpp
*/
class Delegate
{
public: Delegate(int parameter) {}
};
template<typename T_DelegateClass> class Manager : T_DelegateClass
{
public: Manager (T_DelegateClass theDelegate) : T_DelegateClass(theDelegate) {}
};
int parameter=052;
Manager myManager_not_ok( Delegate(parameter) );
Manager myManager_ok( Delegate( 052) );
Manager myManager_ok2( Delegate( (int)parameter) );
// The declaration: myManager_not_ok, results in "error: deduced class type ‘Manager’ in function return type"
// Does this mean that myManager_not_ok(Delegate(parameter)) is in
Changing color of symbol in legend without changing confidence interval (SE) colour
18 April 2026 @ 3:46 pm
I have the following code for a graph:
ggplot(SR_data, aes(x = day, y = max_temp, colour = season2, shape = season2)) +
geom_point(size = 1.5, show.legend = TRUE) +
stat_smooth(formula = y ~ x, method = "lm", se = TRUE) +
scale_colour_manual(values = c("black", "snow4"), labels = c("Shoulder", "Dry"))+
guides(fill = c("none"), shape = "none", color = guide_legend(override.aes = list(size = 3, shape = c(21,24), fill = c("black", "snow4"))))+
scale_x_continuous(breaks = seq(0, 120, 10)) +
labs(x = "Day",y = "Maximum daily temperature (°C)") +
theme_few() +
theme(legend.position = c(0.1, 0.85), text = element_text(size = 13), axis.title.y = element_text(margin = margin(r = 10)), axis.title.x = element_text(margin = margin(t = 10)), legend.title = element_blank())
which gives this graph:
Adding Multiple Guests to Google Calendar Event via Apps Script and Google Calendar API
18 April 2026 @ 3:28 pm
I'm inserting or updating events from a Google sheet with the guests' names in one column and their email addresses in another column. For events with multiple guests, the emails and names are separated by commas, i.e.
Guest Name
Guest Email
Leia Organa, Luke Skywalker
[email protected], justluke@lars_moisture_farm.com
Frodo Baggins
[email protected]
When the script gets to a row with multiple guests, it returns the error:
GoogleJsonResponseException: API call to calendar.events.insert failed with error: Invalid attendee email.
Here is my script:
function createorUpdateEvents() {
/*
* Open the Calendar
*/
const calendarId = '[email protected]';
const sheet = SpreadsheetApp.getActive
Wait for 2 goroutines with WaitGroup or channel
18 April 2026 @ 3:19 pm
If I want to do 2 tasks and wait until both are done, is it better to run both in their own goroutines and parent waits (2 work + 1 waits), or run just one of them in background and make the parent do the work of task2 and wait for task1? It looks the same but way1 uses 1 less goroutine.
func way1() {
done := make(chan bool)
go func() {
task1()
done <- true
}()
task2()
<-done
// both done
}
func way2() {
var wg sync.WaitGroup
wg.Go(func() {
task1()
})
wg.Go(func() {
task2()
})
wg.Wait()
// both done
}
How to read out GoodWe Inverters connected to GoodWe Loggers using Modbus?
18 April 2026 @ 3:15 pm
We are trying to read out a GoodWe Solar Inverter remotely using Modbus TCP.
Our setup:
Laptop/Server with Python Script with Modbus TCP Client
--- (WireGuard) -->
4G Router (Teltonika RUT 241)
--- (LAN) -->
Logger (GoodWe EzLogger3000C)
--- (Modbus RTU / RS-485) -->
PV inverter (GoodWe SMT GW25K-MT)
Detecting if running single or multiple tests with pytest in VS Code
18 April 2026 @ 2:36 pm
It is easy to run a single test or multiple simultaneous tests with pytest in VS Code. I would like to suppress some time-consuming debugging output when running multiple tests in parallel. I know how to detect if the code is run in a test. Is there a way to detect if only a single test is running? I have found no differences in the call stack and the OS environment.
How to make Infinite scrolling ground in Godot game engine [closed]
18 April 2026 @ 11:26 am
I am trying to make Infinite scrolling ground for a 2D runner game even though my ground image is seamless when its changing its position i can see the difference. it is not working properly. Please comment if anyone knows how to make infinite scrolling ground in Godot.