Random snippets of all sorts of code, mixed with a selection of help and advice.
"TypeError: <class> is not reversible" -- what does it mean?
3 December 2025 @ 3:36 pm
Something called reversed() on an instance of a class of mine, which resulted in the error
TypeError: 'HBox' object is not reversible
What does it mean for an object to be reversible?
MCP Connect Fail
3 December 2025 @ 3:36 pm
In the context of writing a simple token or access control smart contract, why is it considered a major security vulnerability to use require(tx.origin == owner) for access control, while require(msg.sender == owner) is the standard and secure practice?
How to obtain ios live activity pushToUpdate token?
3 December 2025 @ 3:34 pm
I’ve implemented a Live Activity for my React Native application. When the activity is started from within the app, I’m able to execute the pushTokenUpdates asynchronous sequence from the widget extension and successfully send the resulting token back to my server. I then use this token to update the Live Activity via APNS notifications.
I also obtained the pushToStartToken and have been able to start a Live Activity remotely through APNS without issues.
According to the documentation (“Construct the payload that starts a live activity”):
https://developer.apple.com/documentation/activitykit/starting-and-updating-live-activities-with-activitykit-push-notifications
For devices running iOS 18 and iPadOS 18 or later, you can add input-push-token: 1 to your payload to start a Live
How does garbage collection differ between Python and Java, and when do objects actually get destroyed?
3 December 2025 @ 3:29 pm
I'm trying to understand how garbage collection works in Python vs Java.
From what I know:
Python uses reference counting + a garbage collector
Java uses an automatic garbage collector based on JVM
But I'm confused about when objects are actually destroyed in both languages.
For example:
Python code
class A:
def __del__(self):
print("Destroyed")
obj = A()
obj = None
print("End")
Sometimes __del__ prints immediately, and sometimes it doesn't (especially when using circular references).
Java code
class A {
protected void finalize() {
System.out.println("Destroyed");
}
}
public class Main {
public static void main(String[] args) {
A obj = new A();
obj = null;
System.ou
How do I add pan and zoom to a vega lite candlestick chart
3 December 2025 @ 3:26 pm
I can see how to pan a scatterplot in vega-lite using the examples. I can also see how to create a static
Analyze a directory in a performant (cross-platform) way for what file types (file extensions) it (recursively) contains?
3 December 2025 @ 2:44 pm
Aim
My aim is to analyze a (big) (sub)directory and just find out what file extensions all files have there (recursively).
Additionally, these conditions apply:
I am on Windows, but I could use WSL if need for Linux commands
There are a lot of files.
I need to access a network file share (\\), also guess this is most easy on Windows
It would be good if I can analyze/visualize the results later.
Edit: "no file extension" being listed too would be nice, too
Tries so far
One first approach would be using Linux shell commands but given the requirements above, I guess this is harder (access needs to be done via samba or WSL mounting somehow? Visualization is harder than if you already have a Jupyter notebook/Python script) and I also don't think it would be really fast.
One could try
c how to display the contents of allocated memory byte by byte
3 December 2025 @ 2:32 pm
Just for information/debugging purposes (and to check if I understood pointers correctly), I want to display the contents of some allocated memory byte by byte. My code so far:
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int len;
int* vec[];
} vec_t;
int main(void) {
int n=3;
int size = sizeof(vec_t) + n * sizeof(int*);
vec_t* vector = malloc(size);
vector->len = n;
vector->vec[0] = NULL;
vector->vec[1] = NULL;
vector->vec[2] = NULL;
char* line = (char*) vector;
printf("memory content: ");
for (int i=0;i<size;i++) {
printf("%2x,", line[i]);
}
printf("\n");
free(vector);
return 0;
}
This gives me something like:
memory content: 3, 0, 0, 0,ffffffc8,22,ffffffa8, 1, 8,23,ffffffa8, 1,48,23,ffffffa8, 1,
I was expecting 16 hex numbers in chunks of 1 byte, but it seems as if I read chunk
Unexpected conversion from pointer to object during function call
3 December 2025 @ 2:16 pm
This piece of code is a synthetic example extracted from a real world app.
This code doesn't make much sense, its only purpose is illustration and everything that is not relevant has been stripped.
#include <iostream>
class st
{
public:
int m = 1;
st() {
std::cout << "st()\n";
};
st(const st *source) {
m = source->m;
std::cout << "st(const st *source) " << m << "\n";
};
};
void Foo(const st& bar) {
std::cout << "Foo" << "\n";
}
int main() {
st foo;
const st* p = &foo;
Foo(p); //(1)
}
Output
st()
st(const st *source) 1
Foo
The problem here is when I call the void Foo(const st& bar) function with a pointer to st as in the line with comment //(1)
How to dynamically create an unknown number of tasks in Airflow based on output of a previous task?
3 December 2025 @ 2:10 pm
I have an Airflow DAG where the number of downstream tasks is unknown until an upstream task finishes. The workflow looks like this:
|---> Task B.1 --|
|---> Task B.2 --|
Task A -----|---> Task B.3 --|-----> Task C
| ... |
|---> Task B.N --|
Task A determines how many Task B instances are required.
Each Task B.* runs for several hours and cannot be merged into a single task.
Task C should run only after all dynamically created Task B tasks complete.
Since the number of Task B tasks is not known at DAG parse time, standard static DAG definitions and SubDAGs do not work.
I considered using TriggerDagRunOperator + ExternalTaskSensor by triggering a second DAG that dynamically creates Task B.*, but t
Hibernate: Invalid stream header "[-0." when trying to deserialize pgvector embedding into JPA entity
3 December 2025 @ 11:19 am
I created a PGvector database:
CREATE TABLE IF NOT EXISTS vector_store (
id uuid DEFAULT uuid_generate_v4() PRIMARY KEY,
content text,
metadata jsonb,
embedding vector(1024),
created_at timestamptz DEFAULT now()
);
and defined a JPA entity following Hibernate's documentation regarding vectors:
@Entity
@Table(name = "vector_store")
public class Document {
@Id
@Column(columnDefinition = "uuid")
private UUID id;
@Column(columnDefinition = "text")
private String content;
@JdbcTypeCode(SqlTypes.JSON)
@Column(columnDefinition = "jsonb")
private LogMetadata metadata;
@JdbcTypeCode(SqlTypes.VECTOR)
@Column(columnDefinition = "vector(1024)")