Skip to content

Instantly share code, notes, and snippets.

@GeekAndDad
GeekAndDad / SafariOpenTabs.scpt
Created May 24, 2022 03:48
*how* many tabs do I have open in Safari? (macOS)
local countOfWindows
local countOfTabs
tell application "Safari"
set countOfWindows to count of windows
set countOfTabs to 0
repeat with n from 1 to countOfWindows
set countOfTabs to countOfTabs + (count of tabs in window n)
end repeat
@GeekAndDad
GeekAndDad / myplayground.swift
Created August 29, 2022 19:54
Sample of drawing into a bitmap
import Cocoa
print( NSImageRep.registeredClasses ) // -> [NSPDFImageRep, NSPICTImageRep, NSEPSImageRep, NSBitmapImageRep]
func test() {
guard let rep = NSBitmapImageRep(bitmapDataPlanes: nil,
pixelsWide: 256,
pixelsHigh: 256,
bitsPerSample: 8,
samplesPerPixel: 4,
@GeekAndDad
GeekAndDad / TestMapCVS.swift
Last active August 15, 2023 08:20
A sketch of a possible approach to mapping a CurrentValueSubject<A,Never> to a CurrentValueSubject<B,Never>. Likely can be simplified and cleaned up, but seems to work...
import XCTest
import Cocoa
import Combine
final public class MappedCurrentValueSubject<A, B, Failure, S: CurrentValueSubject<A, Failure>> : Subject
where Failure == S.Failure
{
public typealias Output = B
@GeekAndDad
GeekAndDad / three_circles.scad
Last active January 6, 2025 19:23
An answer to "distribute 3 circles evenly inside another" for OpenSCAD for Pete.
// For Pete
// v3.0.2
// by @GeekAndDad
// Define the outer circle radius and desired inner circle radius
outer_circle_radius = 100;
desired_inner_radius = 20;
// Call our function to calulate the centers of the three evenly spaced circles
// and
#!/bin/sh
SRC1=$HOME/Library/Safari
SRC2=$HOME/Library/Containers/com.apple.Safari/Data/Library/Safari
HOST=$( hostname | sed 's/\..*//' )
HOUR=$( date +"%H" )
DST=$HOME/Sync/Safari/$HOST/$HOUR
mkdir -p $DST 2>/dev/null
cd $SRC1
@GeekAndDad
GeekAndDad / disable-acs-popups-iwork.sh
Created May 28, 2026 18:51 — forked from Terabyte1385/disable-acs-popups-iwork.sh
Disable Apple Creator Studio update popup in iWork (Keynote, Pages, Numbers)
defaults write com.apple.iWork.Pages TSADisableUpdateNotifications -bool yes
defaults write com.apple.iWork.Keynote TSADisableUpdateNotifications -bool yes
defaults write com.apple.iWork.Numbers TSADisableUpdateNotifications -bool yes