Random snippets of all sorts of code, mixed with a selection of help and advice.
System.Net.WebException: The remote server returned an error: (426) Connection closed
21 December 2025 @ 4:20 am
Can anyone help please?
Trying to write a c# desktop app which will access an FTP server and pull down a file(s).
For developemnt I have one remote FTP server and one on my LAN.
I can access both using Filezilla (client) just fine.
The C# produces a 426 error when connecting to both servers. I have written the app using both System.Net and FluentFTP interfaces. Identical results.
Windows 10 firewall is turned off, but if it were blocking surely it would block my code and Filezilla (client).
What else is there that I could be over looking please?
Full error is:
System.Net.WebException: The remote server returned an error: (426) Connection closed; transfer aborted.
atSystem.Net.FtpWebRequest.SyncRequestCallback(Object obj)
atSystem.Net.FtpWebRequest.RequestCallback(Object obj)
atSystem.Net.CommandStream.Dispose(Boolean disposing)
atSystem.IO.Stream.
What to do for context with multiple families of strategy pattern
21 December 2025 @ 3:52 am
most examples show a single context with a single family of strategy, but what is the correct design for a context with multiple separate families of strategy e.g.
setValidationStrategy(IValidationStrategy vs);
setExportStrategy(IExportStrategy es);
setSyncStrategy(ISyncStrategy st);
}```
I am not finding an example as above. It even appears a little abstract factory-ey, but I am looking to use a strategy pattern.
How to use types correctly and avoid errors in PDDL
21 December 2025 @ 3:41 am
In my PDDL domain, as soon as I add "type" to each of variables, there is an error as follows, but it has no error if I remove these elements. Anyone knows the reason? Thanks!
......
->Parsing 1. group of typed list
Expected item to be a variable
Got: -element
translate exit code: 31
.........
type define in the domain file:
(:types
element -ele
door - dor
location - loc
room - rm
)
Finding Folder to use in Macro
21 December 2025 @ 3:16 am
Very new to VBA and Macros. I have only been learning for a few days so far.
I am trying to make a code that will allow a user to select a folder that is used in the same macro so anyone who places the workbook needed can simply select the folder where it is at to run the remainder of the script.
Below is what I have but I know the Function is not working with the Sub following it.
THe Sub routine at bottom is working, the issue is wanting to be able to select the folder rather than hard code shown in the Set src below. My issue is how to tie the two together.
Function ChooseFolder() As String
Dim fldr As FileDialog
Dim sItem As String
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
With fldr
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = strPath
If .Show <> -1 Then GoTo NextCode
sItem = .SelectedItems(1)
End With
NextCode:
Cho
How does multiple enumeration of an IEnumerable in LINQ affect performance with deferred execution in C#?
21 December 2025 @ 2:59 am
LINQ uses deferred execution, which means an IEnumerable can be re-evaluated each time it is iterated.
In a real-world C# application, how does multiple enumeration of the same LINQ query affect performance, especially when the source involves database calls or other expensive operations?
What are practical ways to detect multiple enumeration issues, and which patterns are recommended, such as ToList() or caching results, to prevent them without introducing unnecessary memory usage?
Broadcasting DataFrames across NumPy array dimensions
21 December 2025 @ 1:45 am
I'm working with a large Pandas DataFrame and a multi-dimensional NumPy array. My goal is to efficiently "broadcast" a specific column of the DataFrame across one or more dimensions of the NumPy array, performing an element-wise operation.
Let's say I have a DataFrame df like this:
import pandas as pd
import numpy as np
data = {'id': range(100), 'value': np.random.rand(100)}
df = pd.DataFrame(data)
And a NumPy array arr with shape (10, 5, 100, 20):
arr = np.random.rand(10, 5, 100, 20)
I want to multiply df['value'] by arr such that df['value'][i] is multiplied by arr[:, :, i, :] for all i. In essence, df['value'] should align with the 3rd dimension of arr.
A solution might involve iterating or using np.apply_along_axis
cout vs. fprintf vs. fputs
21 December 2025 @ 12:05 am
I design my utility function not to throw an exception, as I don't want to deal with exception and to be able to use this function in a while loop. I also try to follow all the best practices I've learnt.
namespace auxiliary {
static bool str_to_double(const std::string &line, double &res) noexcept {
char *end = nullptr;
errno = 0;
double value = strtod(line.c_str(), &end);
if (line.empty()) {
std::fputs("line is empty!\n", stderr);
} else if (end == line.c_str()) {
std::fputs("No characters consumed. Couldn't parse event the first character!\n", stderr);
} else if (*end != '\0') {
std::fputs("trailing nonnumerical character(s) detected\n", stderr);
} else if (errno == ERANGE) {
std::fputs("Overflow or underflow for double\n", stderr);
} else {
// everything's alright
res = value
Segmentation faults on MPI_Info_create and MPI_Finalize
20 December 2025 @ 11:48 pm
For the source code as follows:
#include <iostream>
#include <cstdlib>
#include <mpi.h>
using namespace std;
int main(int argc, char **argv){
int allocresult, infocreateresult;
int tabsize = atoi(*(argv + 1));
int *myrank = new int(0);
int *ranks = new int(0);
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD, myrank);
MPI_Comm_size(MPI_COMM_WORLD, ranks);
MPI_Info *info1;
infocreateresult = MPI_Info_create(info1);
double **tab1init;
double *tab1;
MPI_Aint size1;
if(!*myrank){
// initialization block
size1 = tabsize * sizeof(double);
} else {
int workchunk = tabsize;
workchunk /= (*ranks - 1);
if(*myrank == *ranks - 1){
workchunk += tabsize % (*ranks - 1);
}
size1 = workchunk * sizeof(double);
}
allocresult = MPI_Alloc_mem(size1, *info1, tab1init);
tab1 = *tab1init;
// final block
M
decrypting oddspot data through response interception
20 December 2025 @ 3:06 pm
import asyncio
from datetime import datetime, UTC
from playwright.async_api import async_playwright
captured = []
async def run():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
page = await browser.new_page()
async def handle_response(response):
url = response.url.lower()
if any(k in url for k in ("feed", "ajax", "match", "odds")):
try:
content_type = response.headers.get("content-type", "")
if content_type.startswith("application/json"):
data = await response.json()
captured.append({
"url": response.url,
"data": data,
"captured_at": datetime.now(UTC).isoformat(),
})
How to use method inside another method? [duplicate]
20 December 2025 @ 2:16 pm
I'm trying to learn Rust be rewriting a few of my small projects in C++ to Rust, but borrow checker seems to apply unreasonable rules caused by its limitations. The code in question is:
pub struct ParticleEngine {
system: Vec<ParticleArhetype>,
width: u16, height: u16,
buffer: Vec<u8>,
fps: u8
}
impl ParticleEngine {
pub fn tick(&mut self) {
let mut rng = rand::rng();
for archetype in &mut self.system {
for particle in &mut archetype.particles {
self.buffer[self.coordinates_to_buffer_index(particle.x, particle.y)] = b' ';
particle.y.wrapping_add_signed(archetype.speed);
particle.x = rng.random::<u16>();
particle.y = rng.random::<u16>();
self.buffer[self.coordinates_to_buffer_index(particle.x, particle.y)] = archetype.character;
}
}
}
fn coordinates_to_buffer_inde