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
@propertyWrapper | |
struct ClampedValue<F: FloatingPoint> { | |
var value: F | |
let min: F? | |
let max: F? | |
init(wrappedValue: F, min: F? = nil, max: F? = nil) { | |
value = wrappedValue | |
self.min = min | |
self.max = max | |
} |
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
/* | |
// | |
// xcode-dark-mode.css | |
// Xcode Dark Mode | |
// | |
// Created by Hexagons on 2020-06-11. | |
// http://hexagons.net/ | |
// | |
*/ |
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
public extension UIDevice { | |
static let modelName: String = { | |
var systemInfo = utsname() | |
uname(&systemInfo) | |
let machineMirror = Mirror(reflecting: systemInfo.machine) | |
let identifier = machineMirror.children.reduce("") { identifier, element in | |
guard let value = element.value as? Int8, value != 0 else { return identifier } | |
return identifier + String(UnicodeScalar(UInt8(value))) | |
} |
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 | |
struct BlurView: UIViewRepresentable { | |
let style: UIBlurEffect.Style | |
func makeUIView(context: UIViewRepresentableContext<BlurView>) -> UIVisualEffectView { | |
UIVisualEffectView(effect: UIBlurEffect(style: style)) | |
} |
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 csv(named name: String) -> [[String]]? { | |
guard let url: URL = Bundle.main.url(forResource: name, withExtension: "csv") else { return nil } | |
return csv(url: url) | |
} | |
func csv(url: URL) -> [[String]]? { | |
guard let text: String = try? String(contentsOf: url) else { return nil } | |
return csv(text: text) | |
} |
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 | |
fileprivate let badChars = CharacterSet.alphanumerics.inverted | |
public extension String { | |
var camelToTitleCased: String { | |
if self.count <= 1 { | |
return self.uppercased() | |
} |
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 | |
struct DileView<Content: View>: View { | |
let kColCount: Int = 3 | |
let scale: CGFloat | |
let defaultIndex: Int | |
let options: () -> ([Content]) | |
let selected: (Int) -> () | |
@State var index: Int = 0 | |
@State var open: Bool = false |
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
PixelKit.main.bits = ._16 | |
let ply = PolygonPIX() | |
ply.radius = 0.125 | |
let feed = ply._feed(0.99) { feed in | |
feed._noiseDisplace(distance: 0.01, zPosition: .live / 10, octaves: 10) | |
} | |
return feed._edge(100)._quantize(0.1)._edge(10) |
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
public enum ImagePlacement { | |
case fill | |
case fit | |
} | |
public static func resize(_ image: UIImage, to size: CGSize, placement: ImagePlacement = .fill) -> UIImage { | |
let frame: CGRect | |
switch placement { | |
case .fit: |
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
// QLPreviewControllerDataSource | |
var medaUrl: URL? | |
// MARK: - Quick Look | |
func quickLook(_ url: URL) { | |
medaUrl = url | |
let previewController = QLPreviewController() | |
previewController.dataSource = self |