Skip to content

Instantly share code, notes, and snippets.

@holgr
holgr / weatherkit-sampleproject.py
Last active July 10, 2022 04:40 — forked from jasonsnell/weatherkit-sampleproject.py
WeatherKit API sample
#! /usr/bin/env python3
# Make sure to install the correct PyJWT, not just JWT: pip install PyJWT. See https://stackoverflow.com/questions/33198428/jwt-module-object-has-no-attribute-encode
import time
import jwt
import json
import requests
from datetime import datetime
from collections import defaultdict
@holgr
holgr / read-km002c.py
Last active August 8, 2023 13:08
Reading the API via Python3 and pyusb on macOS from a Power-Z KM002C
##
## As taken from AnandTech (just modified the idProduct for the older KM002C) at:
## https://www.anandtech.com/show/18944/usbc-power-metering-with-the-chargerlab-km003c-a-google-twinkie-alternative/3
##
## You might have to sudo python3 to make this work
##
import usb.core, usb.util, usb.control, timeit, time
dev = usb.core.find(idVendor=0x5fc9, idProduct=0x0061) # Power-Z KM002C
dev
@holgr
holgr / README.md
Last active April 23, 2024 18:33
macOS process stealing window focus

Sean Harding finally put into words an issue that I've witnessed for a while now on macOS Sonoma.

This is it: "Weird MacOS thing: the window I am working in will sometimes lose focus (without the app losing focus). Suddenly, and without any obvious cause. It will be as if no window has focus. Sometimes happens as often as every few minutes, sometimes doesn't happen for a long time. I can’t figure out any common variable. But it can be very disruptive. Has anyone else seen this? Any ideas?"

I've adjusted the Python script mentioned in the thread to work with Python 3.x that you can get with Homebrew for example.

This is what the output looks like: