Skip to content

Instantly share code, notes, and snippets.

@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:

@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 / 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 / iterm-cursor-settings.md
Last active May 22, 2018 01:20
iTerm2 on Mac OSX: add alt-left, alt-right and alt-backspace behaviour

#GoPro HERO4 Black Wifi Hacking, ep 2

By Maelstrom Napalm, @odwdinc and Konrad Iturbe

###Status URL:

http://10.5.5.9/gp/gpControl/status

####Protune EV compensation: Value | URL

@holgr
holgr / FCPrivateBatteryStatus.m
Created January 30, 2016 00:16
How to get raw battery info (mAh remaining, etc.) from iOS using private APIs. For internal testing only, NOT APP STORE DISTRIBUTION!
#import <Foundation/Foundation.h>
#include <dlfcn.h>
NSDictionary *FCPrivateBatteryStatus()
{
static mach_port_t *s_kIOMasterPortDefault;
static kern_return_t (*s_IORegistryEntryCreateCFProperties)(mach_port_t entry, CFMutableDictionaryRef *properties, CFAllocatorRef allocator, UInt32 options);
static mach_port_t (*s_IOServiceGetMatchingService)(mach_port_t masterPort, CFDictionaryRef matching CF_RELEASES_ARGUMENT);
static CFMutableDictionaryRef (*s_IOServiceMatching)(const char *name);
@holgr
holgr / gist:4540665
Created January 15, 2013 18:16
Determine LG or Samsung display on 15" rMBP
ioreg -lw0 | grep \"EDID\" | sed "/[^<]*</s///" | xxd -p -r | strings -6
@holgr
holgr / giga-no-comments-related-videos.user.js
Created July 30, 2012 01:00
GIGA.DE comment and video box remover
#!/bin/bash
while true; do
if curl -silent -A "iMacAppStore/1.0.1 (Macintosh; U; Intel Mac OS X 10.6.7; en) AppleWebKit/533.20.25" 'http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewGrouping?id=29526&mt=12' | grep -i "mountain lion" ; then
echo "Available"
growlnotify -m "Mountain Lion is available" -t "App Store"
break
else
echo "Nada"
fi
sleep 120
@holgr
holgr / latitudedumper.py
Created July 13, 2011 21:46 — forked from mdornseif/latitudedumper.py
Moving Google Latitude Data from one user to an other
# Google latitude backup
#
# This is a little helper to backup your location from Google Latitude to local disk.
# It saves data as JSON and as GPX.
# Usage is somewhat annoying:
#
# 1. get OACurl http://code.google.com/p/oacurl/
# 2. follow the steps in http://code.google.com/apis/latitude/oacurl.html to get strarted
# You will have to register a domain with Google Apps and jump through hoops
# 3. Renerate a Key and a Secret for "installed applications" on the google API console,