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
/*: | |
This is a concept re-implementation of the @Binding and @State property wrappers from SwiftUI | |
The only purpose of this code is to implement those wrappers myself | |
just to understand how they work internally and why they are needed, | |
⚠️ This is not supposed to be a reference implementation nor cover all | |
subtleties of the real Binding and State types. | |
The only purpose of this playground is to show how re-implementing | |
them myself has helped me understand the whole thing better |
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
// #!Swift-1.1 | |
import Foundation | |
// MARK: - (1) classes | |
// Solution 1: | |
// - Use classes instead of struct | |
// Issue: Violate the concept of moving model to the value layer | |
// http://realm.io/news/andy-matuschak-controlling-complexity/ |
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
struct Contact: Decodable, CustomStringConvertible { | |
var id: String | |
@NestedKey | |
var firstname: String | |
@NestedKey | |
var lastname: String | |
@NestedKey | |
var address: String | |
enum CodingKeys: String, NestableCodingKey { |
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
#!/bin/bash | |
#->Usage: launch_ipa.sh <PATH.app> [DEVICE_TYPE] [IOS_RUNTIME] | |
#-> | |
#-> Create a new simulator, install the app in it, launch it, wait 20s then kill it. | |
#-> The main purpose of this script is to just launch an app and let the applicationDidFinishLaunching… callback be called | |
#-> | |
#-> - [DEVICE_TYPE] the model of simulator to use. See `xcrun simctl list devicetypes` for the full list. Defaults to 'iPhone-6s' | |
#-> Note: You just need to provide the last part of the full device ID from | |
#-> com.apple.CoreSimulator.SimDeviceType.<DEVICE_TYPE> |
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 SwiftUI | |
import UIKit | |
import CoreImage | |
import PlaygroundSupport | |
extension CIImage { | |
convenience init(_ uiImage: UIImage) { | |
if let cgImage = uiImage.cgImage { | |
self.init(cgImage: cgImage) |
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
// Coordinator.swift | |
import Foundation | |
public protocol Coordinator: class { | |
var components: CoordinatorComponents { get } | |
/// Set up here everything that needs to happen just before the Coordinator is presented | |
/// | |
/// - Parameter modalSetup: A parameter you can use to customize the default mainViewController's |
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
struct Coordinator { | |
let window: UIWindow | |
let navCtrl: UINavigationController? | |
func start() { | |
presentWelcomeScreen() | |
} | |
private func presentWelcomeScreen() { | |
let vc = WelcomeScreenViewController() // Instanciate from code, XIB, Storyboard, whatever your jam is |
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 | |
// Create a view to display the result in playground | |
let view = UIView(frame: CGRect(x: 0, y: 0, width: 500, height: 500)) | |
view.backgroundColor = .white | |
PlaygroundPage.current.liveView = view; |
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
#!/bin/bash -euo pipefail | |
# | |
# Author: O.Halligon | |
# Jan 2021 | |
# | |
# Help | |
if [ "${1:-}" == "-h" -o "${1:-}" == "--help" ]; then | |
BASENAME=${0##*/} |
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
struct CountedSet<Element: Hashable> { | |
private var storage: [Element: Int] = [:] | |
} | |
/// Creating a CountedSet from a Dictionary or DictionaryLiteral | |
/// | |
/// let example: CountedSet = ["a": 1, "b": 3, "c": 42] | |
extension CountedSet: ExpressibleByDictionaryLiteral { | |
init(dictionaryLiteral elements: (Element, Int)...) { | |
self.storage = Dictionary(uniqueKeysWithValues: elements) |
NewerOlder