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 "UIImage+FixIOS13Bug.h" | |
#import <objc/runtime.h> | |
/** | |
* Fix UIImage -drawRect: bug in iOS 13 that impacts RouteMe library tiling. | |
* | |
* SEE: https://forums.developer.apple.com/thread/120526 | |
*/ | |
@implementation UIImage (FixIOS13Bug) |
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
UIGraphicsBeginImageContext(CGSizeMake(512.0, 512.0)); | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
CGContextSetFillColorWithColor(ctx, [UIColor redColor].CGColor); | |
CGContextFillRect(ctx, CGRectMake(0.0, 0.0, 512.0, 512.0)); | |
UIImage* myImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); |
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
class Cat { | |
func sayHello() -> String { | |
return "Meow!" | |
} | |
} | |
func schrodingersCat() -> Cat? { | |
// Open the box! | |
let cat = [0, 1].randomElement() | |
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
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// See TN2154: https://developer.apple.com/library/archive/technotes/tn2154/_index.html | |
UIScrollView* scrollView = [[UIScrollView alloc] init]; | |
scrollView.translatesAutoresizingMaskIntoConstraints = NO; | |
[[self view] addSubview:scrollView]; | |
// Pin the scroll view to the main view. | |
[[scrollView topAnchor] constraintEqualToAnchor:[[[self view] safeAreaLayoutGuide] topAnchor]].active = YES; |
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 <LocalAuthentication/LocalAuthentication.h> | |
/** | |
* Return YES if iOS device has a notch; NO, otherwise. | |
*/ | |
- (BOOL)hasDeviceNotch | |
{ | |
if ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)) { | |
return NO; | |
} |
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
- (IBAction)sendGETRequest:(id)sender | |
{ | |
AFHTTPSessionManager* manager = | |
[[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:@"http://localhost:8080"]]; | |
AFHTTPRequestSerializer* requestSerializer = [AFHTTPRequestSerializer serializer]; | |
// Simulate the JWT. | |
[requestSerializer setValue:@"Bearer abc123doremiabc123babyuandme" forHTTPHeaderField:@"Authorization"]; | |
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/Foundation.h> | |
#import <CommonCrypto/CommonDigest.h> | |
NSString* const MDXHashSalt = @"usesomekindofsecret"; | |
@interface MDXHash : NSObject | |
- (NSString *)createHash:(NSString *)plaintext; | |
@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 <Foundation/Foundation.h> | |
typedef void (^SampleBlock)(void); | |
int main(int argc, char *argv[]) { | |
@autoreleasepool { | |
SampleBlock myBlock = ^void(void) { | |
NSLog(@"Hello, World!"); | |
}; | |
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
/* Header: ItemStore.h | |
#import <Foundation/Foundation.h> | |
@interface ItemStore : NSObject <NSFastEnumeration> | |
@property (nonatomic, assign, readonly) NSUInteger count; | |
@end | |
*/ | |
#import "ItemStore.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
#include <stdbool.h> | |
#include <stdio.h> | |
#include <string.h> | |
/** | |
* Truncate string at first newline, if exists, returning true on chomp; false, if no chomp. | |
*/ | |
bool chomp(char *line) { | |
// https://stackoverflow.com/a/3217634/155167 | |
bool success = false; |