Skip to content

Instantly share code, notes, and snippets.

@holgr
holgr / README.md
Last active August 7, 2024 01:11
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 / keybase.md
Created January 12, 2015 17:33
keybase.md

Keybase proof

I hereby claim:

  • I am holgr on github.
  • I am holgr (https://keybase.io/holgr) on keybase.
  • I have a public key whose fingerprint is 789D 9F10 91CD 523D CF3A 3436 8ADC 453D 2C25 25BD

To claim this, I am signing this object:

@holgr
holgr / Logstash-Apache-error_log-grokker
Created July 30, 2014 23:22
Apache error_log grokker for logstash
Sample:
[Tue Jul 29 21:25:13.611048 2014] [autoindex:error] [pid 30079] [client 172.16.58.1:52553] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive
Pattern:
\[(?<timestamp>%{DAY:day} %{MONTH:month} %{MONTHDAY} %{TIME} %{YEAR})\] \[%{WORD:module}:%{WORD:errorlevel}\] \[pid %{POSINT:pid}\] \[client %{IPORHOST:http_clientip}:%{POSINT:clientport}\] %{GREEDYDATA:message_remainder}
@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