Skip to content

Instantly share code, notes, and snippets.

View asmallteapot's full-sized avatar
😴
😴

Ellen Teapot asmallteapot

😴
😴
View GitHub Profile
@ole
ole / HeterogeneousDictionary.swift
Last active May 17, 2023 19:23
Code for my article "A heterogeneous dictionary with strong types in Swift" https://oleb.net/2022/heterogeneous-dictionary/
// A heterogeneous dictionary with strong types in Swift, https://oleb.net/2022/heterogeneous-dictionary/
// Ole Begemann, April 2022
/// A key in a `HeterogeneousDictionary`.
public protocol HeterogeneousDictionaryKey {
/// The "namespace" the key belongs to. Every `HeterogeneousDictionary` has its associated domain,
/// and only keys belonging to that domain can be stored in the dictionary.
associatedtype Domain
/// The type of the values that can be stored under this key in the dictionary.
associatedtype Value
@Clarko
Clarko / RemovableKeyboardShortcut.swift
Last active March 28, 2023 18:43
SwiftUI suppressible keyboard shortcuts
//
// RemovableKeyboardShortcut.swift
//
// Created by Clarko on 2/2/21.
//
// Adds an argument to dynamically remove a keyboard shortcut
//
import SwiftUI
@jordansinger
jordansinger / iPod.swift
Created July 27, 2020 21:19
Swift Playgrounds iPod Classic
import SwiftUI
import PlaygroundSupport
struct iPod: View {
var body: some View {
VStack(spacing: 40) {
Screen()
ClickWheel()
Spacer()
}
@steventroughtonsmith
steventroughtonsmith / PSTLDraggableColorSwatchView.h
Last active May 6, 2021 00:47
Color Swatch view for Mac Catalyst that implements inter-app drag & drop
//
// PSTLDraggableColorSwatchView.h
// Pastel
//
// Created by Steven Troughton-Smith on 06/03/2020.
// Copyright © 2020 Steven Troughton-Smith. All rights reserved.
//
@import UIKit;
@danielmartin
danielmartin / XcodeNewBuildSystemSettings.json
Created February 23, 2020 14:37
Complete list of Xcode new build system settings and their documentation in JSON format.
This file has been truncated, but you can view the full file.
[
{
"spec": "com.apple.compilers.metal",
"path": "/Applications/Xcode.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/Metal.xcplugin/Contents/Resources/Metal Compiler.xcspec",
"options": [
{
"name": "CLANG_DIAGNOSTICS_FILE"
},
{
"name": "MTLCOMPILER_DEPENDENCY_INFO_FILE"
protocol KeyPathUpdatable {}
extension KeyPathUpdatable {
func updating<LeafType>(_ keyPath: WritableKeyPath<Self, LeafType>, to value: LeafType) -> Self {
var copy = self
copy[keyPath: keyPath] = value
return copy
}
}
@douglashill
douglashill / KeyboardScrollView.swift
Last active May 6, 2021 00:47
A UIScrollView subclass that allows scrolling using a hardware keyboard like NSScrollView. Supports arrow keys, option + arrow keys, command + arrow keys, space bar, page up, page down, home and end.
// Douglas Hill, November 2019
// Find the latest version of this file at https://github.com/douglashill/KeyboardKit
import UIKit
/// A scroll view that allows scrolling using a hardware keyboard like `NSScrollView`.
/// Supports arrow keys, option + arrow keys, command + arrow keys, space bar, page up, page down, home and end.
/// Limitations:
/// - Paging scroll views (isPagingEnabled = true) are not supported yet.
/// - The scroll view must become its own delegate so setting the delegate is not supported yet.
@danielmartin
danielmartin / BetterXcodeJumpToCounterpartSwift.org
Last active March 9, 2024 02:00
Add support for a better Xcode's Jump to Next Counterpart in Swift

If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).

You can do this in recent versions of Xcode by setting a configuration default.

From a terminal, just type this command and press Enter:

defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"
@kingreza
kingreza / PokerEngine.swift
Last active May 26, 2020 17:21
A simple poker engine that deals cards and detects various hands.
//
// main.swift
// PokerTest
//
// Created by Reza Shirazian on 11/8/19.
// Copyright © 2019 Reza Shirazian. All rights reserved.
//
import Foundation
@steventroughtonsmith
steventroughtonsmith / Info.plist
Created October 27, 2019 17:02
[Catalyst] Registering for & responding to AppleScript events in a Mac Catalyst app
<key>NSAppleScriptEnabled</key>
<true/>
<key>OSAScriptingDefinition</key>
<string>ScriptableTasks.sdef</string>