Random snippets of all sorts of code, mixed with a selection of help and advice.
parsing HTML table in dataframe column
11 March 2026 @ 9:15 pm
I've got a dataframe that contains a pretty simple HTML table, here's a over-simplified example
<table>
<thead>
<tr>
<th>Foo</th>
<th>bar</th>
</tr>
</thead>
<tbody>
<tr>
<td>Blah</td>
<td>More Blah</td>
</tr>
</tbody>
</table>
I'm attempting to parse this using read_html, with the idea of ultimately being able to read the foo and bar columns and adding them to the dataframe:
key
foo
bar
1
blah
more blah
I tried using pandas read_html wrapped in a UDF, but that was thoroughly unsuccessful, I think because read_html is returning a list, not a string.
How can I parse this HTML table into a dataframe?
Display problem using UnevaluatedExpr in Sympy with python
11 March 2026 @ 9:11 pm
When I add another expression to Unevaluated(), then try to print it, the unevaluated output is surrounded by ().
The problem comes when the first coefficient in the resulting expression to be displayed inside of Unevaluated is negative, it will take the first (and only first) '-' and put it in front of the whole expression in front of the ().
Note: This does not affect later computations, but it does display incorrect results since I am wanting to print the content at this stage.
I've looked around for a while and there doesn't seem to be a great solution to resolve this. (e.g. using custom string manipulation, converting to LateX then back, etc)
from sympy import symbols, simplify, UnevaluatedExpr, sstr, Eq, Add, S, latex
x, y = symbols('x y')
r1 = 0
r2 = -2
r3 = -9
uexpr = Add(S.One, UnevaluatedExpr(r1*x**3 + r2*x**2 + r3*x + 5))
print(f"Unevaluated: {uexpr}")
# Note the '-' in front of the parenthesis should not be applied to ever
Amazon Developer Account Verification [closed]
11 March 2026 @ 8:54 pm
I'm trying to gain access to our Amazon Developer Account after receiving an email on Feb 27 2026 from [email protected] informing us that "As part of our ongoing efforts to keep Amazon Appstore safe, we are requiring you to verify your identity in the Amazon Appstore developer portal." I clicked through the instructions and links which led me to a page where I was instructed to provide my face shot via webcam and my government issued id. This process failed even though the id is valid. It then directed me to call a help number. They had absolutely no idea what to do. We are now locked out because the verification with id process does not work and the phone support line does not know how to handle this. Has anyone else run into this? Thanks!
Adding default queryParams in Angular21
11 March 2026 @ 8:53 pm
Before Angular 21, it was possible to add default queryParams like this, to avoid putting them in every link in our application:
@Directive({
selector: "[myRouterLink]",
standalone: false
})
export class MyRouterLinkDirective extends RouterLink {
@Input()
set myRouterLink(commands: any[] | string | null | undefined) {
super.routerLink = commands;
}
get urlTree(): UrlTree {
const { myCustId } = this.activatedRoute.snapshot.queryParams;
const urlTree = super.urlTree;
urlTree.queryParams.myCustId = myCustId;
return urlTree;
}
}
So instead of a link being created with routerLink, I used myRouterLink throughout the application. This is useful for feature-gating features (controlling the feature-gate with a queryParam) and for multi-tenant applications (where every page has a customerId queryParam).
The code
Permanently disable the Dev Tools Button in Expo
11 March 2026 @ 8:48 pm
When starting my expo app during development, there is a circular, blue, floating button that opens the Dev Menu when clicking it. In the dev menu, there is an option to hide the "Tools button".
I find this button disturbing, is there an option to disable it permanently?
Is it possible to badfilter a filter exception?
11 March 2026 @ 8:26 pm
I am using uBlock-Origin and Firefox. There is this exception in EasyList list of filters (https://ublockorigin.pages.dev/thirdparties/easylist.txt):
@@||www.google.*/search?$xmlhttprequest,domain=google.ae|google.at|google.be|google.bg|google.by|google.ca|google.ch|google.cl|google.co.id|google.co.il|google.co.in|google.co.jp|google.co.ke|google.co.kr|google.co.nz|google.co.th|google.co.uk|google.co.ve|google.co.za|google.com|google.com.ar|google.com.au|google.com.br|google.com.co|google.com.ec|google.com.eg|google.com.hk|google.com.mx|google.com.my|google.com.pe|google.com.ph|google.com.pk|google.com.py|google.com.sa|google.com.sg|google.com.tr|google.com.tw|google.com.ua|google.com.uy|google.com.vn|google.cz|google.de|google.dk|google.dz|google.ee|google.es|google.fi|google.fr|google.gr|google.hr|google.hu|google.ie|google.it|google.lt|google.lv|google.nl|google.no|goog
python argparse bug? 'nargs' and 'action' crashes with unexpected keyword 'nargs'
11 March 2026 @ 8:14 pm
Sanity check, please.
This code:
import argparse
def parse_cmd_line():
parser = argparse.ArgumentParser( )
parser.add_argument('-c', '--create', nargs='*', action="store_true")
args, flist = parser.parse_known_args()
if __name__ == "__main__" :
parse_cmd_line()
when run as: python3 parse.py -c
generates this:
raz@WS-5N2PCV2:~/dev/tools/arc$ python3 parse.py -c
Traceback (most recent call last):
File "/home/raz/dev/tools/arc/parse.py", line 13, in <module>
parse_cmd_line()
File "/home/raz/dev/tools/arc/parse.py", line 7, in parse_cmd_line
parser.add_argument('-c', '--create', nargs='*', action="store_true")
File "/usr/lib/python3.12/argparse.py", line 1489, in add_argument
action = action_class(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^
TypeError: _StoreTrueAction.__init__() got an unexpected keyword argument 'narg
Dealing with brackets in email subject line
11 March 2026 @ 7:34 pm
I am using VBA to search for an email sent by a different department. The issue is that the email subject has brackets in it and that causes a bug in the code. Due to bureaucracy, the simplest solution of having the other department simply change their email subject syntax is blocked as they will need to update documented procedures and get managers approvals.... Is there a workaround?
I have attached my code below:
Sub checkemail()
'Searches through email folder and populates table if email found with given subject
Dim myOlApp As Object, myNameSpace As Object, myFolder As Object, myitem As Object
Dim yesterdayMail As Object
Dim rowCount As Long
On Error Resume Next
Dim folder As String
Dim subject As String
folder = "Inbox"
subject = "Test Email Subject (March XX, 20xx)"
Set myOlApp = GetObject(, "Outlook.Application")
If Err.Number = 429 Then Set myOlApp = CreateObject(
How to improve FPS when using MediaPipe hand tracking with OpenCV in Python?
11 March 2026 @ 2:57 pm
I am building a simple AI hand tracking application using MediaPipe and OpenCV in Python.
The program reads frames from a webcam, processes them with MediaPipe Hands, and draws the hand landmarks on the screen.
However, I noticed that the FPS sometimes drops to around 15–20 FPS, which makes the tracking less smooth. I would like to understand if there are ways to improve the performance when using MediaPipe with OpenCV.
My environment:
- Python 3.10
- MediaPipe
- OpenCV
Here is a simplified version of my code:
import cv2
import mediapipe as mp
mp_hands = mp.solutions.hands
hands = mp_hands.Hands()
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
results = hands.process(image)
if results.multi_hand_landmarks:
for hand_landmarks in results.multi_hand_la
How to select elements from list in random order
11 March 2026 @ 1:06 pm
Character string list contains fixed values
'I','Q','C','K','X','T','S','NE'
known in query creation time. This list should be returned in random order. Tried
select unnest( ARRAY['I','Q','C','K','X','T','S','NE'] )
order by random()
but this returns rows is same order in every run. How to change this so that list or rows appear in random order in each run?
Using Postgres 17
Update
Tried answer to update rows using
create temp table test ( test text );
insert into test values (null);
insert into test values (null);
update test set
test=
(SELECT string_agg(val,',' order by random())
FROM (
SELECT unnest(ARRAY['I','Q','C','K','X','T','S','NE']) AS val
) t
ORDER BY random())
returning test
but both rows have same value. How to get different values?