Random snippets of all sorts of code, mixed with a selection of help and advice.
Getting feedback from the main process in an elecron app
8 December 2025 @ 7:40 am
My Electron app start with a script called main.js. In amongst various setting up processes:
I create a BrowserWindow called window.
window loads a page called index.html.
index.html includes `require(./scripts/etc.js')
I want to trouble shoot some activity in the main.js script, but I can’t work out how to report on it.
I understand that I can’t use console.log() because that’s only available in browser window itself.
I have tried passing a message from main.js throug IPC:
// main.js
window.webContents.send('CLOG', 'Hello');
// etc.js
ipcRendered.on('CLOG', (event, message) => {
console.log(message);
})
But that doesn’t get me any where — either it’s the wrong approach or it’s incomplete.
Is the
Does PHP Header Location Send HTTP Referrer information?
8 December 2025 @ 7:40 am
`header('Location: https://www.example.com'); ` => Will send this HTTP Referrer information?.
I want to remove HTTP Referrer information, i am trying like
header('Referrer-Policy: no-referrer');
header('Location: https://www.example.com');
Am I doing right?
Sync-ops in stackexchange redis timeouts
8 December 2025 @ 7:38 am
StackExchange.Redis.RedisTimeoutException: Timeout awaiting response (outbound=0KiB, inbound=4KiB, 6000ms elapsed, timeout is 3000ms), command=EXISTS, next: GET mykey, inst: 0, qu: 0, qs: 0, aw: True, bw: SpinningDown, rs: ReadAsync, ws: Writing, in: 993, last-in: 1, cur-in: 0, sync-ops: 37097, async-ops: 170733, serverEndpoint: XXXXXXXX, conn-sec: 5412.93, aoc: 1, mc: 1/1/0, mgr: 10 of 10 available, clientName: XXXXXXXXX, PerfCounterHelperkeyHashSlot: 7906, IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=28,Free=32739,Min=2,Max=32767), POOL: (Threads=28,QueuedItems=1715,CompletedItems=1310821,Timers=80), v: 2.6.122.38350 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
Could you please answer the following questions
Why do I have sync-ops when I am not using sync functions anywhere in the code. I use the update and get as follows (asy
unet type Segmentation Model training extremely slow
8 December 2025 @ 7:37 am
I am trying to implement unet++ for the next day wildfire dataset, but my training process became extremely slow on colab free gpu, I wonder if there is any bug in my code that I am not aware of? Here is the code snipped and also you can find the full code in this link.
Please advise!
def train_model(model: Model, train_dataset: tf.data.Dataset, epochs: int = 10) -> tuple[list[float], list[float]]:
"""
Trains a model using train dataset. (Save weights of model with best IoU)
Args:
model (Model): Model to train.
train_dataset (Dataset): Training dataset.
epochs (int): Number of epochs
Returns:
Tuple[List[float], List[float]]: Train losses and Validation losses
"""
optimizer
Docker build command is not running
8 December 2025 @ 7:36 am
I'm running the command of
#docker build -t hassaanzafar/mynode_application .
but its not running and giving me an error like:
The legacy builder is deprecated and will be removed in a future release.
How to create a Straddling div that overlaps direct sibling div, but does not overlap content
8 December 2025 @ 7:36 am
I want to add a "Straddling div", between two other divs in a column layout.
Div 1, Div 2, Div 3.
Diagram
In the above image, scenario on the left, Div1 and Div2 are 'touching'. Just two divs next to each other in the DOM, and they each have internal padding.
In the second scenario, on the right, I want to have a straddling div, that doesn't change that the Div1 and Div3 should be 'touching', but I want to make sure the padding remains consistent, so the content is not being overlapped by the straddling div.
Attempts in this fiddle with CSS selectors, but there are magic numbers that I don't really want, and it didn't get me the solution I wanted anyway.
Is there some nice trick to doing this? Ideally with no magic numbers and not changing the outside siblings properties. This is dynam
The image is a little shifted when simulating camera rotation around camera center and ration back using cv2.warpPerspective
8 December 2025 @ 7:34 am
I simulate what one image is changed when the camera is rotated around its center and back to its inital position. I expect the final image will be almost aligned with the original image. When the camera is rotated around its center, the resultant image can be obtained using the function cv2.warpPerspective. The entire process is as follows. The pyquaternion module is used to represent quaternions.
K: camera intrinsic matrix
quat_z_01 = Quaternion(axis=[0, 0, 1], degrees=0.1)
r_z_01 = quat_z_01.rotation_matrix
w_matrix = K@[email protected](K)
frame_z_01 = cv2.warpPerspective(frame, w_matrix, (frame_w, frame_h))
cv2.imwrite("test_frame_z_01.png", frame_z_01)
w_matrix = [email protected](r_z_01)@np.linalg.inv(K)
frame_z_01_inv = cv2.warpPerspective(frame_z_01, w_matrix, (frame_w, frame_h))
cv2.imwrite("test_frame_z_01_inv.png", frame_z_01_inv)
Any help will be greatly appreciated.
Why hasn't ASLR randomized the address of my program?
8 December 2025 @ 7:32 am
I am a student, and I have recently learned about content related to ASLR.
I referred to this article:
Why aren't glibc's function addresses randomized when ASLR is enabled?
But I use the Windows11 system and the Visual Studio compiler,Then I run the same code:
#include <stdio.h>
#include <stdlib.h>
int main() {
printf("%p\n", &system);
return 0;
}
And I made sure I did some necessary work:
However, after
However, after instance segmentation on custom coco dataset using pytorch maskrcnn + fpn for 83 categories (+background)
8 December 2025 @ 7:30 am
I am running a training of instance segmentation on custom coco dataset using pytorch maskrcnn + fpn for 83 categories (+background).
What is the problem with following setup and why RPN head not learning at all? The pos/neg ratio tells that's it's hardly generating any positive proposals.
Below is the dataset summary:
num_images: 4405
total_boxes: 9815
boxes_per_image mean/median/std: 2.228149829738933 2.0 1.0245244095968575
min width quantiles: [ 10.68164062 21.13461914 32.66494141 58.95422363 97.87231445 175.42504883 460.02619629 1400.78208496]
min height quantiles: [ 2.7885437 22.43139648 32.5918457 58.7487793 92.48022461 158.16992188 530.36206055 1252.80771973]
area quantiles: [9.63848358e+02 2.14234753e+03 3.44198750e+03 9.42426807e+03 6.17710273e+04 1.59976806e+06 3.43455110e+06 4.59061925e+06 6.50262512e+06] zero_area_count: 0
bad_coord_count: 0
The training script has custom ROI head
How to extract the path from a drawing using Python?
8 December 2025 @ 7:30 am
I have a engineering drawing and want to extract the path and the distance between the connectors. is there any way to do it ?