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
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer | |
/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash -o symbolicated.crash unsymbolicated.crash |
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
module Main where | |
import Data.Foldable | |
rle = (concatMap (\(sym, num) -> sym:show num)) . foldr' collect [] | |
where collect s [] = [(s, 1)] | |
collect s all@((sym, num):others) | |
| sym == s = (sym, num + 1):others | |
| otherwise = (s, 1):all |
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
module Main where | |
data Tree a = Leaf | Node a (Tree a) (Tree a) | |
isBST :: Tree Double -> Bool | |
isBST = fst . isBST' | |
where isBST' Leaf = (True, Nothing) | |
isBST' (Node n left right) = | |
let (l, lminmax) = isBST' left | |
~(r, rminmax) = isBST' right |
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 | |
infix operator <| { associativity right precedence 95 } | |
func <|<A, R>(@noescape f: A -> R, a: A) -> R { | |
return f(a) | |
} | |
func <|<A, B, R>(@noescape f: (A, B) -> R, a: (A, B)) -> R { | |
return f(a.0, a.1) | |
} |
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
func synchronized(object: AnyObject, @noescape closure: () -> Void) { | |
objc_sync_enter(object) | |
closure() | |
objc_sync_exit(object) | |
} |
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
protocol Lock { | |
func lock() throws | |
func unlock() | |
} | |
protocol Atomic { | |
associatedtype Protected | |
associatedtype Primitive: Lock | |
var lock: Primitive { get } |
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
let queue = dispatch_queue_create("QUEUE", DISPATCH_QUEUE_CONCURRENT) | |
var holder: Int = 10 | |
func readSafe() -> Int { | |
var read: Int! | |
dispatch_sync(queue) { | |
read = holder | |
} | |
return read |
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
public final class SpinLock { | |
private var lock: OSSpinLock = OS_SPINLOCK_INIT | |
public func locked<A>(@noescape f: () throws -> A) rethrows -> A { | |
OSSpinLockLock(&lock) | |
defer { OSSpinLockUnlock(&lock) } | |
return try f() | |
} | |
} |
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
summands 0 = [] | |
summands n = [n]:concat [summandsOfTwo k (n - k) | k <- [1..n `quot` 2]] | |
where summandsOfTwo l r = | |
let le = map (r:) (summands l) | |
re = map (l:) (summands r) | |
in if l == r then le else le ++ re |
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
extern NSManagedObjectContext *GetContext(void); | |
@interface TableViewController () <NSFetchedResultsControllerDelegate> | |
@property (nonatomic) NSFetchedResultsController *controller; | |
@end | |
@implementation TableViewController |
NewerOlder