Random snippets of all sorts of code, mixed with a selection of help and advice.
How to handle token expiry
4 March 2026 @ 11:36 pm
I'm facing a one issue in my flutter application I'm login the dashboard not log out we close the application and used different applications and after 4 to 5 days later once we click on the my application it properly open but not fetch data in application show nothing only see ui not show any data after we log out and log in it properly working I don't know what happened
Zookeeper C Library Include Errors
4 March 2026 @ 11:30 pm
I followed the directions on the official website to install the C libraries in my Linux remote host. The only issue I am having is that none of the synchronous APIs are present. For example, I want to do ret = zoo_get(zh, (std::string("/services/") + server_node).c_str(), 0, buf, &len, nullptr); but I get the compilation error error: ‘zoo_get’ was not declared in this scope; did you mean ‘zoo_aget’? I have verified that the libraries are not corrupted by grep-ing:
> grep zoo_get_children /usr/local/include/zookeeper/zookeeper.h
* are set using \ref zoo_get_children or \ref zoo_get_children2.
ZOOAPI int zoo_get_children(zhandle_t *zh, const char *path, int watch,
* This function is similar to \ref zoo_get_children except it allows one specify
ZOOAPI int zoo_get_children2(zhandle_t *zh, const char *path, int watch,
* This function is similar to \ref zoo_get_children except it allows one specify
I a
Copying a list and trying to make everything in the new list lower case
4 March 2026 @ 11:19 pm
I thought this should work. The goal is to copy the list using [:] and then converting all the items in the list to lowercase. There are probably a lot of ways to do this, but is there a way to make the manner I am trying to work?
list = ['CAR', 'TRUCK']
copied_list = list[:]
for value in copied_list:
value = value.upper
print(copied_list)
I expect in the printed output to see the new, copied list printed in lowercase. However, the case is not changed:
Actual result: ['CAR', 'TRUCK']
Change Button.Text property to a custom value in C#
4 March 2026 @ 11:14 pm
public Button()
{
this.Size = new Size(100, 100);
this.ForeColor = foreColor;
this.BackColor = BackColor;
this.Text = "Hello";
}
I created this constructor class to create my own custom button object, but it always assigns the default text property and doesn't accept my value. I know I can change the text through the designer, but I want to learn how to do it using code.
GDB examine command shows different value than value loaded from the same address
4 March 2026 @ 11:13 pm
I tried to make a function that finds all existing PCIe device's functions and saves the physical address of their config space to an allocated memory for my os, but I noticed that I got WAY too much saved addresses for the simple qemu vm I was testing this on so I tried to use gdb to check if it detects non existing functions correctly,
but when testing the vendor ID I found something very weird: I have an address pointing to the vendor id stored in RDX and when I use the gdb examine command it shows the vendor id is 0x8086 and after the mov instruction to move the vendor id from whats RDX points to, to bx, bx also contains that however on the second iteration(its in a loop) gdb's examine command(i used x/h $rdx) shows that the vendor id is 0x1234 but for some reason bx still contains 0x8086 after the mov bx, [rdx] instruction and this keeps happening for all other iterations too.
so if x/h $rdx shows 0x1234 shouldn't bx also contain 0x1234 after the mov bx, [rdx] ins
In dependency property pattern in WPF, automatically cast the result of GetValue() to expected return type
4 March 2026 @ 11:09 pm
I'm working with WPF and C# with .Net, and I'm building out some basic controls using dependency properties. I'm trying to get the pattern for this sort of thing as repeatable and easy as possible with as little needing to change if, say, I copy a dependency property and paste it, editing what I need to make a new property.
I have a Textbox with an attached label in a DockPanel. LabeledContainer is the generic control with all the logic for a label and control in a DockPanel and more for quickly specifying whether the label should appear to the left, right, or above or below the control but all that is working, and I believe irrelevant for the question.
Here's a stripped down example file:
namespace MyApp.Controls
{
using ContentType = Label;
using MyType = LabeledTextBox;
public partial class LabeledTextBox : LabeledContainer
{
public new Co
Maze Solving without recursion [closed]
4 March 2026 @ 11:01 pm
I'm just learning C and I'm having trouble writing a program that'll take me to the edge of a maze within 5 steps. Well, I need to know all the possible 5 step paths in the maze. The goal is to find the least costly path. I did it with recursion but I'm not too sure how to do it without. Can someone point me in the right direction?
2 dimensional version of "pretty" in R
4 March 2026 @ 10:55 pm
In R it is generally convenient to use a function like "pretty" when deciding intervals to plot in a graph that are useful and readable to the general audience. In R if you are producing a number of plots, you might want to collate them onto a single page or grid, but is there any convenient function to decide the specific inputs to par(mfrow=(...)) to collate several plots?
For instance, if I have 9 plots, a "pretty" rendering would be a square 3 by 3 matrix, but if I had 10 plots, the "best" approach might be a 2 by 5 matrix, or I might choose a 3 by 4 matrix with 2 squares left blank. I'm not too sure of the best internals, in as much as I'm not too sure about how pretty works, but it would be convenient to know how best to automate display of multiple graphs simultaneously, or if any such function exists.
First frame submission fails with unrecorded command buffer and unsignaled semaphore in multithreaded pipeline
4 March 2026 @ 10:36 pm
I’m implementing a Vulkan rendering loop with multiple frames in flight using a producer‑consumer pattern and a thread pool.
The main loop logic is:
PreRender on the main thread — wait on fences, acquire swapchain image.
Submit PrepareFrame and RenderFrame to a thread pool.
Wait (Join) for thread pool tasks to finish.
PostRender on the main thread — present the image.
Repeat.
However, on the very first frame, Vulkan validation reports errors that the command buffer is unrecorded and the semaphore used for waiting has no way to be signaled.
❓ What I’m struggling with
On the first iteration:
PrepareFrame records commands (color clear pass).
But RenderFrame — which submits the command buffer — runs wi
Why does this assignment fail but not cause an error?
4 March 2026 @ 10:12 pm
In this python I expect either for x to be assigned to 1, OR for an error/exception to be raised. Instead, nothing happens. The statement is not an error but it also has no effect.
x = 0
[x][0] = 1
This contradicts my understanding of Python's semantics. If [x][0] is an expression returning 0, this should error because 0 = 1 is an error.
On the other hand, if [x][0] returns a reference to x, then the assignment should succeed and change the value of x to 1. What gives?