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
JSONDecoder().decode([String : Localizations].self from: ...) | |
struct Localizations: Codable { | |
var localizations: [String : Localization] | |
} | |
struct Localization: Codable { | |
var stringUnit: StringUnit | |
var substitutions: [String : Substitution] | |
} |
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 DispatchQueue { | |
func async<T>(group: DispatchGroup? = nil, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute work: @escaping () -> T) async -> T { | |
await withCheckedContinuation { continuation in | |
self.async(group: group, qos: qos, flags: flags) { | |
let result = work() | |
continuation.resume(returning: result) | |
} | |
} | |
} | |
} |
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 CommonCrypto | |
import Bytes // https://github.com/mochidev/Bytes | |
class Cryptor { | |
enum CryptorError: Error { | |
case cryptorCreationError(CCCryptorStatus) | |
case cryptorUpdateError(CCCryptorStatus) | |
case cryptorFinalizeError(CCCryptorStatus) | |
case cryptorResetError(CCCryptorStatus) | |
} |
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
cd "${PROJECT_DIR}" | |
# Make sure working directory is clean. | |
if output=$(git status --porcelain) && [ -n "$output" ]; then | |
echo "error: Please commit any uncommitted files before proceeding:\n$output" | |
exit 1 | |
fi | |
# Make sure we are on master (and not a feature branch, for instance) | |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) |
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
//: Playground - noun: a place where people can play | |
import UIKit | |
struct FloatRange { | |
var minimum: Double; | |
var maximum: Double; | |
} | |
var floatRange = FloatRange(minimum: 0.9999, maximum: 1.0001); |
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
// | |
// UIView+MDConditionalAnimations.h | |
// MDConditionalAnimations | |
// | |
// Created by Dimitri Bouniol on 3/6/13. | |
// Copyright (c) 2013 Dimitri Bouniol. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> |
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
static __inline__ CGFloat MDRound(CGFloat value) | |
{ | |
static CGFloat scale = 0; | |
if (scale <= 0) { | |
scale = [[UIScreen mainScreen] scale]; | |
} | |
return roundf(value*scale)/scale; | |
} |
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/UIKit.h> | |
@interface UIGestureRecognizer (DBTrackingAdditions) | |
@property (nonatomic, readonly, getter=isTracking) BOOL tracking; | |
@end |
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/UIKit.h> | |
@interface UIImage (DBMaskedImageAdditions) | |
- (UIImage *)maskedImageWithMask:(UIImage *)maskImage; | |
@end |
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 <Cocoa/Cocoa.h> | |
@interface NSString (DBMoreStringAdditions) | |
- (CGSize)sizeWithFont:(NSFont *)aFont; | |
- (void)drawAtPoint:(CGPoint)point withFont:(NSFont *)aFont; | |
- (void)drawAtPoint:(CGPoint)point withFont:(NSFont *)aFont color:(NSColor *)aColor; | |
- (CGSize)sizeWithFont:(NSFont *)aFont actualFontSize:(CGFloat *)fontSize forWidth:(CGFloat)width; | |
- (CGSize)sizeWithFont:(NSFont *)aFont constrainedToSize:(CGSize)aSize; |