(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.
/** | |
* Perform a throwing expression, and throw a custom error in case the expression threw | |
* | |
* - parameter expression: The expression to execute | |
* - parameter error: The custom error to throw instead of the expression's error | |
* - throws: The given error | |
* - returns: The return value of the given expression | |
*/ | |
func perform<T>(_ expression: @autoclosure () throws -> T, orThrow errorExpression: @autoclosure () -> Error) throws -> T { | |
do { |
import Foundation | |
public protocol Observer: Equatable { | |
associatedtype EventType | |
func listen(_ event: EventType) | |
} | |
public protocol Observable { | |
associatedtype ObserverType: Observer | |
associatedtype EventType |
import CoreData | |
protocol Fetchable | |
{ | |
typealias FetchableType: NSManagedObject | |
static func entityName() -> String | |
static func objectsInContext(context: NSManagedObjectContext, predicate: NSPredicate?, sortedBy: String?, ascending: Bool) throws -> [FetchableType] | |
static func singleObjectInContext(context: NSManagedObjectContext, predicate: NSPredicate?, sortedBy: String?, ascending: Bool) throws -> FetchableType? | |
static func objectCountInContext(context: NSManagedObjectContext, predicate: NSPredicate?) -> Int |
(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.
import random | |
class TreapNode(object): | |
def __init__(self, key, data): | |
self.key = key | |
self.ran = random.random() | |
self.size = 1 | |
self.cnt = 1 | |
self.data = data | |
self.left = None |
How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS | |
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing). | |
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here: | |
* Heroku Hostname SSL | |
* GoDaddy Standard SSL Certificate | |
* Zerigo DNS |