Skip to content

Instantly share code, notes, and snippets.

View insidegui's full-sized avatar

Guilherme Rambo insidegui

View GitHub Profile
@insidegui
insidegui / PwnageVerifier.swift
Last active September 30, 2018 11:42
Uses the pwnedpasswords API to verify password integrity
/*
By default, this class requires https://github.com/idrougge/sha1-swift to work,
you can replace the default SHA1 implementation by setting the hash property to a function
that takes a String and returns an optional String (the SHA1 hex string of the input)
*/
/// Uses the pwnedpasswords API to verify password integrity
public final class PwnageVerifier {
/// The base URL for the pwnedpasswords service (a default is provided by the initializer)
// This only has to be called once in the application's lifetime
NSKeyedUnarchiver.setClass(CALayer.self, forClassName: "KFVectorLayer")
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorFeatureLayer")
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorAnimationLayer")
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorGradientFeatureLayer")
NSKeyedUnarchiver.setClass(CAShapeLayer.self, forClassName: "KFVectorBitmapFeatureLayer")
let path = Bundle.main.path(forResource: "YOUR_FILE_HERE", ofType: "caar")!
let archive = NSKeyedUnarchiver.unarchiveObject(withFile: path) as! [String: Any]
let animLayer = archive["rootLayer"] as! CALayer
// This only has to be called once in the application's lifetime
[NSKeyedUnarchiver setClass:[CALayer class] forClassName:@"KFVectorLayer"];
[NSKeyedUnarchiver setClass:[CAShapeLayer class] forClassName:@"KFVectorFeatureLayer"];
[NSKeyedUnarchiver setClass:[CAShapeLayer class] forClassName:@"KFVectorAnimationLayer"];
[NSKeyedUnarchiver setClass:[CAShapeLayer class] forClassName:@"KFVectorGradientFeatureLayer"];
[NSKeyedUnarchiver setClass:[CAShapeLayer class] forClassName:@"KFVectorBitmapFeatureLayer"];
NSString *path = [[NSBundle mainBundle] pathForResource:@"NAME_OF_YOUR_FILE" ofType:@"caar"];
NSDictionary *archive = [NSKeyedUnarchiver unarchiveObjectWithData:[NSData dataWithContentsOfFile:path]];
CALayer *animLayer = archive[@"rootLayer"];
public final class UserProfile: ModelObject {
@objc public dynamic var identifier: String = UUID().uuidString
@objc public dynamic var name: String = ""
@objc public dynamic var email: String = ""
public let referred = List<UserProfile>()
public let referrer = LinkingObjects(fromType: UserProfile.self, property: "referred")
}
public class ModelObject: Object {
@objc public override func setValue(_ value: Any?, forKey key: String) {
// make sure we begin a write transaction if this is a managed object
self.realm?.beginWrite()
// actually do the update
super.setValue(value, forKey: key)
// commit the write transaction if managed
record[.title] = title
record[.releaseDate] = date
record[.rating] = rating
// and so on...
let record = CKRecord(recordType: "Movie")
//
// PUPatternTextField.swift
// PeixeUrbano
//
// Created by Guilherme Rambo on 24/01/17.
//
//
import UIKit
//
// MaskPattern.swift
// PeixeUrbano
//
// Created by Guilherme Rambo on 24/01/17.
//
//
import Foundation
let containerIdentifier = "iCloud.br.com.guilhermerambo.KitchenContainer"
let secondContainer = CKContainer(identifier: containerIdentifier)