Skip to content

Instantly share code, notes, and snippets.

View rwbutler's full-sized avatar

Ross Butler rwbutler

View GitHub Profile
#!/usr/bin/env swift
print("Hello World!")
#!/bin/sh
echo "Hello World!"
@rwbutler
rwbutler / gitHub-actions-with-swift-bash.sh
Created November 14, 2023 18:43
Hello World Bash Script
#!/bin/sh
echo "Hello World!"
@rwbutler
rwbutler / routes.swift
Created January 16, 2023 16:20
Register HealthCheckController in routes.swift
func routes(_ app: Application) throws {
try HealthCheckController().register(with: app.routes)
}
@rwbutler
rwbutler / HealthCheckController.swift
Created January 16, 2023 15:54
HealthCheckController.swift
import Foundation
import Vapor
class HealthCheckController {
/// Returns the word 'Success' to indicate that the service is up and running.
func healthCheck(_ request: Request) throws -> Response {
return Response(status: .ok, headers: [:], body: "Success")
}
}
protocol ViewModel {
func viewDidAppear()
func viewDidDisappear()
}
class SimpleViewModel: ViewModel {
private var cancellables = Set<AnyCancellable>()
private var previousBrightness: Double?
private let screenBrightnessService: ScreenBrightnessService
protocol ScreenBrightnessService3 {
var publisher: ScreenBrightnessPublisher { get }
func set(to value: Double)
}
class UIKitScreenBrightnessService3: ScreenBrightnessService3 {
private let brightnessSubject: CurrentValueSubject<Double, Never>
private var cancellables = Set<AnyCancellable>()
var publisher: ScreenBrightnessPublisher { // i.e. AnyPublisher<Double, Never>
brightnessSubject.eraseToAnyPublisher()
protocol ScreenBrightness: AnyObject {
var brightness: CGFloat { get set }
}
extension UIScreen: ScreenBrightness {}
protocol ScreenBrightnessService2 {
var publisher: ScreenBrightnessPublisher { get }
func set(to value: Double)
}
protocol ScreenBrightness: AnyObject {
var brightness: CGFloat { get set }
}
extension UIScreen: ScreenBrightness {}
protocol ScreenBrightnessService2 {
var publisher: ScreenBrightnessPublisher { get }
func set(to value: Double)
}
typealias ScreenBrightnessPublisher = AnyPublisher<Double, Never>
protocol ScreenBrightnessService1 {
var publisher: ScreenBrightnessPublisher { get }
}
class UIKitScreenBrightnessService1: ScreenBrightnessService1 {
let publisher: ScreenBrightnessPublisher // i.e. AnyPublisher<Double, Never>
init() {