Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
- (void)watchdog { | |
NSTimeInterval pingInterval = 1.0/60.0; | |
NSTimeInterval watchdogInterval = 1.0/30.0; | |
__block NSTimeInterval lastPing = 0; | |
NSProcessInfo *pi = [NSProcessInfo processInfo]; | |
dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_main_queue()); | |
dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, pingInterval * NSEC_PER_SEC, 0); |
// Just before switching jobs: | |
// Add one of these. | |
// Preferably into the same commit where you do a large merge. | |
// | |
// This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
// and then it quickly escalated into more and more evil suggestions. | |
// I've tried to capture interesting suggestions here. | |
// | |
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/* | |
var t = Timer() | |
t.start() | |
// do something | |
t.stop() | |
print("took \(t.seconds)") | |
*/ |
// CalculatorView.swift | |
// as seen in http://nshipster.com/ibinspectable-ibdesignable/ | |
// | |
// (c) 2015 Nate Cook, licensed under the MIT license | |
/// The alignment for drawing an String inside a bounding rectangle. | |
enum NCStringAlignment { | |
case LeftTop | |
case CenterTop | |
case RightTop |
// OptionalBinding.swift | |
// as seen in http://nshipster.com/swift-1.2/ | |
// | |
// (c) 2015 Nate Cook, licensed under the MIT license | |
let a: Int? = 10 | |
let b: Int? = 5 | |
let c: Int? = 3 | |
let d: Int? = -2 | |
let e: Int? = 0 |
// Create an `Observable` of Optional<Int> | |
let values: Observable<Int?> = [1, 2, .None, 3, .None, 4, 5].toObservable() | |
// Method 1: using a free function | |
// Requires passing the function to `flatMap` | |
func ignoreNil<A>(x: A?) -> Observable<A> { | |
return x.map { Observable.just($0) } ?? Observable.empty() | |
} |