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 Vapor | |
/// Services files from the public folder. | |
public final class FileMiddlewareWithCache: Middleware, Service { | |
/// The public directory. | |
/// note: does _not_ end with a slash | |
let publicDirectory: String | |
public var webTypes = [MediaType]() |
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
// The 6 ways to uwnrap optionals in Swift 2.0 | |
// | |
// Created by Patrick Lynch on 6/28/15. | |
// Copyright © 2015 Patrick Lynch. All rights reserved. | |
import Foundation | |
// 1. Force Unwrapping | |
// 2. Optional Binding | |
// 3. Optional Chaining |
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
/* | |
This benchmark shows how indirect function calls have nearly | |
the same overhead costs as direct function calls. | |
This is comparing apples to apples, factoring out the savings | |
due to inlining optimizations that direct calls usually afford. | |
From this, it seems that inlining and other generic interprocedual | |
optimizations are the main drivers of direct function call optimization, | |
not the direct call itself. |
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 UIKit | |
extension UIView { | |
func currentFirstResponder() -> UIResponder? { | |
if self.isFirstResponder() { | |
return self | |
} | |
for view in self.subviews { | |
if let responder = view.currentFirstResponder() { |
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
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
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 NSThread (RunBlock) | |
- (void)performBlock:(void(^)())block; | |
- (void)performBlock:(void (^)())block afterDelay:(NSTimeInterval)delay; | |
@end |
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
ACTION | |
AD_HOC_CODE_SIGNING_ALLOWED | |
ALTERNATE_GROUP | |
ALTERNATE_MODE | |
ALTERNATE_OWNER | |
ALWAYS_SEARCH_USER_PATHS | |
ALWAYS_USE_SEPARATE_HEADERMAPS | |
APPLE_INTERNAL_DEVELOPER_DIR | |
APPLE_INTERNAL_DIR | |
APPLE_INTERNAL_DOCUMENTATION_DIR |
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
# Add the following lines of code to your `~/.bash_profile`, | |
# and then run `source ~/.bash_profile` to be able to execute | |
# this from the command line. | |
openx() { | |
fileToOpen=''; | |
for file in `find . -maxdepth 1 -name *.xcworkspace`; do | |
fileToOpen=$file | |
done |
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
-(void) printASBDforNode:(AUNode) node scope:(int) scope bus:(int) bus { | |
AudioStreamBasicDescription testASBD; | |
UInt32 asbdSize = sizeof (AudioStreamBasicDescription); | |
AudioUnit nodeUnit; | |
AUGraphNodeInfo(_graph, node, NULL, &nodeUnit); | |
AudioUnitGetProperty(nodeUnit, | |
kAudioUnitProperty_StreamFormat, | |
scope, | |
bus, // bus |
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
- (UIViewController *)topViewController{ | |
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController]; | |
} | |
- (UIViewController *)topViewController:(UIViewController *)rootViewController | |
{ | |
if (rootViewController.presentedViewController == nil) { | |
return rootViewController; | |
} | |
NewerOlder