Random snippets of all sorts of code, mixed with a selection of help and advice.
How to build a logic to solve any python coding questions?
29 April 2026 @ 1:43 am
Questions like:
How to reverse a string without slicing?
# Write Python code to reverse a string without using slicing
# string("DataScience")) # Output: ecneicSataD
Write a Python code which takes a string as an input and prints True if the string is valid identifier else returns False.
#Sample Input:- 'abc', 'abc1', 'ab1c', '1abc', 'abc$', '_abc', 'if'
Flatten nested dictonary
# Inputdict = {'a' : {'b' : {'c' : 9}}} # Out: {'a.b.c' : 9}
Find the second largest number/element from the list using for loop # a = [3,7,2,1,9,4]
sum of first 15 odd natural numbers using loop
grdctl rdp disable-view-only gives ERROR][com.freerdp.crypto] - [x509_utils_from_pem]: BIO_new failed for certificate RDP server certificate is invali
29 April 2026 @ 1:28 am
while trying to configure, connect and use Ubuntu 24.04 Desktop (default GNOME)
from macOS
# 3. Configure RDP credentials and enable the service
# 'grdctl' is the control utility for GNOME Remote Desktop
grdctl rdp set-credentials "$REMOTE_USER" "$REMOTE_PASS"
grdctl rdp enable
grdctl rdp disable-view-only # This allows you to interact with the desktop
Executing
grdctl rdp disable-view-only
I get
[23:05:29:593] [3211:00000c8b] [ERROR][com.freerdp.crypto] - [x509_utils_from_pem]: BIO_new failed for certificate
RDP server certificate is invalid.
How to avoid "Close" button on Windows notification via Electron
29 April 2026 @ 1:03 am
I know Windows OS notifications can exclude these buttons but how is a mystery to me. Virtually every Windows notification I've ever seen does NOT have any such button but I'm lost on how to make that the case with Electron.
Best method for loading a new page based on the value of an API response: Call API before or after landing
29 April 2026 @ 12:57 am
for some background we are in Angular 20 & using a java-based server for the API.
The client has a use case where they will view a table of URLs matched with data about (an) entity. When they click the url it will open a new tab and populate the page with the full data about the entity (17 fields, one JSON Object that represents a table of data).
To do this an API needs to be called and passed four parameters (present in the table record that was clicked). We will then use 17 primitive variables and one JSON object(returned in the API) to populate the page.
The question is, what is the best way to populate the data on the page? My approach was to call the API on the previous page and pass all of the data as query params to the new page. The other approach is to pass only those four variables, call the API from the new page, and set the values. The second option introduces latency which causes issues rendering the page. Basically, there is logic being done to
How to copy files in Windows while preserving their dates?
29 April 2026 @ 12:49 am
I'd like to copy files and directories while preserving all their attributes, so I use CopyFileEx and CreateDirectoryEx, but they don't preserve file times, so I need to get the file handle and call SetFileTime on it.
CopyFileEx passes the destination file handle through a callback, so I can SetFileTime there, but the documentation doesn't say if the callback is guaranteed to be invoked. Preferably I'd set the file times at the end of the copy, but the callback doesn't indicate if it's the last, so I'm left with setting them on the first invocation. But if CopyFileEx subsequently writes more data, wouldn't the last write time be overwritten? (I tried on small files and all three file times are preserved).
CreateDirectoryEx doesn't provide access to the destination directory handle at all. While I can open it right after the call, that's a race condition and seems a little silly when CreateDirectoryEx already has it open.
A similar problem arises when the destina
How to redirect output text to a separate window in Python?
29 April 2026 @ 12:12 am
I am very, very new to programming having just finished a semester-long course on Python. I wanted to take an existing program I had written for my class and redirect all the output text to a separate window instead of the program terminal. I followed a tutorial (https://www.py4u.org/blog/python-tkinter-make-any-output-appear-in-a-text-box-on-gui-not-in-the-shell/), but I'm having issues with actually getting the output text to the created window. Both programs run fine separately, but just aren't connected.
I was thinking the issue was that my original program involves user input, thus when running the full program, the original program must complete first in the terminal and then the window will open (still blank).
This is the code I had written while following the tutorial linked above:
import tkinter as tk
fro
Git branching workflow with regular commits to staging and production
29 April 2026 @ 12:11 am
I have Dev, Stage and Prod branches but due to my tools, I have to commit configurations onto Stage and Prod when deploying.
Dev --> Staging (Jan 1st)
Staging <-- release branch
Staging --> Prod
Prod <-- release branch
Prod --> Dev
After that cycle I begin having all kinds of git conflicts and even when resolved, git keeps trying to replay the entire history starting on Jan 1st history. I've tried rebasing and still have issues. What am I missing here?
Thanks!
Always appear in my packaege.json. "packageManager": "[email protected]+sha512..." how to get rid?
28 April 2026 @ 11:10 pm
I am unable to remove from my Angular v21 app's package.json the below Row:
"packageManager": "[email protected]+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319"
I using node 24.0.0 and pnpm 10.33.0
I tried more variations, I used any of them, then deleted them, and they were automatically restored.
pnpm config set managePackageManagerVersions false
pnpm config get managePackageManagerVersions
pnpm config set manage-package-manager-versions false
managePackageManagerVersions: false
COREPACK_ENABLE_AUTO_PIN=0
export COREPACK_ENABLE_AUTO_PIN=0
How do I get rid of the below row from my package.json?
I used any of them, then deleted them and they were automatically restored.
Printing page without dialog box printer
28 April 2026 @ 10:56 pm
I have one page that call the page for printing.
But the problem is I need to go directly on printing page process without opening the dialog box print preview. After printing out page close.
Someone can resolv it in PHP with Javascript.
<script type="text/javascript">
function PrintPage() {
window.print();
}
window.addEventListener('DOMContentLoaded', (event) => {
PrintPage()
setTimeout(function(){ window.close() },750)
});
</script>
Go SNMP library. What do You actualy need? I made my own library and ready to interact with users
28 April 2026 @ 10:45 pm
I made go SNMP v3 library which have few anvantage over gosnmp.
Divide errors for fatal and partial
Correct processing report messages
Trap/Inform receiver can receive messages with different SNMP v3 parameters (User/Protocols/Keys)
and many more...
You can use any AI for compare it or try to comile examples.
But may be You need extra features?
Project on github: https://github.com/OlegPowerC/powersnmpv3/