Skip to content

Instantly share code, notes, and snippets.

View tmandry's full-sized avatar

Tyler Mandry tmandry

View GitHub Profile
@tmandry
tmandry / windowTracker.lua
Created December 21, 2014 08:30
Track all window open, close, move, and resize events using Hammerspoon
local events = hs.uielement.watcher
watchers = {}
function init()
appsWatcher = hs.application.watcher.new(handleGlobalAppEvent)
appsWatcher:start()
-- Watch any apps that already exist
local apps = hs.application.runningApplications()
@tmandry
tmandry / bfs.pro
Last active April 12, 2020 20:01
Prolog Breadth First Search
% Breadth-first search with a list of possible destinations (picks the closest first.)
bfs(Dests, [[Target,Path,Cost]|_], Target, Path, Cost):- member(Target, Dests).
bfs(Dests, [[N,P,C]|Queue], Target, Path, Cost):-
setof([Child,Pp,Cp], child(N, P, C, Child, Pp, Cp), Children),
append(Queue, Children, NextQueue),
bfs(Dests, NextQueue, Target, Path, Cost).
child(N0, P0, C0, N, P, C):-
arc(N0, N, Len),
append(P0, [N], P),
C is C0 + Len.
@tmandry
tmandry / dwarf-dump.txt
Created June 17, 2020 23:20
Generator variant line info
0x00000935: DW_TAG_namespace
DW_AT_name ("generator_simple")
0x0000093a: DW_TAG_namespace
DW_AT_name ("example")
0x0000093f: DW_TAG_structure_type
DW_AT_name ("generator-0")
DW_AT_byte_size (0x20)
DW_AT_alignment (8)
@tmandry
tmandry / watch_spaces.swift
Last active March 29, 2022 21:22
Getting Spaces and their order for each display
var observer: Observer!
func stuff() {
guard let database = UserDefaults.init(suiteName: "com.apple.spaces") else {
fatalError("cannot read spaces data")
}
print(String(describing: database.object(forKey: "SpacesDisplayConfiguration")))
observer = Observer(object: database)
}
class Observer: NSObject {