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
    
  
  
    
  | func resolveFirebaseObject<T: Codable>(_ snapshot: DocumentSnapshot) -> T? { | |
| guard snapshot.exists else {return nil} | |
| if let data = try? JSONSerialization.data(withJSONObject: snapshot.data(), options: []) { | |
| do { | |
| return try self.decoder.decode(T.self, from: data) | |
| } catch { | |
| print("Decoding error: \(error)") | |
| } | |
| } | |
| 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
    
  
  
    
  | // | |
| // FMBlurable.swift | |
| // FMBlurable | |
| // | |
| // Created by SIMON_NON_ADMIN on 18/09/2015. | |
| // Copyright © 2015 Simon Gladman. All rights reserved. | |
| // | |
| // Thanks to romainmenke (https://twitter.com/romainmenke) for hint on a larger sample... | |
| 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
    
  
  
    
  | func printRoots(a: Double, b: Double, c: Double, showImaginaryRoots: Bool = false) { | |
| let b2 = b * b | |
| let disc = b2 - (4 * a * c) | |
| let discSqrt = sqrt(fabs(disc)) | |
| let isImage = disc < 0 | |
| let result = b * b - 4.0 * a * 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
    
  
  
    
  | #insert after all pods declaring (just put at the bottom of a file) | |
| post_install do |installer| | |
| installer.pods_project.targets.each do |target| | |
| if target.name == 'POD_NAME_HERE' | |
| target.build_configurations.each do |config| | |
| config.build_settings['SWIFT_VERSION'] = '4.0' | |
| end | |
| end | |
| end | |
| end | 
  
    
      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
    
  
  
    
  | func piCalc(_ totalPoints: Int) -> Double { | |
| var nPointsInside = 0 | |
| for _ in 1...totalPoints { | |
| let (x, y) = (drand48() * 2 - 1, drand48() * 2 - 1) | |
| if x * x + y * y <= 1 { | |
| nPointsInside += 1 | |
| } | |
| } | |
| return 4.0 * Double(nPointsInside) / Double(totalPoints) | |
| } | 
  
    
      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
    
  
  
    
  | fileprivate var propertyAnimator: UIViewPropertyAnimator! | |
| fileprivate var blurEffectView: UIVisualEffectView! | |
| fileprivate var backGradientView: UIView! | |
| func addWorkoutBlur() { | |
| if !UIAccessibilityIsReduceTransparencyEnabled() { | |
| if blurEffectView != nil { | |
| blurEffectView.removeFromSuperview() | |
| } | |
| if backGradientView != 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
    
  
  
    
  | class Fraction: ExpressibleByStringLiteral { | |
| private(set) var n: Int | |
| private(set) var d: Int | |
| init(numerator: Int, denominator:Int) { | |
| self.n = numerator | |
| self.d = denominator | |
| } | |
  
    
      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
    
  
  
    
  | do { | |
| try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, mode: AVAudioSessionModeDefault, options: .mixWithOthers) | |
| try AVAudioSession.sharedInstance().setActive(true) | |
| } catch { | |
| print(error) | |
| } | 
  
    
      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
    
  
  
    
  | func stripUrlToValid(_ url: String) -> String { | |
| var stripped = url.trimmingCharacters(in: .whitespacesAndNewlines) | |
| if stripped.hasPrefix("https") { | |
| stripped = stripped.replacingOccurrences(of: "https", with: "") | |
| } | |
| if stripped.hasPrefix("http") { | |
| stripped = stripped.replacingOccurrences(of: "http", with: "") | |
| } | |
| while stripped.hasPrefix(":") || stripped.hasPrefix("/") { |