Random snippets of all sorts of code, mixed with a selection of help and advice.
How to user Riverpod NotifierProvider with Controllers?
1 November 2025 @ 2:01 pm
I always struggle to hook up Controllers with Riverpod NotifierProvider. For example, TextEditingController, MapController or in this case I need to hook it up with TreeController from the interactive_tree_view package. The problem is that this makes two sources of truth. Where one is provider and other one is Controller and I need to keep them in sync. So when I change value in provider, then the controller value updates, but also I can change the value in controller, then I need to update value in provider. I cannot set Controller to the provider as parameter, this is not a good practice. But would resolve the problem. Since the controller is the one that is responsible for the item adding and removing from the widget I cannot simply remove item from the list of my provider. Normally if this is something like ListView where I just provide items I want, I can just ref.watch my provider in build m
How do real-world C++ developers think about object design, aggregation/composition, and templates in large embedded systems? [closed]
1 November 2025 @ 1:52 pm
I have a solid understanding of C++ syntax and OOP fundamentals — classes, inheritance, polymorphism, encapsulation, etc. However, I’m struggling to understand how these concepts come together in real-world C++ development, especially in embedded systems or platform-level software.
For example, when a team develops something complex like a file system or a device driver framework, how do experienced developers:
Decide which objects should own others (composition vs aggregation)?
Design class hierarchies or module boundaries in a way that remains maintainable and efficient?
Use templates and generic programming in practical ways (beyond simple examples like vector) — e.g., for flexibility or performance in embedded contexts?
Most resources and tutorials I find use trivial examples (like cars and engines), but I’d like to understand:
How such principles are actually applied when multiple developers collaborate on large embedded softwar
How can I monitor process creation/termination in C# using winapi?
1 November 2025 @ 1:33 pm
I’m building a lightweight process monitoring tool in C# (.NET Framework 4.6.2).
Here’s my situation:
I cannot use WMI due to environment restrictions (it’s blocked on some endpoints).
I also cannot rely on ETW (Microsoft.Diagnostics.Tracing.TraceEvent) because it brings too many external dependencies for my use case.
Basically, I want to detect when new processes are created or terminated, similar to what Win32_ProcessStartTrace / Win32_ProcessStopTrace provide in WMI — but using only native Windows APIs if possible.
I’m fine with using P/Invoke or low-level Windows APIs.
So my questions are:
Is there a pure WinAPI approach to subscribe to process creation/termination notifications?
If yes, which APIs or mechanisms should I look into? (e.g. CreateToolhelp32Snapshot, WaitForSingleObject, job objects, hooks, or something else?)
Are there any examples or references for implementing this in C# safely (without polling eve
How to fix this:Type alias is not generic or already specialized
1 November 2025 @ 1:32 pm
As shown in the image, I got a warning in PyCharm at the list index positions like [0][1][2].... The program still runs, but I don't understand what this warning means or how to resolve it.
invitation_list = ["Allen", "Lucas", "Peter"]
message = "Pls come to my house for the dinner,"
print(f"{message} {invitation_list[0]}, {invitation_list[1]}, {invitation_list[2]}.")
print(f"But, {invitation_list[0]} can not join the dinner.")
invitation_list[0] = "John"
message_2= "I just found a bigger table."
print(message_2)


Identifying an event from a big Python list
1 November 2025 @ 1:14 pm
I have a big Python list containing integers.
Below is the definition of my event.
Look at each element of the list and check if that element is greater than a specified number, say S. If before that element, there is a zero, then the Event is recorded. That zero may not be immediately before, however after occurrence of similar past event.
Let say I have this list for S = 6
List = [3, 5, 6, 0, 2, 5, 6, 8, 3, 0, 7].
In above list there are 2 such events occurring at indices 7 and 10.
I am seeking an expert advice if there can be some efficient method to achieve the same. I can run a for loop, but for a large list, that may not be efficient.
Thanks for your time.
How to rotate AlertDialog correctly?
1 November 2025 @ 11:35 am
I'm using this code:
@Override
protected void onResume() {
super.onResume();
AlertDialog d = new AlertDialog.Builder(this)
.setTitle("This is the Dialog Title")
.setMessage("This is the Test message")
.setPositiveButton("Positive Button", (dialog, which) -> {
dialog.dismiss();
})
.create();
rotateDialog(d);
d.show();
}
public static void rotateDialog(Dialog curDlg) {
Window window = curDlg.getWindow();
if (window != null) {
View decorView = window.getDecorView();
decorView.setRotation(-90);
}
}
Before rotation, the Dialog looks correctly. But after rotation, it is cropped on Emulator. (DecorView is visualized using LayoutInspector).
How to handle aiokafka getmany() exceptions in case of stopped kafka
1 November 2025 @ 8:14 am
I am runnging aiokafka consumer in fastAPI app
In the main file I am starting the consumer
from aiokafka import AIOKafkaConsumer
def create_application() -> FastAPI:
...
return FastAPI()
app = create_application()
consumer = create_consumer()
@app.on_event("startup")
async def startup_event():
"""Start up event for FastAPI application."""
global_items["logger"].info("Starting up...")
await consumer.start()
asyncio.gather(
consume(),
# some other tasks
return_exceptions=True
)
async def consume(db: Session = next(get_db())):
"""Consume and process messages from Kafka."""
while True:
try:
print("Try consume")
data = await consumer.getmany(timeout_ms=10000)
for tp, msgs in data.items():
if msgs:
for msg in msgs:
Foreground text is dull and difficult to read on VSCodium/VSCode
1 November 2025 @ 7:28 am
I recently installed a fresh Arch build with the XFCE4 Desktop Environment on a laptop and installed VS Codium. I've used VS Code on the same device but on Windows earlier and on other devices without any issues previously. But when I opened it this time, I feel like the text is significantly duller and the font is particularly hard to read. I compared my settings with another laptop running VS Code on Ubuntu (GNOME) and I am attaching the screenshots of what I see there vs what I see on this laptop.
Screenshot of this laptop with dull foreground text
Screenshot of the other laptop with crisp foreground text
Screenshot of the other laptop with crisp foreground text
How can I display the colors of text inserted with color codes by another program in Bash?
31 October 2025 @ 5:46 pm
When the text directly contained color code for example:
a="\033[0;31mRED\033[0m"
echo -e $a
The terminal had no problem colorizing the text in red. But when I modified the color code indirectly:
#!/bin/bash
# define color mappings
declare -A colors=(
['r']='\033[0;31m' # Red (escaped for sed/printf)
['reset']='\033[0m' # Reset color
)
# Sample text
t="abc def [ghi] jkl
nmo [ttt] dfd
and more"
# colorize all [...] in red
echo -e "$t" | sed "s/\(\[[^]]*\]\)/\\${colors[r]}\1\\${colors[reset]}/g"
The result was
abc def \033[0;31m[ghi]\033[0m jkl
nmo \033[0;31m[ttt]\033[0m dfd
and more
The terminal did not colorize [...]s with red color at all but showed the raw color codes. It seems like the problem is related to the timing of variable expansion of some sort.
How to programmatically grant users permissions for actions with queues in Artemis?
31 October 2025 @ 1:52 pm
I need to programmatically create users in Artemis and grant them access to some queues.
I am currently using JMX for creating users. It works fine, but I cannot determine how to grant a specific user access to a specific queue (i.e. specify that user 'User1' can consume from or send to queue 'Queue1').