Skip to content

Instantly share code, notes, and snippets.

View jayrhynas's full-sized avatar

Jayson Rhynas jayrhynas

View GitHub Profile
enum Planet: Int {
case mercury, venus, earth, mars, jupiter, saturn, uranus, neptune
// case pluto
static var gasGiants: Set<Planet> = [.jupiter, .saturn]
}
let planet: Planet = .jupiter
if Planet.gasGiants.contains(planet) {
enum Planet: Int {
case mercury, venus, earth, mars, jupiter, saturn, uranus, neptune
}
struct PlanetOptions {
let planets: Set<Planet>
private init(_ planets: Set<Planet>) {
self.planets = planets
}
class PassthroughContainer: UIView {
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
guard super.point(inside: point, with: event) else {
return false
}
for subview in self.subviews where subview.isUserInteractionEnabled {
let subPoint = self.convert(point, to: subview)
if subview.point(inside: subPoint, with: event) {
return true
protocol EditorViewController {
associatedtype Item: EditableItem
var item: Item? { get set }
}
protocol EditableItem {
associatedtype Editor: EditorViewController & NSViewController
static var editorSceneId: NSStoryboard.SceneIdentifier { get }
}
@jayrhynas
jayrhynas / keypath-sort.swift
Last active August 28, 2018 16:10
Sort By KeyPath
import Foundation
// MARK: - Basic Implementation
struct SortDescriptor<Element> {
let compare: (Element, Element) -> ComparisonResult
}
private func compare<Element>(_ lhs: Element, _ rhs: Element, _ descriptors: [SortDescriptor<Element>]) -> Bool {
for descriptor in descriptors {
git config --global diff.json.textconv "f() { cat \"${1}\" | jq --sort-keys .; }; f"
//
// ViewController.swift
// ModalTest2
//
// Created by Jayson Rhynas on 2018-11-21.
// Copyright © 2018 Jayson Rhynas. All rights reserved.
//
import UIKit
/////////////////
// MyFramework //
/////////////////
// Instrument.swift
@objc public class Instrument: NSManagedObject {
}
#0 0x0000000103dd5c80 in swift_checkMetadataState ()
#1 0x0000000103da16bc in type metadata completion function for ClosedRange<>.Index ()
#2 0x0000000103dd8e24 in swift::MetadataCacheEntryBase<(anonymous namespace)::GenericCacheEntry, void const*>::doInitialization(swift::ConcurrencyControl&, swift::MetadataCompletionQueueEntry*, swift::MetadataRequest) ()
#3 0x0000000103dd0168 in swift_getGenericMetadata ()
#4 0x0000000103c505f8 in type metadata accessor for Optional ()
#5 0x0000000101286afc in BaseMappable.init(JSONString:context:) ()
#6 0x000000010156926c in LoopAudioUser.init(metadata:song:) at /Users/jayson/Developer/Medly/Medly/Loop/LoopAudioUser.swift:71
$HOME/.config/git/attributes:
*.json diff=json
$HOME/.gitconfig:
[diff "json"]
textconv = "f() { cat \"${1}\" | jq --sort-keys .; }; f"