Random snippets of all sorts of code, mixed with a selection of help and advice.
Normalizing inconsistent Amazon product price fields from a third-party API response
2 June 2026 @ 12:12 am
I'm building a price tracking service that pulls Amazon product data through a real time data API (easyparser.com) and stores the results in PostgreSQL. The data pipeline works fine overall but I'm running into a normalization problem with the price fields.
The API returns price data in a few different shapes depending on the product type:
// Simple product
{ "price": { "current": 29.99, "currency": "USD" } }
// Product with active deal
{ "price": { "current": 21.99, "was": 29.99, "currency": "USD" } }
// Marketplace / third-party seller
{ "price": null, "offers": [{ "price": 18.50, "seller": "XYZ Store", "condition": "new" }] }
// Out of stock
{ "price": { "current": null, "currency": "USD" } }
My current normalization function tries to handle
Pandas rolling window lack of understanding
1 June 2026 @ 11:36 pm
I searched how to use the rolling function from Pandas, but struggle using it.
Let's take a simple example : let be the list [0, 1, 2, ... , 15], make it a Pandas serie.
df = pd.Series(range(16))
I want to obtain the sum of the first four elements, then the sum of the next four, until reaching the last element, i.e. [6, 22, 38, 54].
I tried this:
df.rolling(4, step=4, closed="both").sum()
This returns me:
0 NaN
4 10.0
8 30.0
12 50.0
(it seems to start at 3 and stop at 12 , which is not what is expected...). Tweaking the parameters doesn't help as far as I tried. At "best", I got
0 NaN
4 6.0
8 22.0
How do I use useRef as input in a function with typescript
1 June 2026 @ 11:14 pm
I am trying to make an automatic scrpreference in production environments and its ability to catch issues earlier on. The olling utility for my React website, I have chosen typescript due to what I have heard about its problem however, surely due to my inexperience, is that I have no idea what type to put on my ref element in the scrollToSection()function. No article I found covered this exact us case, for instace nulldog and x. xjavascript
function Navbar() {
const section1 = useRef<HTMLElement>(null)
const section2 = useRef<HTMLElement>(null)
const section3 = useRef<HTMLElement>(null)
const section4 = useRef<HTMLElement>(null)
const scrollToSection = ( ref ) => {
ref.current?.scro
How can I get reference to child controls of XRC-loaded object hierarchy in wxErlang?
1 June 2026 @ 11:11 pm
I'm new to Erlang, wxWidgets,and wxErlang. I've got an example running which will load a wxFrame from an xrc file and show the frame with all of its child panels/controls/etc.. How to I get references to those child objects to connect their command messages to handler functions?
I'm able to create everything manually with constructors and such, but don't know how to get at the child objects in an object hierarchy loaded from an xrc file.
Slimmed-down start of code:
-module(xt4).
-export([start/0]).
-include_lib("wx/include/wx.hrl").
start() ->
wx:new(),
WxXmlResource = wxXmlResource:new(),
wxXmlResource:load(WxXmlResource, "TryMyLayout1.xrc"),
MyXrcFrame = wxXmlResource:loadFrame(WxXmlResource, wx:null(), "ID_MAINFRAME"),
wxFrame:show(MyXrcFrame),
...
handle_click_dlg(#wx{userData = #{frame := Frame, env := Env}}, _Event) ->
wx:set_env(Env),
MsgDlg = wxMessageDialog:new(Frame, "Insi
Call graph generation
1 June 2026 @ 9:47 pm
I'm maintaining an unfamiliar codebase and I'd like a chart of what method calls what. Something that penetrates interface abstractions.
If the output was a mermaid diagram that would be lovely but even a text listing of "this calls this" would be helpful.
Where can I find the reference source for ISerializationSurrogateProvider and DataContractSerializerExtensions in .NET Framework 4.8?
1 June 2026 @ 6:40 pm
I am looking for Microsoft's reference source for the types DataContractSerializerExtensions and ISerializationSurrogateProvider in .NET Framework 4.8.1. The reference source in .NET Framework 4.8 or 4.7.2 or 4.7.1 would also be acceptable.
These types were introduced in .NET Standard / .NET Core 3.1 as replacements for the data contract surrogate functionality provided by
Conditional sub-flows not respecting user attribute condition
1 June 2026 @ 6:36 pm
I’m building a multi-MFA flow in Keycloak 26.5.1 where users can be assigned one of three MFA methods: SMS, Email OTP, or TOTP. The method is stored as a user attribute mfa_option with values SMS, Email, or TOTP.
Current flow structure:
MFA Selection Sub-flow (Required/Alternative — tested both)
SMS FLOW (Conditional) — condition: mfa_option = SMS
EMAIL FLOW (Conditional) — condition: mfa_option = Email
TOTP FLOW (Conditional) — condition: mfa_option = TOTP
Behavior per MFA method:
TOTP → works correctly, QR code appears as expected
SMS → after username/password, page just refreshes and restarts login with no error
Email → throws "C
Local HTML file embed youtube with <iframe>
31 May 2026 @ 2:51 am
I have a created a test website at infinityfree and uploaded a test file to display a Youtube video in an <iframe\>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Local Video Embed Test</title>
</head>
<body>
<h1>My Local Web Page</h1>
<!-- Paste your copied YouTube iframe code here -->
<iframe width="560" height="315"
src="https://www.youtube.com/embed/1IxxwvR6qSA?si=GjL_9UnP4EtQJTHs"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerpolicy="strict-origin-when-cross-origin"
allowfullscreen>
</iframe>
</body>
</html>
this works as expected. The problem occurs when I click on this as a local file on my deskto
Tracking visited nodes when traversing datastructure
30 May 2026 @ 4:04 pm
I am new to Python, reading the book "Learning Python" by Mark Lutz, https://learning-python.com/about-lp6e.html.
It mentions avoiding cycles (or repeat visits) when traversing structured data, eg nested structures or graphs or similar ("Beware of Cyclic Data Structures" at end of Ch 9). It suggests using a list/dictionary/set of already visited items.
Clear enough. Set seems suitable. However if the data structure is composed of various mutable objects, these cannot be added in a Set, as python sets only take immutable (or perhaps hashable) objects, i.e. this pseudocode would not work:
if node not in visited:
visited.append(node)
process(node)
What is a good way to do this, in python style? Some ideas:
1: Use a set to track id(obj) rather than object references themselves. However my impression is that id() is kind
Why does this vb script not do what I am expecting it to do?
30 May 2026 @ 4:02 pm
I wrote this simple script to open the app mentioned and then close it using Alt+F4. (The app is set to minimise to the system tray when closed). I added the sleep command (and made it longer too) - wasn't sure (and am still not) if it was needed (to delay the Alt+F4 until the Oculus app window was open on my desktop. Maybe pointless??
Set app = CreateObject("Shell.Application")
app.ShellExecute "C:\Program Files\Meta Horizon\Support\oculus-client\OculusClient.exe", , , "runas"
Set WshShell = WScript.CreateObject("WScript.Shell")
Wscript.Sleep 500
WshShell.SendKeys "%{F4}"
Well, the app opens and there are no error messages, but the Alt+F4 part does nothing - the app window remains open on my PC screen. If I press Alt+F4 on my keyboard, then the app goes to the tray. But I can't see why the script isn't doing this. What do I need to change here please?
Many thanks for any comments! :-)
(