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 Foundation | |
/// 9 radom numbers followed by two verifying digits | |
var randomValidCpf: String { | |
var cpf = (1...11).map { _ in Int(arc4random_uniform(9)) } | |
cpf[9] = calcVerifyingDigit(originalValue: cpf, weights: (2...10).map{$0}.reversed()) | |
cpf[10] = calcVerifyingDigit(originalValue: cpf, weights: (2...11).map{$0}.reversed()) | |
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 UIKit | |
class AppDelegate { | |
var window: UIWindow? | |
} | |
//Chain of Resposability: Handler | |
protocol ErrorHandler { | |
var errorHandlerSuccessor: ErrorHandler? {get} | |
func handleError(error: Error) |
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
override init() { | |
super.init() | |
//Make sure the device can handle video | |
guard let videoDevice = AVCaptureDevice.default(for: .video), | |
let deviceInput = try? AVCaptureDeviceInput(device: videoDevice) else { | |
return | |
} | |
//session |
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
extension AVCodeReader: AVCaptureMetadataOutputObjectsDelegate { | |
func metadataOutput(_ captureOutput: AVCaptureMetadataOutput, | |
didOutput metadataObjects: [AVMetadataObject], | |
from connection: AVCaptureConnection) { | |
guard let readableCode = metadataObjects.first as? AVMetadataMachineReadableCodeObject, | |
let code = readableCode.stringValue else { | |
return | |
} | |
//Vibrate the phone |
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
// | |
// ContentSizePagingCollectionDelegate.swift | |
// CardsCarousel | |
// | |
// Created by Daniel Carlos Souza Carvalho on 2/20/21. | |
// | |
import UIKit | |
/// Horizontal paging for collections based on the content size |
OlderNewer