routes
– an array of route objectsrequest
- configuration of a request.response
- configuration of the response.resourcePath
- relative path of the resource to serve, if the request was matched.contentType
- optional an override for the resource content type. By default it's automatically deduced from the file MIME type.
This file contains hidden or 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
#!/usr/bin/env xcrun swift | |
// $ chmod +x script.swift | |
// $ ./script.swift | |
// or $ ./script.swift -xcode=/Applications/Xcode-beta.app | |
import Foundation | |
@noreturn private func failWithError(message: String) { | |
print("🚫 \(message)") |
This file contains hidden or 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 | |
extension Dictionary { | |
static func keyDifference<Value: Equatable>(dictionary1 dic1: Dictionary<Key, Value>, dictionary2 dic2: Dictionary<Key, Value>, inout inserted: Set<Key>, inout deleted: Set<Key>, inout updated:Set<Key>, inout unchanged: Set<Key>) { | |
let keys1 = Set(dic1.keys.array) | |
let keys2 = Set(dic2.keys.array) | |
let allKeys = keys1.union(keys2) | |
inserted = [] |
This file contains hidden or 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
1 | |
2 | |
fizz | |
4 | |
buzz | |
fizz | |
7 | |
8 | |
fizz | |
buzz |
This file contains hidden or 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 | |
import GameplayKit | |
let randoms = NSCountedSet() | |
let shuffles = NSCountedSet() | |
let gausians = NSCountedSet() | |
let randomD3 = GKRandomDistribution(lowestValue: 1, highestValue: 3) | |
let shuffledD3 = GKShuffledDistribution(lowestValue: 1, highestValue: 3) | |
let gausianD3 = GKGaussianDistribution(lowestValue: 1, highestValue: 3) |
This file contains hidden or 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
let str: String | |
dispatch_sync(dispatch_get_global_queue(QOS_CLASS_UTILITY, 0)) { // Variable 'str' used before being initialized | |
str = "Hello" | |
} | |
print(str) // Variable 'str' used before being initialized |
This file contains hidden or 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
#ifdef DEBUG | |
#import "WMLSwizzler.h" | |
static SEL wml_loadViewSEL; | |
static void wml_swizzleLoadViewForClass(Class class) { | |
typedef void(*load_view_t)(id, SEL); | |
__block load_view_t loadView = (load_view_t)[class S_replaceInstanceMethod:wml_loadViewSEL withBlock:^(UIViewController *self){ | |
loadView(self, wml_loadViewSEL); |
This file contains hidden or 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> | |
@interface WMLPushNotificationRegistrationService : NSObject | |
+ (instancetype)sharedInstance; | |
@property (nonatomic, readonly, getter=isRegisteredForPushNotifications) BOOL registeredForPushNotifications; | |
/** | |
* Must be called every app startup, once got user's permission to send push notificaitons |
This file contains hidden or 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> | |
@interface Node : NSObject <NSCopying, NSMutableCopying> | |
@property (nonatomic, weak, readonly) Node *parent; | |
@property (nonatomic, strong, readonly) Node *left; | |
@property (nonatomic, strong, readonly) Node *right; | |
- (instancetype)initWithParent:(Node *)parent left:(Node *)left right:(Node *)right; | |
@end | |
@interface MutableNode : Node |