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
# Drop this into your ~/.gitconfig | |
[alias] | |
delete-merged = !bash -c '\ | |
REMOTE=$1 && \ | |
REMOTE=${REMOTE:="origin"} && \ | |
echo "Fetching $REMOTE" && \ | |
git fetch $REMOTE --prune && \ | |
git branch -vv | grep "gone]" | awk \"{ print \\$1 }\" | xargs git branch -d' - | |
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 FooProtocol { | |
func blah() | |
} | |
struct Foo : FooProtocol { | |
func blah() {} | |
} |
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
// The Swift Programming Language book from Apple states the following: | |
// | |
// Swift automatically provides shorthand argument names to inline closures, | |
// which can be used to refer to the values of the closure’s arguments by the | |
// names $0, $1, $2, and so on. | |
// In Xcode 6.1 and 6.2b1, it appears that this is only true IF the last argument | |
// is referenced using shorthand syntax somewhere in the closure body. See below | |
// for details. |
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
#! /usr/bin/swift | |
import ScriptingBridge | |
@objc protocol iTunesTrack { | |
optional var name: String {get} | |
optional var album: String {get} | |
} | |
@objc protocol iTunesApplication { |
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
// What I would expect: | |
(lldb) p newPaths | |
([AnyObject]) $R1 = 2 values { | |
[0] = "This is a string", | |
[1] = "This is another string" | |
} | |
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
context | |
context | |
-AAAA | |
-AAAA | |
-AAAA | |
+BBBB | |
+BBBB | |
+BBBB | |
+BBBB | |
{ |
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
class Foo { | |
var closure: () -> () = {} | |
init() {} | |
func nothing() {} | |
func setupClosure() { | |
closure = { | |
[weak self] in | |
self?.nothing() // <-- this returns a "Void?", which means that the rhs's |
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
@implementation MyImageView | |
- (void)registerForDraggedTypes:(NSArray *)newTypes { | |
if (self.editable) { | |
[super registerForDraggedTypes:newTypes]; | |
} | |
} | |
- (void)setEditable:(BOOL)editable | |
{ |
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
// You might think that a view could trigger window movement by overriding -[NSView mouseDownCanMoveWindow] | |
@interface DraggyView : NSView | |
@end | |
@implementation DraggyView | |
- (BOOL)mouseDownCanMoveWindow { | |
return YES; | |
} | |
@end |
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
// Looking for a Swift replacement for the following ObjC code: | |
// id x = foo ?: bar | |
// | |
// Which of the following do you like, if any? Any other suggestions? | |
// (Note that '?' cannot be used in a custom operator.) | |
x = foo !|| bar | |
x = foo |< bar | |
x = foo ||< bar |