{{ message }}

Instantly share code, notes, and snippets.

Wondering why anyone puts up with me

# Rob Bishop SaganRitual

Wondering why anyone puts up with me
• Chico, CA
Created Mar 25, 2019
Arithmetic and conversions for CGPoint, CGSize, and CGVector. These make the code much more readable and writable, at least for me.
 import CoreGraphics /// Arithmetic extensions for CGPoint, CGSize, and CGVector. /// All of the operators +, -, *, /, and unary minus are supported. Where /// applicable, operators can be applied to point/size/vector + point/size/vector, /// as well as point/size/vector + CGFloat and CGFloat + point/size/vector. protocol Overload2D { /// Really for internal use, but publicly available so the unit tests can use them. var a: CGFloat { get set } var b: CGFloat { get set }
Created Mar 13, 2019
I'm not a bad person. Why must the universe punish me so with Swift generics?
 struct ProtoOrder { var quantity: T init(_ quantity: T) { self.quantity = quantity } } protocol ItemProtocol { associatedtype HowCounted: Numeric typealias Order = ProtoOrder
Created Feb 22, 2019
View SKNodeSkalingProblem.swift
 import SpriteKit import GameplayKit class GameScene: SKScene { static var shared: GameScene? var frameCount = 0 var bigSprite: SKSpriteNode? var bigSpriteIsSetup = false var spriteTexture: SKTexture?
Created Feb 4, 2019
SpriteKit starter, draw grid, detect touches on sprites, cause neighboring sprites to react
View Box.swift
 import Foundation import SpriteKit class Box { let sprite: SKShapeNode let cellAddress: XYPair var position: CGPoint { get { return sprite.position } set { sprite.position = newValue }
Created Jan 29, 2019
Another SpriteKit starter, some examples of how to use physics and actions
View Box.swift
 import Foundation import SpriteKit func getColorName(_ color: NSColor) -> String { switch color { case .black: return "black" case .white: return "white" case .gray: return "gray" case .red: return "red" case .green: return "green"
Created Jan 29, 2019
In case it helps anyone, a SpriteKit starter with physics turned on and a couple of sprites demonstrating collision detection
View GameScene.swift
 import SpriteKit import GameplayKit class GameScene: SKScene { var box1: SKShapeNode? var box2: SKShapeNode? override func didMove(to view: SKView) { let b1 = SKShapeNode(circleOfRadius: 50.0)
Created Jan 21, 2019 — forked from ryanchang/lldb_cheat_sheet.md
LLDB Cheat Sheet
View lldb_cheat_sheet.md

# LLDB Cheat Sheet

A complete gdb to lldb command map.

### Print out

• Print object
``````(lldb) po responseObject
(lldb) po [responseObject objectForKey@"state"]
``````
• p - Print primitive type
Created Dec 15, 2018
View GenericsWillBeMyDownfall.swift
 // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software.
Last active Oct 31, 2018
A generic builder that allows me to inject dependencies into the built objects
View PricelessGenericBuilder.swift
 // With gratitude to David Harris http://davidharris.io/ // for his article on making generic factories. I might keep some of my hair. // // http://davidharris.io/ios/swift/2018/03/19/generic-factory.html import Foundation open class Builder { public typealias DependencyCreator = () -> DependencyType
Last active Mar 15, 2018 — forked from sergiosette/diff5.swift
Compare two sequences, report back the common elements, plus deletes/inserts required to make the sequences match
View SequenceDiff.swift
 // See how to use it at the bottom of this file // Helper struct for sequenceDiff public struct SequenceDiff { public let common: [(T1, T2)] public let removed: [T1] public let inserted: [T2] public init(common: [(T1, T2)] = [], removed: [T1] = [], inserted: [T2] = []) { self.common = common self.removed = removed