Random snippets of all sorts of code, mixed with a selection of help and advice.
How to use the Javascript pushState function of the history object to navigate to a link without adding duplicate entries
18 May 2026 @ 5:52 pm
I am working on an address book that is a single page javascript application. It uses a custom router function which renders different views based on the url. The url is always divided into the root which is the domain name and separated by a forward slash, hash, and another forward slash (ex: localhost:3000/#/...) followed by the fragment where the fragment contains the rest of the identifier information needed for the router function to show the right view (ex: localhost:3000/#/contact/contact_id=1&name=John+Doe) would show the contact page for contact 1, John Doe. The application has a side panel that allows the user to click an icon to navigate to four higher level views as well as to a page to create a new contact. Navigating through the side panel icons using the browser's back/forward buttons is working perfectly.
The application organizes contacts into a few different types of lists. Once the user finds their way to a contact's page they can click a button on the
Unity URP point light blinking, incorrect shadow display, texture overexposure [closed]
18 May 2026 @ 5:32 pm
Please help me solve the problem. Due to the large number of point light sources, there is a problem with textures and incorrect display of shadows on textures. Since many rooms are located behind the same wall and need to be illuminated, it is not possible to reduce the number of light sources (at least I do not know how to do this). https://youtu.be/YOTth6ZDbgg
enter image description here
enter image description here
enter image description here
enter image description here
Stuck on steps to install mongodb [closed]
18 May 2026 @ 5:11 pm
Stuck on upgrading php when setting up newsletter for my business website.
Installing mongodb
ERROR: Could not find a version that satisfies the requirement mongodb (from versions: none)
`NULL` and non-result-set values both return `NULL` when using IN subquery in Apache IoTDB SELECT clause
18 May 2026 @ 3:58 pm
I'm using the table model of Apache IoTDB 2.0.6 to implement a data filtering feature, where I need to mark whether each record belongs to a specific category. For example, I want to check if each product's price is in the price list of "Category A" products.
Raw Data
CREATE TABLE products (product_id STRING Tag, category STRING Tag, price INT32 Field);
INSERT INTO products(`time`, product_id, category, price) VALUES (2024-09-24T14:00:00.000+08:00, 'p01', 'A', 100);
INSERT INTO products(`time`, product_id, category, price) VALUES (2024-09-24T14:01:00.000+08:00, 'p01', 'A', 200);
INSERT INTO products(`time`, product_id, category, price) VALUES (2024-09-24T14:02:00.000+08:00, 'p01', 'A', `NULL`);
INSERT INTO products(`time`, product_id, category, price) VALUES (2024-09-24T14:03:00.000+08:00, 'p02', 'B', 150);
RARS 1.6 – HEX Keypad + Bitmap Display Problem
18 May 2026 @ 2:40 pm
RARS 1.6 – HEX Keypad + Bitmap Display Problem
I am using RARS 1.6 with:
Digital Lab Sim (HEX Keypad)
Bitmap Display
Polling-based keypad scanning
Assignment Requirement
Create a 4×4 grid on the Bitmap Display.
Each key on the HEX keypad corresponds to one cell in the grid.
When a key is pressed, the corresponding cell should turn red.
All other cells should remain black.
Example mapping:
0 1 2 3
4 5 6 7
8 9 A B
C D E F
The bitmap size is 256×256, so each cell is 64×64 pixels.
Current Problems
Problem 1: Program only works at MAX speed
The program only reacts to keypad input when I set Run Speed to MAX in RARS.
If I lower the speed (for example 30 inst/sec or 300 inst/sec):
keypad input stops working
or becomes
Seeking a pattern-recognition solution to address an operational bottleneck
17 May 2026 @ 6:11 pm
What rule can be consistently used to identify the item(s)/element(s) which will be repeated in the next bracket. It is noted that on rare occasions there is no repeat in the next bracket and also that in the last part of the data there are a lot of double repeats in the next bracket. Hence the rule should (a) Indicate which item will be repeated in the next bracket (b) State clearly what condition(s) lead to no repeat in the next bracket; and (c) What condition(s) lead to double repeats in the next bracket. The rule should consistently apply to all the repeats (single, double, etc.)/no repeats in the data provided below.
The dataset is alphanumeric: {0A 0B 0C 1A 1B 1C 2A 2B 2C 3A 3B 3C 4A 4B 4C 5A 5B 5C}
[1C 0B 3B 2A 5A 3A]; [1A 0B 3B 2B 4A]; [1A 5C 2A]; [0C 5A 3A 1A 2B]; [2A 5C 4A 1A]; [1A 5B 4B 3A]; [1A 2B 4C 5A]; [2B 0A 4A 1B 3A]; [5B 4A 1B 3C 2A]; [3A 4B 5C 2A]; [2C 5C 1A 4C]; [5C 3A 4A 0B 1A]; [5C 4B 2A]; [0C 5B 4B 1A
Available C++ annotations for unreachable code
17 May 2026 @ 11:30 am
I have a function that has both Windows and Linux code in it. Due to the fact that I'm using execl, there's a point where some code will be unreachable. Is there a C++ attribute for this?
uint32_t Verify(const std::string& exe_path, const std::string& file_path)
{
#ifdef _WIN32
// Windows code is here
return 0;
#else
if (pid_t pid = fork(); pid == -1)
return 1;
else if (!pid)
execl(AppData::RAR_PATH, std::filesystem::path(AppData::RAR_PATH).filename().c_str(), std::format(AppData::RAR_CMD_LINUX, file_path).c_str(), (char*)0);
else
{
int status{};
waitpid(pid, &status, 0);
return WIFEXITED(status) ? 1 : 0;
}
#endif
}
I'm handling all cases, but the compiler still says that it will reach the end of a non-void function. I could just remove the else block entirely, but I'm interested in attributes.
I have tried [[unreachable]] and [[noreturn]]
Type narrowing fails when default function argument is provided
17 May 2026 @ 11:04 am
Using TypeScript v6.0.3 (also tested on earlier versions down to v4.9.5), I'm narrowing the type for the options of a function which are passed as an object. Some of those parameters have default values. The parameters which have default values aren't working properly with TypeScript automatic type discernment, as far as I can tell.
Why does fun1 fail to narrow the type of t in the if block, yet fun2 can properly narrow its type based on the definition? Is this a bug?
type Type = {
b?: false,
t: number,
} | {
b: true,
t: string,
}
// This doesn't work
function fun1({b = true, t}: Type) {
if(b) {
t /* <-- can't discern type as 'string' only, is 'string|number' */
}
}
// This works
function fun2({b, t}: Type) {
if(b) {
t /* <-- can discern type as 'string' */
}
}
Why my debug msg is not printed on my Kernel Screen?
15 May 2026 @ 3:18 pm
I am currently coding a Kernel, i am trying to use debug msg to check if the kernel has an error.
But for an unknown reason, my debug msg is not printed on the screen,
I tried
Here the main code of the kernel :
kernel_entry:
cli
mov ax, 0x1000
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov si, DEBUG_MSG
call print_string
mov ax, 0x1000
mov ss, ax
mov sp, 0x9000
mov si, DEBUG_MSG
call print_string
call load_memory_map
mov si, DEBUG_MSG
call print_string
jmp $
print_string:
.next_char:
mov al, [si]
cmp al, 0
je .done
mov ah, 0x0E
int 0x10
inc si
jmp .next_char
.done:
ret
DEBUG_MSG db "debug", 13, 10, 0
I'm not using grub since i use my own bootloader in assembly, if you need it :
start:
push cs
pop ds
mov si, boot_title
call print_string
mov si, option_1
call print_string
Looking for a replacement of rimraf for deno project
15 May 2026 @ 1:03 pm
What is the recommended way to replace rimraf in a deno project and in particular in deno tasks? The project [https://github.com/franckLdx/fs_cli] was aiming to fix this but it is outdated. Chatgpt recommends to write some ts-file for deleting the files but that's over-engineered for such trivial task. So do we have some deno-based cli to delete files and directories? Or should we create it? rm -fr would be a not multi-platform workaround.