Skip to content

Instantly share code, notes, and snippets.

View insidegui's full-sized avatar
🧩

Guilherme Rambo insidegui

🧩
View GitHub Profile
//
// MaskPattern.swift
// PeixeUrbano
//
// Created by Guilherme Rambo on 24/01/17.
//
//
import Foundation
//
// PUPatternTextField.swift
// PeixeUrbano
//
// Created by Guilherme Rambo on 24/01/17.
//
//
import UIKit
let record = CKRecord(recordType: "Movie")
record[.title] = title
record[.releaseDate] = date
record[.rating] = rating
// and so on...
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
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")
}
// 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"];
// 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
@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)
@insidegui
insidegui / iBridge2_1_devtree.txt
Created March 10, 2018 15:38
iBridge 2,1 device tree
dtre
Device Tree with 19 properties and 10 children
Properties:
device-tree:
| +--name 12 bytes: device-tree
| +--target-type 5 bytes: J137
| +--mlb-serial-number 29 bytes: syscfg/MLB#/0x20,zeroes/0x20
| +--compatible 27 bytes: J137AP
| +--secure-root-prefix 3 bytes: md
| +--AAPL,phandle 4 bytes: 1