This file contains hidden or 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
| /// The RepeatingSequence accepts a collection and returns the values sequentially until the | |
| /// final element is returned, at which point the sequence wraps around to the first element | |
| /// of the collection and continues from there. | |
| struct RepeatingSequence<T>: Sequence { | |
| /// The Collection that we base our sequence on. We use a Collection and not | |
| /// another Sequence because Sequences are not guaranteed to be repeatedly iterated. | |
| let data: AnyCollection<T> | |
| /// We can optionally specify a maximum number of iterations. This is necessary |
This file contains hidden or 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 Foundation | |
| public struct ObfuscationDecoder { | |
| public enum DeobfuscationError: Error { | |
| case invalidStringBytes | |
| } | |
| /// The multi-byte nonce used to encode strings. | |
| private static let nonce: [UInt8] = [199, 152, 254, 45, 85, 241, 134, 185, 22, 249, 182, 208, 43, 176, 143, 252] |
This file contains hidden or 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
| //: # Protocols and Inheritance | |
| //: This playground demonstrates a gotcha in the use of protcols with default | |
| //: method implementations along with class inheritance. | |
| import UIKit | |
| //: This protocol defines a single method that takes an `Int` and returns an `Int`. | |
| protocol Doable { | |
| func doSomething() -> Int | |
| } |
This file contains hidden or 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
| // | |
| // ColorCubeHelper.swift | |
| // | |
| // Created by Joshua Sullivan on 10/01/16. | |
| // Copyright © 2016 Joshua Sullivan. All rights reserved. | |
| // | |
| import UIKit | |
| import Accelerate |
This file contains hidden or 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
| //: # Challenge Accepted #49 | |
| //: ## WUnderground API Client | |
| //: ### Version 2.0 | |
| //: | |
| //: Implement the networking layer for the Umbrella weather app(iOS or Android), | |
| //: using a similar architecture to the one demonstrated in the first episode of Swift Talks. | |
| //: | |
| //: - note: | |
| //: This is my updated solution to the challenge which demonstrates a more powerful and flexible | |
| //: approach to customizing the request sent to the API through the use of closures rather than |
This file contains hidden or 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
| // | |
| // ColorCubeImageCreator.swift | |
| // ColorCubeImageCreator | |
| // | |
| // Created by Joshua Sullivan on 4/25/16. | |
| // Copyright © 2016 Joshua Sullivan. All rights reserved. | |
| // | |
| import UIKit |
This file contains hidden or 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
| // | |
| // ViewController.swift | |
| // MetalCoreImage | |
| // | |
| // Created by Joshua Sullivan on 4/21/16. | |
| // Copyright © 2016 The Nerdery. All rights reserved. | |
| // | |
| import UIKit | |
| import MetalKit |
This file contains hidden or 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 Swift | |
| /// This method returns half of the input value if the number is even. It returns nil if the number is odd. | |
| func evenHalfOrNil(input: Int) -> Int? { | |
| if (input % 2 == 0) { | |
| return input / 2 | |
| } else { | |
| return nil | |
| } | |
| } |
This file contains hidden or 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
| static float FOCAL_LENGTH = 200.0; | |
| static float ORBIT_RADIUS = 180.0; | |
| static int SPARK_COUNT = 200; | |
| class Spark { | |
| color clr; | |
| float orbitRadius; | |
| float rx, ry, rz, drx, dry, drz; | |
| Spark(color c, float orbitRadius) { | |
| this.clr = c; |
This file contains hidden or 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
| class SingleWave { | |
| float SEGMENTS_PER_CYCLE = 48.0; | |
| float wavelength, r, dr; | |
| color drawColor; | |
| SingleWave(float wavelength, color drawColor) { | |
| this.wavelength = wavelength; | |
| this.drawColor = drawColor; |