Random snippets of all sorts of code, mixed with a selection of help and advice.
Accessing source code from importlib module [duplicate]
17 May 2026 @ 3:14 pm
Please note that this is not the same as the previous question Using importlib is it possible to modify the incoming source code as, thanks to inspect we now know that the importlib module does actually contain the text of the source code. It is now just a question of how to access that.
I notice that the source code from an importlib module can be read using inspect module. However is there an alternative way of accessing this code so that it can be modified? Presumably inspect.getsource must have some method of finding this.
import inspect
import importlib
spec = importlib.util.spec_from_file_location(module_name, source_path)
module = importlib.util.module_from_spec(spec)
print(inspect.getsource(module))
Halting condition in recursion java
17 May 2026 @ 3:06 pm
public class Main {
public static int sum(int start, int end) {
if (end > start) {
return end + sum(start, end - 1);
} else {
return end;
}
}
public static void main(String[] args) {
int result = sum(1, 10);
System.out.println(result);
}
}
Can somebody help me with this? I'm genuinely getting confused here specially in a return end + sum(start, end - 1);
Adjust ttk.Treeview column width to fit its contents and make horizontal scrolling viable
17 May 2026 @ 3:06 pm
import tkinter as tk
import tkinter.ttk
root = tk.Tk()
root.geometry("400x300")
frame = tk.Frame(root)
frame.pack(fill="both", expand=True)
vertical_scrollbar = tk.Scrollbar(frame, orient="vertical")
vertical_scrollbar.pack(side="right", fill="y")
horizontal_scrollbar = tk.Scrollbar(frame, orient="horizontal")
horizontal_scrollbar.pack(side="bottom", fill="x")
horizontal_scrollbar.update()
vertical_scrollbar.pack_configure(pady=(0, horizontal_scrollbar.winfo_height()))
treeview = tk.ttk.Treeview(frame, show="tree")
treeview.pack(fill="both", expand=True)
treeview.column("#0", stretch=True)
# treeview.column("#0", stretch=False, width=800)
# treeview.column("#0", stretch=False, width=2000)
treeview.configure(yscrollcommand=vertical_scrollbar.set)
treeview.configure(xscrollcommand=horizontal_scrollbar.set)
v
How to restrict Microsoft Entra ID / Intune enrollment to one device per user?
17 May 2026 @ 3:04 pm
I am designing a deployment for a client with ~230 users transitioning into Microsoft Entra ID and Microsoft Intune.
The Requirement:
1. Standard Users:Must be strictly limited to enrolling exactly one PC and one Mobile phone.
2. Exception Users:A small subset of users need the ability to register two personal devices.
3. Shared PC Scenario:Some users share a single corporate email identity but log into different physical desktop PCs and separate mobile devices.
Questions:
1. What is the best architectural approach in Intune/Entra to enforce a 1-PC limit for standard users while excluding a specific group of power users?
2. How should we handle the enrollment of the physical PCs used by the "shared email ID" users so they don't exhaust the individual identity quota?
3. Can this boundary be securely enforced via Conditional Access policies without blocking mobile device enrollment?
Any guidance on policy design
Why does Bash substring slicing on BASH_REMATCH corrupt UTF-8 text in a Systemd service but work perfectly in the terminal? [duplicate]
17 May 2026 @ 3:02 pm
I am running a Bash script that parses a log file, extracts a specific localized string using native regex matching ([[ $line =~ $pattern ]]), and then truncates the result to a maximum of 15 characters using Bash substring syntax (${BASH_REMATCH[1]:0:15}) before sending it to a webhook.
When I run this script manually in my interactive terminal (Ubuntu 24.04, Bash 5.2), it works flawlessly. Multi-byte characters (like German umlauts or emojis) are counted as single characters, and the truncation cuts the string cleanly.
However, when the exact same script is executed as a background Systemd service, it randomly corrupts the trailing characters of the truncated string, resulting in invalid UTF-8 sequences (like Müll) that crash my downstream API parser.
The Script (parse_logs.sh)
#!/usr/bin/env bash
# Simulated log line with a multi-byte character (ü)
line=&qu
What is the difference between Collection and TimeSeries containers in GridDB and when should each be used?
17 May 2026 @ 2:42 pm
I am working with GridDB and noticed there are different container types such as Collection and TimeSeries.
From the documentation, both appear to store records, but I am unclear about:
Main differences between Collection and TimeSeries containers
Performance considerations
Query behavior
Recommended use cases
For example:
User/customer records
IoT sensor data
Log/event storage
When should I choose a Collection container versus a TimeSeries container in GridDB?
How do I create a TimeSeries container and insert timestamped records in GridDB using Java?
17 May 2026 @ 2:41 pm
I am learning GridDB and trying to store time-series data using the Java API.
I want to:
Connect to GridDB
Create a TimeSeries container
Insert records with timestamps
Retrieve the stored data later
Example data:
Timestamp Temperature
2026-05-17 10:00:00 32.5
2026-05-17 11:00:00 33.1
I am unsure about the correct container definition and insertion process using the Java client.
What is the recommended way to create a TimeSeries container and insert timestamped rows in GridDB using Java?
Why can't I put my div in a div even if it works on different html files? [closed]
17 May 2026 @ 2:03 pm
I'm creating a personal website and I want to put a div in a div, but for some reason, it doesn't work.
I created a different html file to test if it would appear if it wasn't for the outside div, and it worked normally.
This is my CSS and markup:
.background-cover {
width: 900px;
height: 600px;
background-image: url('main.jpg');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
border: 12px solid;
border-image: url("border.png") 11 fill round;
margin: auto
.div {
height: 600px;
width: 120px;
background-image: url('idk.jpg');
I would like help regarding a html artifact
17 May 2026 @ 2:02 pm
So l wanted to create an interactive artifact with claude and l asked it(since l don't have any knowledge of code)to create a html document that l can fully edit and save.Long story short it created one though l mistakenly assumed that it had also made it to have an auto save feature but it had only just the export option.I accepted it as l thought claude couldn't propably put an auto save feature and so l continued with creating the artifact as l wanted it.I started making one by one all the changes and edits l wanted in the artifact and add new things for a concept that l hadn't yet told claude about them(it was already made by the claude l just started to adjusted it more as to how l would want it and so l started to make the changes and edits and adding some other things which weren't told yet to claude)l had make by that point some important changes,added details and l had made long texts of those changes.
After about a day l went to the artifact window to continue the c
Shiny app - A conditional selectInput with renderUI persists despite condition no longer being met
17 May 2026 @ 12:39 pm
I am making a Shiny-app, with multiple selectInput's and one that is conditional on the choice picked in the others. A "dummy" version of the app:
# Packages and data: ----
library(shiny)
library(bslib)
samlet_liste <-
list(
"termin1" = list("variant1" = list("model1" = "1", "model2" = "2", "model3" = "3"),
"variant2" = list("model1" = "1", "model2" = "2", "model3" = "3")),
"termin2" = list("variant1" = list("model1" = "1", "model2" = "2", "model3" = "3"),
"variant2" = list("model1" = "1", "model2" = "2", "model3" = "3"))
)
# UI: ----
ui <- fluidPage(
theme = bs_t