This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum ConnectionError: Error { | |
case fakeWork | |
case close | |
case connect | |
} | |
struct Connection { | |
func close(fail: Bool = false) throws { | |
if fail { | |
print("throwing during close connection ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Parsing | |
/// simple test. | |
/// First char must exist and must be a char from a to z | |
/// Followed by zero or more characters from a to z or 0 to 9 | |
/// Must end with a space or be the end of input | |
/// | |
let validFirstChars = CharacterSet(charactersIn: "a"..."z") | |
let validFollowingChars = CharacterSet(charactersIn: "0"..."9").union(validFirstChars) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Advanced SwiftUI Transitions | |
// https://swiftui-lab.com | |
// https://swiftui-lab.com/advanced-transitions | |
import SwiftUI | |
struct GeometryEffectTransitionsDemo: View { | |
@State private var show = false | |
var body: some View { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- AppleScript I wrote to eject mounted USB disks before I disconnect my USB-C hub. | |
-- Notes: | |
-- this will halt a time machine backup to a locally mounted | |
-- drive when it tries to eject it. | |
-- will also halt a time machine backup to a network destination. | |
-- tested in macOS 11.6 (2021.11.19) | |
-- License: MIT | |
tell application "System Events" | |
set ds to get disks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Put in the public domain with zero warranty of any kind | |
-- | |
-- only tested on macOS 11.6, with Safari 13.0; ymmv | |
use scripting additions | |
tell application "Safari" | |
set windlist to windows | |
log "Examining " & length of windlist & " windows..." |
NewerOlder