Skip to content

Instantly share code, notes, and snippets.

View macbellingrath's full-sized avatar

Mac Bellingrath macbellingrath

View GitHub Profile
@macbellingrath
macbellingrath / String+Palindrome.swift
Last active October 17, 2018 14:30
10/16/18 - Johnny from FB
import Foundation
extension String {
/// Returns true if a string is a valid palindrome.
var isPalindrome: Bool {
let scalars = utf16
if scalars.count < 2 { return true }
extension Optional {
func flatMapWith<T, U>(_ other: T?, _ transform: (Wrapped, T) -> U?) -> U? {
guard case .some(let `self`) = self else {
return nil
}
guard let element = other else {
return nil
}
import UIKit
import PlaygroundSupport
class FirstTable: UITableViewController, UIViewControllerTransitioningDelegate {
lazy var animator = TransitionAnimator()
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "reuseID")
@macbellingrath
macbellingrath / ClearHigherOrder.swift
Last active July 9, 2016 16:55
ClearHigherOrder.swift
let pushTopicSubscriptionStates = ["Sports": true, "News": false]
// an array of topics that user is subscribed to
let subscribedUserTopics = pushTopicSubscriptionStates.filter { (_, subscribed) in subscribed }
.map { (topic, _) in topic
}
@macbellingrath
macbellingrath / RACVSRX.swift
Created January 12, 2016 14:57
Comparing ReactiveCocoa with RxSwift
/* RAC*/
let userNameStrings = userNameTextfield
.rac_textSignal()
.toSignalProducer()
.map { text in text as! String }
let passwordStrings = passwordTextfield.rac_textSignal()
.toSignalProducer()
.map { password in password as! String }