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
/* Put this in a subclass of LHSprite! | |
* Then, in your layer's update: method you can check if a sprite is touching another sprite: | |
* [mySpriteClassInstance isCollidedWithSprite:anotherSprite]; | |
*/ | |
- (BOOL)isCollidedWithSprite:(LHSprite *)spriteB | |
{ | |
BOOL isTouching = FALSE; | |
for (b2Fixture *fA = self.body->GetFixtureList(); fA; fA = fA->GetNext()) |
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
// | |
// KIFUITestActor+Helper.h | |
// | |
// Created by Max Chuquimia on 10/04/2014. | |
// | |
// | |
#import "KIFUITestActor.h" | |
@interface KIFUITestActor (Helper) |
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
-- commandline `avconvert` didn't want to work and I was desperate, so I wrote this. | |
-- Use it at your own risk | |
-- Do what you want with it | |
tell application "Finder" to set chosenFiles to every file of (choose folder) | |
repeat with aFile in chosenFiles | |
-- Change to suit your extension | |
if name of aFile ends with ".MPG" then | |
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
[self requestSupplementaryLexiconWithCompletion:^(UILexicon *lex){ | |
NSMutableString *s = [NSMutableString new]; | |
for (UILexiconEntry *e in lex.entries) | |
{ | |
[s appendFormat:@"%@ -> %@\n", e.userInput, e.documentText]; | |
} | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
UITextView *textView = [[UITextView alloc] initWithFrame:self.view.bounds]; | |
textView.text = s; | |
[self.view addSubview:textView]; |
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> | |
@interface NSUserDefaults (Extension) | |
/*! | |
* Associates a block of code with a token. If the token has not been used the code block will run immediately. | |
* | |
* @param token A token unique to the code block | |
* @param block A block of code to run | |
* |
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
//This is currently working in my Keyboard Extension (not upside-down friendly) | |
- (BOOL)isPortrait { | |
CGFloat portraitWidth = [[UIScreen mainScreen] nativeBounds].size.width/[UIScreen mainScreen].scale; | |
CGFloat thisWidth = [[UIScreen mainScreen] bounds].size.width; | |
return portraitWidth == thisWidth; | |
} |
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
//gcc -o audiostream audiostream.m -framework Foundation -framework AppKit -framework AVFoundation | |
#import <Foundation/Foundation.h> | |
#import <AVFoundation/AVFoundation.h> | |
#import <AppKit/AppKit.h> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
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
//MARK: instancetype | |
//Xcode 7A176x | |
extension UIViewController { | |
class func fromStoryboard(named name: String) -> Self { | |
let storyboard = UIStoryboard(name: name, bundle: NSBundle.mainBundle()) | |
let classname = NSStringFromClass(self) as NSString //Error: Type 'Self" does not conform to protocol 'AnyObject' | |
return storyboard.instantiateViewControllerWithIdentifier(classname.pathExtension) | |
} | |
} |
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 Array { | |
/*! | |
Convert an array to a dictionary of two of it's element's properties | |
- parameter f: the parse block | |
- returns: a dictionary of the type of the tuple returned by the parse block | |
*/ | |
func toDict<K, V>(f: (Element -> (K, V))) -> [K: V] { |
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 | |
@objc class GTINCalculator: NSObject { | |
/*! | |
An exception thrown when there is a calculation error | |
- BadDigit: a substring of the input string could not be read as an `Int` | |
*/ | |
enum GTINCalculatingError: ErrorType { |
OlderNewer