This file contains 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
disabled_rules: | |
- trailing_comma | |
opt_in_rules: | |
- file_header | |
file_header: | |
forbidden_pattern: /./ | |
custom_rules: | |
state_private: | |
name: "Private SwiftUI State" | |
regex: "\\@State\\s*var" |
This file contains 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 | |
import WebKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Configure the web view for JavaScript injection | |
configureWebView() |
This file contains 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 | |
/// A validation rule for text input. | |
public enum TextValidationRule { | |
/// Any input is valid, including an empty string. | |
case noRestriction | |
/// The input must not be empty. | |
case nonEmpty | |
/// The enitre input must match a regular expression. A matching substring is not enough. | |
case regularExpression(NSRegularExpression) |
This file contains 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
// | |
// UserDefaults.swift | |
// | |
// Created by Shaps Benkau on 24/05/2018. | |
// Copyright © 2018 152percent Ltd. All rights reserved. | |
// | |
import Foundation | |
#if os(iOS) |
This file contains 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 | |
extension DateFormatter { | |
static let iso8601Full: DateFormatter = { | |
let formatter = DateFormatter() | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" | |
formatter.calendar = Calendar(identifier: .iso8601) | |
formatter.timeZone = TimeZone(secondsFromGMT: 0) | |
formatter.locale = Locale(identifier: "en_US_POSIX") | |
return formatter |
This file contains 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
func polygon(){ | |
// Create a rectangular path | |
let rect = GMSMutablePath() | |
rect.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.0)) | |
rect.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.0)) | |
rect.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.2)) | |
rect.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.2)) | |
// Create the polygon, and assign it to the map. | |
let polygon = GMSPolygon(path: rect) |
This file contains 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 | |
import PlaygroundSupport | |
// https://gist.github.com/erica/6f13f3043a330359c035e7660f3fe7f5 | |
// Original Video: https://www.youtube.com/watch?v=TTmWUSgNOHk | |
// Video: https://www.youtube.com/watch?v=hmAB3WJOQTU | |
// Video: https://www.youtube.com/watch?v=DWtavuvmKdw (with zoom and fade) | |
// String to animate and its attributes | |
var string = "Hello, playground" | |
let attributes: [String: Any] = [ |
This file contains 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
// A Gist. | |
struct Gist { | |
let id: String | |
} | |
typealias JSONDictionary = [String: AnyObject] | |
// These methods are "helpers" to transform Data -> JSON -> Result<[Gist]> | |
func jsonFrom(data: Data) -> Result<AnyObject> { | |
let json = try! JSONSerialization.jsonObject(with: data, options: []) |
This file contains 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
/*: | |
Stuff from [Crustacean](https://developer.apple.com/sample-code/wwdc/2015/?q=protocol). | |
(Wish I could hide this in a single-file playground somehow.) | |
*/ | |
import CoreGraphics | |
protocol Renderer { | |
func moveTo(position: CGPoint) | |
func lineTo(position: CGPoint) | |
func arcAt(center: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat) |
NewerOlder