This file contains 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
var card_number = "" | |
func make_random_number(num:Int)->[Int]{ | |
var result = [Int]() | |
for _ in 0...num { | |
result.append(Int(arc4random_uniform(9))) | |
} | |
return result | |
} | |
func luhn_algorithm(){ |
This file contains 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 random | |
credit_card_number = "" | |
def make_random_number(number_of_element): | |
random_numbers = [] | |
for i in range(number_of_element): | |
random_numbers.append(random.randint(0, 9)) | |
return random_numbers |
This file contains 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 bezierPath = UIBezierPath() | |
bezierPath.move(to: CGPoint(x: 25.5, y: 185.5)) | |
bezierPath.addCurve(to: CGPoint(x: 25.5, y: 56.5), controlPoint1: CGPoint(x: 25.5, y: 185.5), controlPoint2: CGPoint(x: 25.5, y: 88.75)) | |
bezierPath.addCurve(to: CGPoint(x: 72.5, y: 67.5), controlPoint1: CGPoint(x: 25.5, y: 24.25), controlPoint2: CGPoint(x: 60.75, y: 64.75)) | |
bezierPath.addCurve(to: CGPoint(x: 108.5, y: 185.5), controlPoint1: CGPoint(x: 84.25, y: 70.25), controlPoint2: CGPoint(x: 108.5, y: 185.5)) | |
bezierPath.addCurve(to: CGPoint(x: 136.5, y: 299.5), controlPoint1: CGPoint(x: 108.5, y: 185.5), controlPoint2: CGPoint(x: 129.5, y: 271)) | |
bezierPath.addCurve(to: CGPoint(x: 186.5, y: 279.5), controlPoint1: CGPoint(x: 143.5, y: 328), controlPoint2: CGPoint(x: 174, y: 284.5)) | |
bezierPath.addCurve(to: CGPoint(x: 202.5, y: 185.5), controlPoint1: CGPoint(x: 199, y: 274.5), controlPoint2: CGPoint(x: 202.5, y: 185.5)) | |
bezierPath.addCurve(to: CGPoint(x: 217.5, y: 67.5), controlPoint1: CGPoint(x: 202.5, y: 185.5), controlPoint2: CG |
This file contains 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 animation = CAKeyframeAnimation(keyPath: "position") | |
animation.path = bezierPath.cgPath | |
animation.repeatCount = 0 | |
animation.duration = 3.0 | |
animation.delegate = self | |
movingView.layer.add(animation, forKey: "animate along path") | |
movingView.center = CGPoint(x: 0, y: frame.maxY) | |
timer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(fireTimer), userInfo: nil, repeats: true) | |
movingView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5) |
This file contains 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 func scaleMethod() { | |
UIView.animate(withDuration: 0.75, animations: { | |
self.movingView.transform = .identity | |
}) { _ in | |
self.movingView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5) | |
self.scaleMethod() | |
} | |
} |
This file contains 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 BaseController<ViewType: UIView>: UIViewController, Controller { | |
var viewType: ViewType{ | |
if let view = self.view as? ViewType { | |
return view | |
} else { | |
let view = ViewType() | |
self.view = view | |
return view | |
} | |
} |
This file contains 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 TestViewController: BaseController<OriginalView> { | |
} | |
class TestBaseView: BaseView { | |
public weak var buttonActionDelegate: MyViewActionDelegate? | |
private let button: UIButton = { |
This file contains 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 MainCoordinator: Coordinator { | |
var childCoodinators = [Coordinator]() | |
var navigationController: UINavigationController | |
fileprivate var isLoggedIn = false | |
init(navigationController: UINavigationController) { | |
self.navigationController = navigationController | |
} | |
func start() { |
This file contains 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
window = UIWindow(frame: UIScreen.main.bounds) | |
window?.rootViewController = UINavigationController() | |
mainCoordinator = MainCoordinator(navigationController: window?.rootViewController as! UINavigationController) | |
mainCoordinator?.start() | |
window?.makeKeyAndVisible() |
This file contains 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 pathToCert = Bundle.main.path(forResource: "name-of-cert-file", ofType: "cer") | |
let localCertificate: NSData = NSData(contentsOfFile: pathToCert!)! | |
let serverTrustPolicy = ServerTrustPolicy.pinCertificates( | |
certificates: [SecCertificateCreateWithData(nil, localCertificate)!], | |
validateCertificateChain: true, | |
validateHost: true | |
) | |
let serverTrustPolicies = [ |
OlderNewer