Skip to content

Instantly share code, notes, and snippets.

@sturdysturge
sturdysturge / main.swift
Created May 19, 2019 00:35
Command Line Tool with input and output
import Foundation
print("Whatever you say is repeated")
var inputString = String()
while inputString != "quit"
{
inputString = readLine()!
print("You said: \(inputString)")
}
print("The program has ended")
@sturdysturge
sturdysturge / WheelView.swift
Last active July 14, 2020 10:18
WheelView Colour Picker Maker
import SwiftUI
struct RGBAWheelView: WheelPickable {
typealias DataType = RGBAData
let data: DataType
@State var thumbOffset = CGPoint()
var _$thumbOffset: Binding<CGPoint> { $thumbOffset }
let angularGradient: Gradient
let radialGradient: Gradient
init(data: DataType) {
import SwiftUI
extension URL {
func getFromPublisher<T: Codable>(property: inout Published<T>.Publisher) {
URLSession.shared.dataTaskPublisher(for: self)
.receive(on: DispatchQueue.main)
.map(\.data)
.decode(type: T.self, decoder: JSONDecoder())
.assertNoFailure()
.assign(to: &property)
DELETE ME - Must create a new gist with an initial file
We couldn’t find that file to show.