This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Game { | |
public $espn_id, $date, $home_team, $visiting_team, $home_score, $visiting_score, $is_preseason; | |
} | |
$urls = build_URLs(); | |
$games = array(); | |
foreach ($urls as $url) { | |
$games = array_merge($games, get_games($url)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
protocol Segmentable: RawRepresentable & CaseIterable { } | |
class EnumeratedSegmentedControl<T: Segmentable>: UISegmentedControl where T.RawValue == String { | |
convenience init() { | |
let items = T.allCases.map { $0.rawValue } | |
self.init(items: items) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
func addInputAccessoryForTextFields(textFields: [UITextField], dismissable: Bool = true, previousNextable: Bool = false) { | |
for (index, textField) in textFields.enumerate() { | |
let toolbar: UIToolbar = UIToolbar() | |
toolbar.sizeToFit() | |
var items = [UIBarButtonItem]() | |
if previousNextable { | |
let previousButton = UIBarButtonItem(image: UIImage(named: "Backward Arrow"), style: .Plain, target: nil, action: nil) | |
previousButton.width = 30 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIViewController { | |
func addDismissingInputAccessoryToTextField(textField: UITextField) { | |
let doneButton = UIBarButtonItem(barButtonSystemItem: .Done, target: view, action: #selector(UIView.endEditing)) | |
let toolbar: UIToolbar = UIToolbar() | |
toolbar.sizeToFit() | |
let spacer = UIBarButtonItem(barButtonSystemItem: .FlexibleSpace, target: nil, action: nil) | |
toolbar.setItems([spacer, doneButton], animated: false) | |
textField.inputAccessoryView = toolbar | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
class Photo { | |
let title: String | |
init(title: String) { | |
self.title = title | |
} | |
} |