Skip to content

Instantly share code, notes, and snippets.

View hallski's full-sized avatar

Mikael Hallendal hallski

View GitHub Profile
extension Optional {
func both_then<T, U>(_ other: Optional<U>, f: (Wrapped, U) -> T) -> Optional<T> {
guard let a = self, let b = other else { return nil }
return f(a, b)
}
func neither<T>(_ other: Optional<T>) -> Bool {
return self == nil && other == nil
}
@hallski
hallski / gist:4240823
Created December 8, 2012 15:56
Toggle terminal
set appName to "Terminal" -- openTerminalWindow requires Terminal
set newWindowScript to "tmux -2" -- set to "" to just run the shell
if not isRunning(appName) then tell application appName to activate
if numberOfWindows(appName) is 0 then
openTerminalWindow(appName, newWindowScript)
foregroundApp(appName)
else
if isCurrentApp(appName) then
@class GHTestCase;
@interface GHTestCase (Swizzle)
+ (id)sharedMock;
+ (void)setSharedMock:(id)newMock;
- (void)swizzle:(Class)target_class selector:(SEL)selector;
- (void)deswizzle;