Random snippets of all sorts of code, mixed with a selection of help and advice.
How can I be the best back end developer using JAVA [closed]
11 November 2025 @ 4:22 am
I am Ranjeet and currently learning Java oops and I want to be a back end developer can anyone suggest is this right path and demand in future or not
Summing log and getting a total
11 November 2025 @ 4:04 am
I’m new to programming. I have a simple push up counter that creates a log to record push ups completed. I cannot figure out a way to modify the program in order to add a fourth option to sum the log and get a total for all pushups completed.
import datetime
def log_pushups():
try:
reps = int(input("Enter the number of push-ups completed: "))
if reps < 0:
print("Please enter a non-negative number.")
return
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
with open("pushup_log.txt", "a") as f:
f.write(f"{timestamp},{reps}\n")
print(f"Logged {reps} push-ups at {timestamp}")
except ValueError:
print("Invalid input. Please enter a number.")
def view_log():
try:
with open("pushup_log.txt", "r") as f:
print("\n--- Push-up Log ---&q
Update reply in conversation
11 November 2025 @ 4:03 am
In a teams channel, after I reply with a card, how do I then update that card? The usual "update card" does not work for me. I think i need something that references the conversation id and the message id.
How can I programmatically perform a system board (motherboard) diagnostic test on Linux?
11 November 2025 @ 3:44 am
I’m working on a C++ backend tool that performs system diagnostics for various hardware components on Linux.
So far, I’ve implemented tests for:
Memory — using memtester
CPU — using stress-based utilities
GPU, Battery, Ethernet, Mouse, Keyboard — using CLI tools and libevdev for input devices
All of these are integrated into a gRPC-based service that reports JSON-formatted results back to the frontend.
Now I need to implement a system board diagnostic, i.e. something that can test or at least report the health of the motherboard and its connected components — like USB ports, PCIe slots, onboard sensors, etc.
Question:
Is there any existing Linux utility, API, or system file that can:
Report faults or health metrics
WebAthn/PassKey Attestation UserHandle is always null
11 November 2025 @ 3:25 am
In my Assertion Verification code I have written: -
if (assertion == null || assertion.Id == null || assertion.AuthenticatorData == null || assertion.ClientDataJSON == null || assertion.Signature == null)
{
// **assertion.UserHandle is null for Samsung phone**
return FAIL_STATUS;
}
Is my comment "assertion.UserHandle is null for Samsung phone" in fact true? I'm only testing on http://localhost with my Samsung phone.
If it is true, how do I reliably associate a WebSite user with their PassKey in my database? Use/Store the the Assertion Id along side my user in the DB? But surely that'd rule out discoverable credentials for anyone with a Samsung phone :-(
Is the failure to return the User Handle only the case for the navigator.credentials.get() method?
return navigator.credentials.get({
publicKey: getAssertionOptions
}).then(rawAssertion => {
var assertion
Is this a sort or something that already exists?
11 November 2025 @ 3:15 am
This is quacksort, if this isn't already existing, someone tell me. This was based off a sort of mine that basically does Bubble Sort but faster, and this is even faster. Only problem is when it has a list that has a missing item.
def quacksort(items: list):
"""Quacksort - Direct position swapping until sorted."""
iterations = 0
# Try until sorted
while not items == list(range(len(items))):
for i, item in enumerate(items):
correct_idx = item
if i != correct_idx:
items[i], items[correct_idx] = items[correct_idx], items[i]
iterations += 1
return items, iterations
C++ does atomic<int> has faster speed than atomic<size_t> for counter?
11 November 2025 @ 3:12 am
I have a bounded queue with small size that definitely fit in int. So I want to use atomic<int> instead of atomic<size_t> for indexing/counter, since int is smaller it should be faster.
However, currently my benchmark shows they have similar speed (when using std::memory_order_relaxed) when used as a counter, but I'm not sure if this is due to bad benchmarking (also this is a VM so current result isn't the most reliable)
=== System Information ===
OS: Linux 6.8.0-1043-gcp (#46~22.04.1-Ubuntu SMP Wed Oct 22 19:00:03 UTC 2025)
CPU:
Architecture: x86_64
Logical CPUs: 8
Node name: Check
Machine: x86_64
g++ 13.3
atomic<int> vs atomic<size_t> micro-benchmark
OPS_PER_BENCH = 50000000
int shared relaxed threads=1 ops=50000000 time=0.3271s ops/s=152878203.38 ns/op=6.54
size_t shared relaxed threads=1 ops=50000000 time=0.3222s op
Can I use Python built-in variables for Seaborn plots
11 November 2025 @ 12:21 am
say I create a dataclass for recording some data...
@dataclass
class HourlyReading:
temperature float
pressure int
I create a list of my dataclass instances and regularly add data to it ...
stationA_meteorology = []
stationA_meteorology.append(HourlyReading(234,456))
stationA_meteorology.append(HourlyReading(345,345))
stationA_meteorology.append(HourlyReading(234,245))
Can I use my list as direct input to sns.lineplot to plot, for instance, a graph of temperature values?
ASP.NET Controls Don't Span Bootstrap Columns
10 November 2025 @ 10:02 pm
I am using Bootstrap 3.5 with ASP.NET controls (Visual Studio 2022). I have an ASP.NET:TextBox in a Bootstrap column. While an HTML input tag spreads across the entire Bootstrap column, left to right, the ASP.NET:TextBox does not. It's width is greatly shorter than the the column width.
I am using codebehind to populate the page with a servertransfer from another page which works quite well with ASP.NET controls, so I don't want to use the the html tags.
How do I get the Bootstrap formatting to spread across the Bootstrap columns correctly with ASP.NET controls?
Yes, some code and an illustration would be great.
Here is the code I have for the page in question.
<formview id="ProviderEdit" runat="server">
<div class="form-group, form-horizontal">
<div class="row" runat="server">
<div class="col-md-1" style="padding-top:7px;">
Do I need a __DMB() memory barrier between two ISRs on a single-core Cortex-M (e.g., STM32H7)?
10 November 2025 @ 6:34 pm
On a Cortex-M7 microcontroller, I have two interrupt service routines running at different priorities(in a baremetal environment) :
IRQ1 runs at 20 kHz (higher priority).
IRQ2 runs at 4 kHz (lower priority)
Both interrupts share a few volatile variables:
volatile uint16_t g_angle;
volatile float g_speed;
void IRQ1_Handler(void) {
g_angle = read_sensor_angle();
g_speed = latest_speed; // written by IRQ2
}
void IRQ2_Handler(void) {
uint16_t angle = g_angle;
g_speed = compute_speed(angle);
}
Because the interrupts can preempt each other, I need to ensure that data written by one handler is fully visible to the other.
I’m aware that volatile forces actual memory accesses and prevents compiler caching, but I want to confirm whether a Data Memory Barrier (__DMB()) is required for hardware-level visibility between interrupts.
Questions:
1. On a single-core Cortex-M (M3/M4/M7), is a __DMB() requir