Skip to content

Instantly share code, notes, and snippets.

View gpambrozio's full-sized avatar

Gustavo Ambrozio gpambrozio

View GitHub Profile
@gpambrozio
gpambrozio / configurable.swift
Last active August 10, 2020 20:05
Configurable
typealias ConfigurationClosure<T> = (inout T) throws -> Void
protocol Configurable {}
extension Configurable {
func configure(_ step: ConfigurationClosure<Self>) rethrows -> Self {
var mutableSelf = self
try step(&mutableSelf)
return mutableSelf
}
@gpambrozio
gpambrozio / synchronized.swift
Created August 10, 2020 20:02
Synchronized in swift
func synchronized<T>(_ lock: Any, _ body: () throws -> T) rethrows -> T {
objc_sync_enter(lock)
defer { objc_sync_exit(lock) }
return try body()
}
@gpambrozio
gpambrozio / gist:963012
Created May 9, 2011 18:09
NSMutableDictionary+ImageMetadata methods
- (void)setLocation:(CLLocation *)currentLocation;
- (void)setUserComment:(NSString*)comment;
- (void)setDateOriginal:(NSDate *)date;
- (void)setDateDigitized:(NSDate *)date;
- (void)setMake:(NSString*)make model:(NSString*)model software:(NSString*)software;
- (void)setDescription:(NSString*)description;
- (void)setKeywords:(NSString*)keywords;
- (void)setImageOrientarion:(UIImageOrientation)orientation;