Skip to content

Instantly share code, notes, and snippets.

View blinker13's full-sized avatar
๐ŸŒˆ

Felix Gabel blinker13

๐ŸŒˆ
View GitHub Profile
@blinker13
blinker13 / OSPlatform
Last active December 15, 2015 22:19
Macros to differentiate between the Mac OS and iOS platform and between simulator and actual device on iOS
#define MAC_PLATFORM (TARGET_OS_MAC && !TARGET_OS_IPHONE)
#define IOS_PLATFORM (TARGET_OS_MAC && TARGET_OS_IPHONE)
#define IOS_DEVICE (IOS_PLATFORM && TARGET_OS_EMBEDDED)
#define IOS_SIMULATOR (IOS_PLATFORM && TARGET_IPHONE_SIMULATOR)
@blinker13
blinker13 / Singleton
Last active December 15, 2015 22:19
Class method for creating and retrieving a unique instance.
+ (instancetype)sharedInstance {
static dispatch_once_t onceToken;
static id sharedInstance;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
@blinker13
blinker13 / Dock Autohide Delay
Last active December 17, 2015 07:49
Remove and restore the Dock's display delay
defaults write com.apple.Dock autohide-delay -float 0 && killall Dock
defaults delete com.apple.Dock autohide-delay && killall Dock
@blinker13
blinker13 / .gitignore
Created October 14, 2013 22:21
.gitignore for Xcode 5
# Xcode
.DS_Store
xcuserdata
*.xccheckout
@blinker13
blinker13 / CoreDataLaunchFlags
Last active August 29, 2015 14:17
Core Data Launch Flags
-com.apple.CoreData.ConcurrencyDebug 1
-com.apple.CoreData.SQLDebug 3
-com.apple.CoreData.SQLDebug 2
-com.apple.CoreData.SQLDebug 1
-com.apple.CoreData.SyntaxColoredLogging YES
-com.apple.CoreData.MigrationDebug
@blinker13
blinker13 / pthread.swift
Last active December 20, 2015 04:04
Small Swift 2.0 pthread example that does not work
func foo(x:UnsafeMutablePointer<Void>) -> UnsafeMutablePointer<Void> {
print("Hello World")
return nil
}
let thread:UnsafeMutablePointer<pthread_t> = nil
//
pthread_create(thread, nil, foo, nil)
pthread_join(thread.memory, nil)
@blinker13
blinker13 / SwiftGetThreadName.swift
Created August 7, 2015 13:57
Calling pthread_getname_np() in Swift
var chars:[Int8] = Array(count:128, repeatedValue:0)
let error = pthread_getname_np(pthread, &chars, chars.count)
assert(error == 0, "Could not retrieve thread name")
let characters = chars.filter { $0 != 0 }.map { UInt8($0) }.map(UnicodeScalar.init).map(Character.init)
let name = String(characters)
protocol Foo {
var title:String { get }
func rant(value:Int) -> String
}
let bar = @mock(Foo)
bar.rant = { value in
fail(value != 13)
return "mocked"
public protocol Command {
associatedtype Input
associatedtype Output
func execute(input:Input) -> Output
}
public final class Signal<Input, Output> : Command {
private let block:(Input) -> Output
SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator
VALID_ARCHS[sdk=iphone*] = arm64 armv7 armv7s
VALID_ARCHS[sdk=macosx*] = i386 x86_64
LD_RUNPATH_SEARCH_PATHS[sdk=iphone*] = @executable_path/Frameworks @loader_path/Frameworks
LD_RUNPATH_SEARCH_PATHS[sdk=appletv*] = @executable_path/Frameworks @loader_path/Frameworks
LD_RUNPATH_SEARCH_PATHS[sdk=watch*] = @executable_path/Frameworks @loader_path/Frameworks
LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = @executable_path/../Frameworks @loader_path/Frameworks