Random snippets of all sorts of code, mixed with a selection of help and advice.
Linux Sockets Correct Syntax Gcc Console App compiles with list of undefined errors unexplained?
1 December 2025 @ 12:55 am
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <netdb.h>
#include <fcntl.h>
#include <poll.h>
#define _GNU_SOURCE
#define http 80
extern int sockvrsn, socktyp, sockprtcl;
extern int clisocket;
extern socklen_t clisockaddrinfsze;
extern const struct sockaddr *clisockaddrinf;
int cliprogram(int cliprogramend)
{
int clisockmde = AI_PASSIVE|AI_ADDRCONFIG|AI_CANONNAME;
char *cliaddrnfoiphost = NULL;
const struct addrinfo *cliaddrnfoinfr = NULL;
struct addrinfo cliaddrnfo{
cliaddrnfo.ai_flags = clisockmde;
cliaddrnfo.ai_family = sockvrsn;
cliaddrnfo.ai_socktype = socktyp;
cliaddrnfo.ai_protocol = sockprtcl;
cliaddrnfo.ai_addrlen = clisockaddrinfsze;
cliaddrnfo.ai_addr = clisockaddrinf;
cliaddrnfo.ai_canonname = cliaddrnfoiphost;
cliaddrnfo.ai_next = cliaddrnfoinfr
Using stackview with qrc
1 December 2025 @ 12:28 am
I have an issue:
qrc:/qt/qml/MyApp/qml/MyApp/Main.qml:11:5: QML StackView: initialItem: qrc:/qml/pages/LoginPage.qml:-1 No such file or directory
File tree
Im strugling to see why it cannot find my qml file to load?
I have tried with both the qrc file path and the alias:
Main.qml:
import QtQuick
import QtQuick.Controls
ApplicationWindow {
visible: true
minimumWidth: 300
minimumHeight: 600
width: 400
height: 800
StackView {
id: mainStack
anchors.fill: parent
initialItem: "qrc:/qml/pages/LoginPage.qml"
}
}
resources.qrc
<RCC>
<qresource prefix="/qml">
<file alias="pages/LoginPage.qml">qml/MyApp/pages/LoginPage.qml</file>
<file alias=&
Dynamic Look Up with Multiple Criteria: <>, =, >, >=, <, <= as Sign Inputs and an Input Value Cell
1 December 2025 @ 12:23 am
I have a workbook with 2 tabs: an Override tab and a Calculation Detail tab. I am trying to create a formula that returns "Y" or "N" in the parameter_# field of the Calculation Detail tab if a given loan_id meets the criteria inputted for that Adjustment # in the Override Tab.
For example, for loan_id 292484674, I want cell X22 to calculate: IF(AND(G22>=1,H22="N",I22<=0.8,J22<>"NPL",K22<>"LDTV",L22<>"NPL_LDTV"),"Y","N")
The working function I have is laid out in Working Parameter Criteria Formula below. This function is returning a #REF error when the criteria inputs on my Override Tab are set to anything other than <> for the sign input and [null] for the value input for each criteria (i.e. column D of the Override Tab). Any help in getting this function to work whilst keeping it dynamic so the user can toggle the sign and value for each
How do you move the function definition for the ->when() function in Laravel Eloquent Models?
1 December 2025 @ 12:19 am
so I'm building a way to organize Items based on different requests:
$items = Item::query()
->where("type", $itemType)
->when($mode, function (Builder $query, $mode) {
switch ($mode) {
case "TopFavorites":
return $query->orderByDesc('number_favorited');
case "BestSelling":
return $query->orderByDesc('number_sold');
case "RecentlyUpdated":
return $query->orderByDesc('updated_at');
case "ForSale":
return $query->where("onSale", true);
case "Offsale":
return $query->where("onSale", false);
}
})
->get();
I'm wondering if you can move the function in when to an external functio
install error on Mac OS: 'ios' file not found ... failed building wheel for pandas
1 December 2025 @ 12:00 am
I am running into a consistent error with the PyPI install of apache superset 6.0.0. I am following the instructions from https://superset.apache.org/docs/6.0.0/installation/pypi/.
pip install apache-superset
fails with this error:
building 'pandas._libs.window.aggregations' extension
creating build/temp.macosx-15.0-arm64-cpython-312/pandas/_libs/window
clang++ -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -DNPY_NO_DEPRECATED_API=0 -Ipandas/_libs/window -I/private/var/folders/0q/9xvvq6m90j1gy8xgdm3d_vtw0000gn/T/pip-build-env-1_mbt4lw/overlay/lib/python3.12/site-packages/numpy/core/include "-I/Users/patrice/Documents/Development/CCBC Ski Team Data/bcskiteam/include" -I/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c pandas/_libs/
Using a colour matrix to isolate only yellow out of a grayscale
30 November 2025 @ 11:41 pm
I do apologise if this is an incredibly dumb question, because I know it is,
I have no experience with colour matrices and the information I can find online to learn about them is unhelpful at best for what I am looking to do, as I literally cannot wrap my head around how to do specifically this, or if it is even possible (which I at least assume that it is)
How do I make every colour grayscale whilst keeping only one colour, the one that I have figured out thus far has only managed to do the exact opposite of what I was trying to do, turning almost every colour into yellow yet leaving the actual yellow as grayscale, but I still feel like it is progress,
{ 0.4, 0.4, 0.4, 0.0, 0.0 }
{ 0.4, 0.4, 0.4, 0.0, 0.0 }
{ 0.4, 0.4, 0.0, 0.0, 0.0 }
{ 0.0, 0.0, 0.0, 1.0, 0.0 }
{ 0.0, 0.0, 0.0, 0.0, 1.0 }
Literally any help whatsoever would be wonderful, I am
TypeScript: Why does my async Redis operation return undefined even though the command resolves successfully?
30 November 2025 @ 11:41 pm
I’m working on a Node.js (v20) + TypeScript application using Redis Stack.
I’m trying to fetch data using an async function, but the return value is always undefined, even though the Redis command itself resolves successfully.
My function:
export async function getUserSession(sessionId: string) {
try {
const result = await redisClient.get(sessionId);
console.log("Redis result:", result); // prints correct value
return result; // returns undefined to caller
} catch (err) {
console.error(err);
}
}
How I call it:
const session = getUserSession("abc123");
console.log(session); // undefined
The function should return the actual Redis value as a resolved promise.
Actual behavior:
The returned value logs as undefined unless I manually add await inside the calle
Is there a better way to map a user input to a list of possible replies than this function I cobbled together?
30 November 2025 @ 10:37 pm
I have this function I came up with as a python noob that takes an "inputMap", a 2-dimensonal array as follows:
exampleInputMap = [
['1', 'a', -1], # do the first action
['2', 'b'], # do the second action
['3', 'h'], # print help
['4', 'q'] # quit the program
]
def mapInputToAction(inputMap, matchFirstCharOnly=True, prompt='> '):
while True:
response = input(prompt)
if len(response) == 0:
for index, row in enumerate(inputMap):
if -1 in row:
return index
else:
for index, row in enumerate(inputMap):
if matchFirstCharOnly:
if response[0] in row:
return index
else:
if response in row:
return index
This is used in a while loop, fed into a match/case statement. It gets an input f
How to cause a linker error when an externally-defined macro is inconsistent across translation units?
30 November 2025 @ 9:57 pm
I'm writing a header-only library which defines class X in header x.hpp. The implementation of X is different for different standard versions:
#if __cplusplus < 201703
class X {
int a;
};
#else
class X {
char b;
short c;
};
#endif
When x.hpp is included in different client translation units a.cpp and b.cpp, which are compiled with ${CXX} -std=c++11 -c a.cpp and ${CXX} -std=c++20 -c b.cpp and linked together, this silently produces a broken binary since ODR violations are IF-NDR.
In practice I can use inline namespaces like so:
#if __cplusplus < 201703
inline namespace before_cpp17 {
class X {
int a;
};
}
#else
inline namespace cpp17_or_later {
class X {
`Compress-Archive` with the `-Update` parameter erases the archive when given an empty list
30 November 2025 @ 8:55 pm
I need to create a ZIP archive from a directory (data) with the following properties:
A specific file (.foo) needs to be the first item in the archive, uncompressed
The remaining files, if any, need to be added to the archive in any order, with any compression level
The idea is to create an archive from the initial file (.foo) and subsequently -Update the archive with the remaining files. Given this directory structure
/
├─ + data
│ ├─ .foo
│ └─ bar
└─ + script
└─ make.ps1
the following script accomplishes that.
script/make.ps1:
$root_dir = Join-Path -Path $PSScriptRoot -ChildPath '..' -Resolve
$out_dir = $root_dir + '\out'
if (!(Test-Path -Path $out_dir)) {
[void](New-Item -Path $out_dir -ItemType 'Directory')
}
$out_file