Random snippets of all sorts of code, mixed with a selection of help and advice.
Recommendations for improving my structure
25 January 2026 @ 10:57 pm
"""Firewall"""
import random
def rng_ipv4():
"""Generates random IP address"""
number = tuple(str(random.randint(100, 255)) for _ in range (2))
first_half = ".".join(number[:2])
number_2 = tuple(str(random.randint(0,9)) for _ in range (2))
second_half = ".".join(number_2[:2])
number = str(f"{first_half}."f"{second_half}")
return number
def firewall(ipaddress_1):
'''what is allowed within this firewall'''
checking_ip = ipaddress_1.split(".")
#point scoring system
x = 0
if len(ipaddress_1) >= 7 and len(ipaddress_1) <=15:
x+=1
if len(ipaddress_1.split(".")) == 4:
x+=1
for ocet in checking_ip:
if ocet.isdigit():
x+=1
if int(ocet) >=0 and int(ocet) <= 255:
x+=1
if x == 10:
How to spread Jobs on multiple frames?
25 January 2026 @ 10:51 pm
I have a script that needs to perform computationally intensive operations, so I decided to use Jobs and Burst. My idea would be to schedule a Job and have it run in the background on all available threads, splitting the work across multiple frames so as not to cause spikes or block the main thread. That would be the intention... But I don't understand why it doesn't work... What happens is that when I schedule the Job, I expect it to run across multiple frames due to the time it takes to complete, which isn't currently the case. The Job is forced to run and complete in the same frame in which it was scheduled.
I have two Jobs; the second needs data from the first, so: Currently, in the code, I schedule the first Job. Then, in the next frame, I check whether it has completed with* IsCompleted()*. If true, I call Complete() and prepare the data needed to run the second Job, then schedule it. So with this job too, I check in the next frame whether it's
Azure Application Gateway in front of an external Azure Container Apps environment
25 January 2026 @ 10:35 pm
I have external Azure Container Apps environment with containerized applications(ACA) inside dedicated subnet. All apps have ingress settings set to internal(traffic is limited to ACA environment)
Now I want to setup Application Gateway in the same VNET, but in a different subnet. I am constantly getting 404 error when calling the App Gateway public ip. I assume that is because of the ingress setting which block traffic from other subnets. Is there a way to bypass the traffic from the other subnets ?
I know that setup works on internal ACA env, but I don't want to switch for now.
Microsoft store application is not working [closed]
25 January 2026 @ 10:27 pm
I am facing the Windows camera error:
"Microsoft store application not working "
Environment:
- Windows 10 / 11
Goal:
I am looking for a PowerShell-based solution to:
Does the pointer to a struct array not point to the same address as it's first element?
25 January 2026 @ 7:46 pm
On running the following piece of code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
struct Person {
char *name;
int age;
char *address;
struct Person *next;
};
int noOfPersons;
printf("\nEnter the number of persons:\t");
scanf("%d", &noOfPersons);
struct Person *person_arr = malloc(sizeof(struct Person) * noOfPersons); //indexed array of persons
printf("\nMemory allocated for %d persons\n", noOfPersons);
struct Person *head = &person_arr[0];
printf("Address pointed by person_arr: %p\n", (void*)&person_arr);
printf("Address pointed by head: %p\n", (void*)head);
printf("Address pointed by first person_arr element: %p\n", (void*)&person_arr[0]);
free(person_arr);
return 0;
}
I am getting the following output:
Enter the number of persons: 2
Mem
Index name in Oracle
25 January 2026 @ 7:29 pm
In my app I’m doing following:
SELECT 1 FROM all_indexes WHERE table_name = UPPER(‘my table name’) AND table_index = UPPER(‘my index name’)
CREATE INDEX my index name ON my table name(field1, firld2)
The problem is that when I execute the first query it doesn’t return anything and so it successfully tries to create an index, which fails because it already went through this logic.
So I tried to run the first query in the shell and it didn’t return anything. However when I try to filter only by table name and display the index name I got something like SYS_C007052, which is not what I expect.
Does Oracle not honor index names?
This is what I receive from shell:
SQL> DROP TABLE abcatcol;
Table dropped.
SQL> CREATE TABLE abcatcol(abc_tnam char(129) NOT NULL, abc_tid integer, abc_ownr char(129) NOT NULL, abc_cnam char(129) NOT NULL, abc_cid smallint, a
React Leaflet Error with HMR - Cannot read properties of undefined
25 January 2026 @ 5:26 pm
I'm using Next.js 16 with React-leaflet 5.0.0. When saving a change an on browser HMR updates I'm getting the following error.
Cannot read properties of undefined (reading 'appendChild')
My component structure is the following
In my Page.tsx I'm dynamically loading the map with
Page.tsx
const LazyMap = dynamic(
async () => {
return import("@/components/map/search-map")
},
{
ssr: false,
loading: () => <LoadingSpinner />,
}
)
this page is is client rendered
My search-map.tsx is
'use client'
import { useState, useEffect } from 'react'
import "leaflet/dist/leaflet.css"
import L from 'leaflet'
import { MapContainer, Marker, Popup, TileLayer } from "react-leaflet"
import Link from 'next/link'
import { createClient } from '@/lib/supabase/client'
import {
Is there a concept in Python 3 which integrates with the while-statement like an iterator does with the for-statement?
25 January 2026 @ 7:03 am
I am searching for a way to accomplish the common algorithmic pattern
prev_length = -1
while len(my_list) != prev_length:
prev_length = len(my_list)
# algorithmic code goes here
in the following form, which reads like plain English
while length_changed(my_list):
# algorithmic code goes here
I only was able to come so far:
tracker = LengthTracker(my_list)
while tracker.changed():
# algorithmic code goes here
To keep focus on the actual question, I spare you reading the implementation of class LengthTracker because this client side code already shows why I dislike this approach: There is the extra initialization of the tracker object plus it pollutes my code as the object needlessly keeps existing after the loop has ended.
I guess, as I want automatic initialization, I might be looking for a concept that structurally relates to the whil
How to handle multiple dependencies in TDD with Java?
24 January 2026 @ 11:44 pm
I'm practicing TDD in Java and my test setup is becoming too complex when a class has multiple dependencies.
Scenario:
For example, my PaymentProcessingService depends on a validator, payment gateway, database repository, and email service. My tests require mocking all four dependencies, making the setup verbose and hard to maintain.
@Test
public void shouldProcessValidPayment() {
// Mocking 4 dependencies makes this setup very long
when(validator.validate(any())).thenReturn(true);
when(gateway.charge(any())).thenReturn(new GatewayResponse("success"));
when(repository.save(any())).thenReturn(transaction);
// ... bla bla bla
PaymentResult result = service.processPayment(request);
assertEquals(PaymentStatus.SUCCESS, result.getStatus());
}
Question:
In TDD, should I be breaking this into smaller classe
Update MS Access db with SQL that includes select statement
24 January 2026 @ 3:32 pm
I'm using NodeJS and node-adodb to try to run an update on a MS Access database that includes selects. I tried this:
update [Objects]
set
[Object] = 1,
[CardID] = (select id from Oracle where name = 'mycard'),
[CardID2] = null,
[SetID] = 1034,
[LangID] = 1,
[Version] = '',
[Name] = 'mycard'
where
id = 502561
But I get an error:
user lacks privilege or object not found: WHERE
It appears to not like the select statement with cardid. Is there a way to create an update in access that includes a select like this?