Skip to content

Instantly share code, notes, and snippets.

View alanf's full-sized avatar

Alan Fineberg alanf

View GitHub Profile
// Set a new `value` and a the `interpolatedSignal` will emit a number of values between our current `value` and the new `value`.
import Foundation
import ReactiveKit
class InterpolatedFloat {
private let bag = DisposeBag()
let interpolationPeriod: TimeInterval
let interpolationSteps: Int
private var oldValue: Float = 0.0
import UIKit
@IBDesignable class RoundedButton: UIButton {
// https://stackoverflow.com/questions/29618760/create-a-rectangle-with-just-two-rounded-corners-in-swift
override func awakeFromNib() {
super.awakeFromNib()
let roundedButtonFont = UIFont(name: "Montserrat-Bold", size: 14) ?? UIFont.boldSystemFont(ofSize: 14)
titleLabel?.font = roundedButtonFont
class ExampleUsage: SimpleAlertDelegate {
private func configureRestPeriodAlert(lastStimulationTime: Date) -> SimpleAlertViewController {
let alertStoryboard = UIStoryboard(name: "Alert", bundle: Bundle.main)
guard let alertViewController = alertStoryboard.instantiateViewController(withIdentifier: "Alert") as? SimpleAlertViewController else { fatalError() }
alertViewController.modalTransitionStyle = .coverVertical
alertViewController.modalPresentationStyle = .overCurrentContext
let viewModel = SimpleAlertViewController.ViewModel()
viewModel.title.value = NSLocalizedString("RestPeriodAlertTitle", tableName: "", bundle: Bundle.main, value: "Rest Period", comment: "Title for alert which recommends waiting between Neuropriming sessions.")
import Foundation
import ReactiveKit
import Bond
import UIKit
protocol SimpleAlertDelegate: class {
func didTapSecondaryButton(alertViewController: SimpleAlertViewController)
func didTapPrimaryButton(alertViewController: SimpleAlertViewController)
}
import Foundation
import UIKit
@IBDesignable class GradientView: UIView {
let titleLabel = UILabel()
@IBInspectable var title: String? = nil {
didSet {
titleLabel.text = title
//
// UnderlinedTextField.swift
// Halo
//
// Created by Alan Fineberg on 7/25/17.
//
//
import Foundation
import ReactiveKit
import ReactiveKit
import UIKit
class ViewController: UIViewController {
// ... snip ...
override func viewDidLoad() {
super.viewDidLoad()
viewModel.email.map { email in
return email?.address
import ReactiveKit
import UIKit
class UnderlinedTextField: UITextField {
@IBOutlet weak var underlineView: UIView!
override func awakeFromNib() {
super.awakeFromNib()
func testLogBreadcrumbs() {
let recorder = FakeRecorder()
let logger = BreadcrumbLogger(recorder: recorder)
let breadcrumbs = createBreadcrumbs()
logger.logBreadcrumbs(breadcrumbs: breadcrumbs)
let firstRecord = JSON(data: recorder.testRecords[0])
XCTAssertEqual(firstRecord["breadcrumb"], "testdata")
// ... Additional checks omitted for brevity ...
class BreadcrumbLogger {
private let recorder: BreadcrumbRecordable
init(recorder: BreadcrumbRecordable = AWSFirehoseRecorder.default()) {
self.recorder = recorder
}
private func breadcrumbDictionary(breadcrumb: Breadcrumb) -> Dictionary<String, AnyObject?> {
let breadcrumbDictionary: Dictionary<String, AnyObject?> = [:]