Skip to content

Instantly share code, notes, and snippets.

View artemkrachulov's full-sized avatar

Artem Krachulov artemkrachulov

View GitHub Profile
extension ObservableType {
func flatMap<A: AnyObject, O: ObservableType>(weak obj: A, selector: @escaping (A, Self.E) throws -> O) -> Observable<O.E> {
return flatMap { [weak obj] value -> Observable<O.E> in
try obj.map { try selector($0, value).asObservable() } ?? .empty()
}
}
func flatMapFirst<A: AnyObject, O: ObservableType>(weak obj: A, selector: @escaping (A, Self.E) throws -> O) -> Observable<O.E> {
return flatMapFirst { [weak obj] value -> Observable<O.E> in
import Foundation
// Very slightly adapted from http://stackoverflow.com/a/30141700/106244
// 99.99% Credit to Martin R!
// Mapping from XML/HTML character entity reference to character
// From http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references
private let characterEntities : [String: Character] = [
// XML predefined entities:
@aGupieWare
aGupieWare / phplumbing_bare_bones_api
Created October 25, 2014 21:10
A bare-bones RESTful API interface . . .
<?php
/*
Plumbing Supply House API -- Super PHPlumbing Bros. Inc.
This script provides a RESTful API interface for a web application
Input:
$_GET['format'] = [ json | html | xml ]
$_GET['method'] = []
Output: A formatted HTTP response