- Code tends to be shorter & clearer
- Value types are a super valuable design pattern (see what I did there)
- Optionals are amazing
- Online resources tend to be in Swift these days
- Swift 2 is a lot better than Swift 1.2
- Trending towards stability
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
/// An API for managing UIKit background tasks by composing signals. | |
@interface UIApplication (SHReactiveBackgroundTask) | |
/// Creates a signal that wraps an underlying signal in a background task. | |
/// Upon subscription, starts a background task, and then automatically ends | |
/// the background task when the underlying signal completes or errors. | |
/// If the background task expires, the subscription to the underlying signal | |
/// will automatically be disposed of. | |
/// | |
/// @note If the call to `-beginBackgroundTaskWithExpirationHandler:` returns |
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
Process: Xcode [56151] | |
Path: /Applications/Xcode.app/Contents/MacOS/Xcode | |
Identifier: com.apple.dt.Xcode | |
Version: 6.3.2 (7718) | |
Build Info: IDEFrameworks-7718000000000000~2 | |
App Item ID: 497799835 | |
App External ID: 812404257 | |
Code Type: X86-64 (Native) | |
Parent Process: ??? [1] | |
Responsible: Xcode [56151] |
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
require "rspec/autorun" | |
class Enumerator::Lazy | |
def reduce(*) | |
Lazy.new([nil]) do |yielder, _| | |
yielder << super | |
end | |
end | |
def join(separator="") |
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
#!/bin/sh | |
if [ -t 1 ]; then | |
echo LOL >&2 | |
exit 1 | |
else | |
real_git=$(type -a git | head -2 | tail -1 | cut -d" " -f 3) | |
exec "$real_git" ${*} | |
fi |
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
final class GreetingFeature: Feature { | |
override func scenarios() { | |
Scenario("Greeting on first load") | |
.Given("the app has launched") | |
.Then("the text 'Hello, world!' is on screen") | |
} | |
} |
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 Darwin | |
enum Signal: Int32 { | |
case HUP = 1 | |
case INT = 2 | |
case QUIT = 3 | |
case ABRT = 6 | |
case KILL = 9 | |
case ALRM = 14 | |
case TERM = 15 |
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 Dispatch | |
/// Wraps some `Base` type so that all method calls become | |
/// "message sends", e.g., `async { $0.foo() }` or `sync { $0.bar() }`. | |
public final class Actor<Base> { | |
private var instance: Base | |
private let queue: DispatchQueue | |
public init(_ instance: Base, target: DispatchQueue? = nil) { | |
self.instance = instance |
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
// Prints out all the unicode scalars in a Foundation CharacterSet. | |
// | |
// Compile: swiftc -O scalars.swift | |
// Run: ./scalars <character set name> | |
import Foundation | |
extension UnicodeScalar { | |
static var allScalars: AnySequence<UnicodeScalar> { | |
let numbers = sequence(first: 0, next: { $0 + 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
struct BitMask<T: FixedWidthInteger>: RandomAccessCollection { | |
typealias SubSequence = BitMask<T> | |
var rawValue: T { | |
var rawValue: T = 0 | |
for bit in self { | |
rawValue |= bit | |
} | |
return rawValue | |
} |