A yield example from chatgpt

def count_up_to(n): “””Generator that counts from 1 up to n.””” count = 1 while count <= n: yield count count += 1 # Using the generator for number in count_up_to(5): print(number)

22.04 save not focus bug

Workaround available for the very annoying bug (from here) Install Devilspie 2 from the standard repositories or, if you want the latest version, which has several improvements, compile from source direct from the Devilspie 2 Github. Add devilspie2 to your autostart programs. Create the file ~/.config/devilspie2/devilspie2.lua (you can use a different file name; read the instructions for details). In this…

Shower sprout leak

I got water leaking downstair when I turned on the shower. The leak is quite slow and we didn’t aware of that because we still didn’t fix the dry board water damage from years before. We have American home shield and the plumber came and requested for drilling a hole at the beginning. It was…

gpg error for dropbox

I got this frustrating errors W: http://linux.dropbox.com/ubuntu/dists/disco/Release.gpg: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details. After over an hour of googling and back and forth with gpt4, this one as below resolved it temporarily. Thanks!  This worked.   For others that run into this problem: Use a…

Unable to use fitz with python 3.8

I use pymupdf to automatically sign my document. But the package name is pymupdf even the warning is that “fitz”  is not installed. If come across an error message like import fitz File “/home/phsamuel/p3/lib/python3.10/site-packages/fitz/__init__.py”, line 1, in <module> from frontend import * File “/home/phsamuel/p3/lib/python3.10/site-packages/frontend/__init__.py”, line 1, in <module> from .events import * File “/home/phsamuel/p3/lib/python3.10/site-packages/frontend/events/__init__.py”, line…

Create trackbar example in OpenCV

I was not aware that OpenCV has a built-in slider, I usually use cvui for that. But for simple application, the built-in function is more handy import cv2 cap=cv2.VideoCapture(0) low_H=99 high_H=125 def on_low_H_thresh_trackbar(var): global low_H low_H=var def on_high_H_thresh_trackbar(var): global high_H high_H=var cv2.namedWindow(‘frame’) cv2.createTrackbar(‘Low H’,’frame’,low_H,255,on_low_H_thresh_trackbar) cv2.createTrackbar(‘High H’,’frame’,high_H,255,on_high_H_thresh_trackbar) while True: ret, frame=cap.read() color=cv2.cvtColor(frame,cv2.COLOR_BGR2HSV) frame=cv2.inRange(color,(low_H,0,0),(high_H,255,255)) cv2.imshow(‘frame’,frame) if cv2.waitKey(50)…

OpenCV and QT on 22.04

I got error Could not load the Qt platform plugin “xcb” in “” even though it was found Even following this did not solve the problem. But it seems that going headless works. That is, pip uninstall opencv-python pip install opencv-python-headless

hotkey for taking screenshots

Suddenly Ubuntu does not show the window of how to deal with a screenshot after taking one. It still was not solved. But I guess it is better to just add “Ctrl” to grab a shot.  

No bold math in latex

I got this “bug” for a long time and ignored it. Eventually it seems like coming from \renewcommand{\sfdefault}{cmss} which I am not sure where I copied from. This seems to set sans font to cmss, which probably doesn’t bold math.  

Canvas API pagination

Canvas API’s pagination is mentioned here but is not really very well-documented. For example, r.links[‘last’] may not exist. Therefore a solution as below suggested here may not work while r.links[‘current’][‘url’] != r.links[‘last’][‘url’]:    r = requests.get(r.links[‘next’][‘url’], headers=headers)    raw = r.json()    for question in raw:        data_set.append(question) Instead, I changed it a little bit…