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
/* | |
func createBackgroundContext() -> NSManagedObjectContext { | |
let context = NSManagedObjectContext(concurrencyType: NSManagedObjectContextConcurrencyType.privateQueueConcurrencyType) | |
context.parent = self.mainContext | |
return context | |
} | |
*/ | |
do { | |
let photos = try appData.createBackgroundContext().fetch(request) |
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 | |
class A: NSObject, NSCoding { | |
var value: Double? | |
init(value: Double?) { | |
self.value = value | |
} |
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 is rather simple example of defer usage | |
// It won't work if your'e about to measure microsecs for obvious reasons | |
// But it can help if you're gathering small stats and instruments aren't working for you | |
// For debugging purposes - Try to use instruments first :) | |
// For analytics purposes - This can be better | |
// Swift 2.+ | |
// func timeLogger(operation: String = #function) -> () -> () { | |
// let now = NSDate() | |
// return { |
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
int +[NSPersistentStoreCoordinator _beginPowerAssertionWithAssert:]() { | |
r14 = rdx; | |
rbx = objc_getClass("UIApplication"); | |
rax = 0x0; | |
rcx = 0x0; | |
if (rbx != 0x0) { | |
rcx = [rbx respondsToSelector:@selector(sharedApplication)]; | |
rax = 0x0; | |
COND = rcx == 0x0; |
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
#!/bin/sh | |
# place me in .git/hooks/pre-commit | |
exec 1>&2 | |
if test $(git diff-index -p -M --cached HEAD -- | grep '^+' | grep '^+[[:space:]]*\(fdescribe(\|fcontext(\|fit(\)' | wc -c ) != 0 | |
then | |
searchedStrings=`git diff-index -p -M --cached HEAD -- | grep '^+' | grep '^+[[:space:]]*\(fdescribe(\|fcontext(\|fit(\)'` | |
echo "Error: You forgot to remove fdescribe: | |
${searchedStrings}" | |
exit 1 | |
fi |
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
protocol Additable { | |
func add() | |
} | |
protocol Substractable { | |
func sub() | |
} | |
protocol SupportsAddition1 { | |
associatedtype T = Additable | |
var operand: T {get set} |
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
# So there should be run script which will pass | |
#./timecheck.py start | |
#./timecheck.py stop | |
#!/usr/bin/python | |
import json,httplib,sys,time,os | |
from os.path import expanduser | |
seconds = int(round(time.time())) |
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 UITableViewCell { | |
private static var className: String { | |
return String(self.self) | |
} | |
static func reuseIdentifier() -> String { | |
return className |
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> | |
@implementation NSObject (Private) | |
- (float)doSomethng { | |
return 42.0; | |
} | |
@end | |
int main(int argc, char * argv[]) { | |
@autoreleasepool { | |
NSObject * object = [NSObject new]; |
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 | |
protocol DefaultValueConvertible { | |
static func defaultValue() -> Self | |
} | |
extension Double : DefaultValueConvertible { | |
static func defaultValue() -> Double { return 0.0 } | |
} |