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
| # Find all the available rules by running: | |
| # swiftlint rules | |
| disabled_rules: # rule identifiers to exclude from running | |
| # - colon | |
| # - comma | |
| - control_statement | |
| # - trailing_whitespace | |
| opt_in_rules: # some rules are only opt-in | |
| - empty_count |
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 calculateAverage(total: Int, countOfNumbers: Int) -> Int { | |
| return total / countOfNumbers | |
| } | |
| func average(algorithm: (Int, Int) -> Int, numbers: Int...) -> Int { | |
| var countOfNumbers = 0 | |
| var total = 0 | |
| for number in numbers { | |
| total += number |
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
| prefix func ++(inout x: Int) -> Int { | |
| x = x + 1 | |
| return x | |
| } | |
| postfix func ++(inout x: Int) -> Int { | |
| let oldX = x | |
| x = x + 1 | |
| return oldX | |
| } |
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
| // | |
| // AppConst.swift | |
| // AdBlockSample | |
| // | |
| // Created by bright on 2016/11/26. | |
| // Copyright © 2016年 bright. All rights reserved. | |
| // | |
| import Foundation | |
| 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
| import Foundation | |
| import CoreTelephony | |
| class OperatorInfo { | |
| func id() -> String { | |
| let networkInfo = CTTelephonyNetworkInfo() | |
| let carrier = networkInfo.subscriberCellularProvider | |
| let mcc = carrier!.mobileCountryCode | |
| let mnc = carrier!.mobileNetworkCode |
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 currentViewController(_ viewController: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? { | |
| guard let viewController = viewController else { return nil } | |
| if let viewController = viewController as? UINavigationController { | |
| if let viewController = viewController.visibleViewController { | |
| return currentViewController(viewController) | |
| } else { | |
| return currentViewController(viewController.topViewController) | |
| } | |
| } else if let viewController = viewController as? UITabBarController { |
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
| // https://medium.com/@milanpanchal24/clearing-all-notifications-in-mac-os-x-3be0a16eb2a3 | |
| function run(input, parameters) { | |
| var app = Application('System Events'); | |
| app.includeStandardAdditions = true; | |
| app.processes.byName('NotificationCenter').windows.buttons[0].click(); | |
| return input; | |
| } |
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 UIKit | |
| import Foundation | |
| @IBDesignable class PlaceholderTextView: UITextView, UITextViewDelegate | |
| { | |
| private let _placeholderColor: UIColor = UIColor(white: 0.78, alpha: 1) | |
| private var _placeholderLabel: UILabel! | |
| @IBInspectable var placeholder: String = "" { | |
| 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
| // https://medium.com/@milanpanchal24/how-to-group-array-using-dictionary-in-swift-6d185c8c79c | |
| let fruits = ["Apple", "Apricot", "Avocado", | |
| "Banana", "Boysenberry", "Blueberry", "Bing Cherry", | |
| "Clementine", "Cucumber", | |
| "Dates", "Dewberries", "Dragon Fruit"] | |
| let groupedByAlphabet = Dictionary(grouping: fruits) { $0.first! } |
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
| // https://medium.com/@milanpanchal24/how-to-group-array-using-dictionary-in-swift-6d185c8c79c | |
| let employee = [["countryName":"India", "name":"Milan", "age":"30"], | |
| ["countryName":"India", "name":"Emma", "age":"25"], | |
| ["countryName":"NZ", "name":"Olivia", "age":"40"], | |
| ["countryName":"NZ", "name":"Sophia", "age":"22"], | |
| ["countryName":"Canada", "name":"David", "age":"33"], | |
| ["countryName":"Canada", "name":"Wyatt", "age":"21"], | |
| ["countryName":"Portugal", "name":"Joseph", "age":"28"]] |
OlderNewer