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 copyDatabaseIfNeeded() { | |
| // Move database file from bundle to documents folder | |
| let fileManager = FileManager.default | |
| let documentsUrl = fileManager.urls(for: .documentDirectory, | |
| in: .userDomainMask) | |
| guard documentsUrl.count != 0 else { | |
| return // Could not find documents URL | 
  
    
      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
    
  
  
    
  | // MARK: - Adding a header to a single request | |
| func doRequestWithHeaders1() { | |
| let headers: HTTPHeaders = [ | |
| "X-Mashape-Key": MY_API_KEY, | |
| "Accept": "application/json" | |
| ] | |
| Alamofire.request("https://mashape-community-urban-dictionary.p.mashape.com/define?term=smh", headers: headers) | |
| .responseJSON { response in | |
| debugPrint(response) | 
  
    
      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
    
  
  
    
  | # usage: | |
| # IFS=$'\n' find ROOT_SOURCE_FOLDER -name "*.swift" -exec python PATH/TO/migrate.py {} \; | |
| import sys | |
| import re | |
| func = re.compile('func\s+\w+\(') | |
| param = re.compile('(?P<indent>\s*)/// -[ ]*[pP]arameter[ ]+(?P<name>\w+)[ ]*:(?P<description>[^\n]+)\n') | |
| ret = re.compile('(?P<indent>\s*)/// -[ ]*[rR]eturns[ ]*:(?P<description>[^\n]+)\n') | |
| continuation = re.compile('\s*///(?P<description>[^\n]+)') | 
  
    
      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
    
  
  
    
  | version: '3' | |
| services: | |
| mssql-server-linux: | |
| image: microsoft/mssql-server-linux:latest | |
| volumes: | |
| - mssql-server-linux-data:/var/opt/mssql/data | |
| environment: | |
| - ACCEPT_EULA=Y | |
| - SA_PASSWORD=${SQLSERVER_SA_PASSWORD:-yourStrong(!)Password} | 
  
    
      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
    
  
  
    
  | let granularity = Calendar.Component.day | |
| let comparisonResult = Calendar.current.compare(firstDate, to: secondDate, toGranularity: granularity) | |
| // granularity: | |
| // .second | |
| // .minute | |
| // .hour | |
| // .day | |
| // .month | |
| // .year | 
  
    
      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 | |
| import XCTest | |
| /// Basic sanity check that ensures that we are able to retrieve localized strings for all languages | |
| /// we support. | |
| final class L10NTests: XCTestCase { | |
| func testLocalizations() { | |
| let locales = ["en", "es", "zh-Hans", "zh-Hant", "fi"] | |
| for locale in locales { | 
  
    
      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 MyLabel: UILabel { | |
| var textWillChange:((_ oldText: String?)->())? = nil | |
| var textDidChange:((_ newText: String?)->())? = nil | |
| override var text: String? { | |
| willSet { | |
| if textWillChange != nil { | |
| textWillChange!(self.text) | |
| } | |
| } | |
| didSet { | 
  
    
      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
    
  
  
    
  | #!/bin/bash | |
| # if 1st param empty... | |
| if [ -z "$1" ] | |
| then | |
| echo "Usage: select-xcode {8|9}" | |
| exit | |
| fi | |
| XCODE8_APP=/Applications/Xcode-8.app | 
  
    
      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 deepDescription(_ any: Any) -> String { | |
| guard let any = deepUnwrap(any) else { | |
| return "nil" | |
| } | |
| if any is Void { | |
| return "Void" | |
| } | |
| if let int = any as? Int { |