Skip to content

Instantly share code, notes, and snippets.

View OskarGroth's full-sized avatar

Oskar Groth OskarGroth

View GitHub Profile
@danielpunkass
danielpunkass / RSDimensionHuggingTextField.swift
Last active April 17, 2024 13:17
NSTextField subclasses that grow/shrink their width or height to fit text content
//
// RSDimensionHuggingTextField.swift
// RSUIKit
//
// Created by Daniel Jalkut on 6/13/18.
//
import Cocoa
// You probably want to use one of RSHeightHuggingTextField or RSWidthHuggingTextField, below
@frankfka
frankfka / iOSCustomSegmentedControlSwiftUI.swift
Created May 17, 2020 16:47
Custom Segmented Picker / Segmented Control in SwiftUI
import SwiftUI
extension View {
func eraseToAnyView() -> AnyView {
AnyView(self)
}
}
struct SizePreferenceKey: PreferenceKey {
typealias Value = CGSize
@izakpavel
izakpavel / AnimatablePairWithAnimatableVector.swift
Last active February 11, 2022 16:28
Mixing custom AnimatableVector in AnimatablePair
//
// Mixing custom AnimatableVector in AnimatablePair
//
// Created by Pavel Zak on 26/05/2020.
// Copyright © 2020 Pavel Zak. All rights reserved.
//
import SwiftUI
struct AnimatableVector2D: VectorArithmetic {
//
// ContentView.swift
// ComposableTest
//
import ComposableArchitecture
import SwiftUI
struct ContentView: View {
var store: Store<Main.State, Main.Action>
@sharplet
sharplet / AnyEventPublisher.swift
Last active February 17, 2024 02:18
PublisherQueue — Serialise the execution of multiple publishers like OperationQueue
import Combine
public enum AnyError: Error {
case never(Never)
case failure(Error)
}
public enum AnyEvent {
case output(Any)
case completion(Subscribers.Completion<AnyError>)
@GreyAsteroid
GreyAsteroid / StageManagerOptions.md
Last active April 2, 2024 11:53
Stage Manager Options

defaults write com.apple.WindowManager GloballyEnabled -bool [True/False] Adjusts whether Stage Manager is enabled or not.

defaults write com.apple.WindowManager AutoHide -bool [True/False] Adjusts auto hide behavior. This option controls the "Show Recent Apps" and "Hide Recent Apps" GUI option.

defaults write com.apple.WindowManager AutoHideOverlapThreshold -int [-2147483647...2147483647] Unsure what this option does. Should be noted that when AutoHide is set to False and this option is set to -17 or lower Stage Manager behaves as if AutoHide is set to True.

defaults write com.apple.WindowManager LeftStripMaximumRowCount -int [-2147483647...2147483647]

@kirb
kirb / Device.swift
Last active January 2, 2024 04:18
Get Mac device image based on device class - https://kirb.me/2023/04/15/mac-device-icon-by-device-class.html
import Cocoa
import UniformTypeIdentifiers
extension UTTagClass {
static let deviceModelCode = UTTagClass(rawValue: "com.apple.device-model-code")
}
extension UTType {
static let macBook = UTType("com.apple.mac.laptop")
static let macBookWithNotch = UTType("com.apple.mac.notched-laptop")