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
    
  
  
    
  | + (UIImage *)thumbnailImageFromURL:(NSURL*)imageUrl downsampledToMaxPixelSize:(NSNumber *)maxPixelSize { | |
| NSDictionary *opts = @{ | |
| (id)kCGImageSourceThumbnailMaxPixelSize: maxPixelSize, | |
| (id)kCGImageSourceCreateThumbnailWithTransform: (id)kCFBooleanTrue, | |
| (id)kCGImageSourceCreateThumbnailFromImageIfAbsent: (id)kCFBooleanTrue | |
| }; | |
| CGImageSourceRef src = CGImageSourceCreateWithURL((__bridge CFURLRef)imageUrl, NULL); | |
| CGImageRef thumbnail = CGImageSourceCreateThumbnailAtIndex(src, 0, (__bridge CFDictionaryRef)opts); | |
| UIImage *img = [UIImage imageWithCGImage:thumbnail]; | 
  
    
      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
    
  
  
    
  | + (instancetype)sharedInstance { | |
| static id instance = nil; | |
| static dispatch_once_t onceToken; | |
| dispatch_once(&onceToken, ^{ | |
| instance = self.new; | |
| }); | |
| return instance; | |
| } | 
  
    
      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
    
  
  
    
  | #sudo vim /Library/LaunchDaemons/io.redis.redis-server.plist | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>Label</key> | |
| <string>io.redis.redis-server</string> | |
| <key>ProgramArguments</key> | |
| <array> | 
  
    
      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
    
  
  
    
  | struct User: Decodable { | |
| let username: String | |
| let email: String | |
| let accountType: AccountType | |
| let rank: Int | |
| let badges: [Badge] | |
| } | 
  
    
      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
    
  
  
    
  | private struct InputUser: Decodable { | |
| var email: String | |
| var password: String | |
| } | |
| private struct InputUserContract: ModelContract { | |
| typealias M = InputUser | |
| let email: PropertyPolicy = (\M.email, EmailValidator())) | |
| let password: PropertyPolicy = (\M.password, StringValidator(length: (min: 8, max: 20))) | 
  
    
      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 LoginViewController_ByExample: UIViewController { | |
| private var user = InputUser(email: "", password: "") | |
| private let userContract = InputUserContract() | |
| private let formValidator = ModelValidator() | |
| // MARK: - UITextFieldDelegate | |
| func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { | |
| let delayed = { |