This file contains hidden or 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/sh | |
# usage: | |
# ql /tmp/file.jpg | |
# cat /tmp/file.jpg | ql | |
# cal -h | ql | |
if [ -z "$*" ]; then | |
cat > /tmp/ql.stdin | |
mime_type=$(file --brief --mime-type /tmp/ql.stdin) |
This file contains hidden or 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
// | |
// Shell.swift | |
// | |
// Created by Tanner Bennett on 6/25/22. | |
// Copyright Tanner Bennett (c) 2022 | |
// | |
import Foundation | |
extension StringProtocol { |
This file contains hidden or 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 | |
class Base: UIViewController { | |
func mySomeAsyncSequence() -> AsyncStream<String> { | |
fatalError() | |
} | |
func use(_ value: String) { | |
print(value) | |
} |
This file contains hidden or 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
// | |
// ConcurrencyNFCApp.swift | |
// ConcurrencyNFC | |
// | |
// Created by treastrain on 2021/08/28. | |
// | |
import SwiftUI | |
import CoreNFC |
This file contains hidden or 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
extension Array { | |
func parallelMap<T>(transform: (Element) -> T) -> [T] { | |
var result = ContiguousArray<T?>(repeating: nil, count: count) | |
return result.withUnsafeMutableBufferPointer { buffer in | |
DispatchQueue.concurrentPerform(iterations: buffer.count) { idx in | |
buffer[idx] = transform(self[idx]) | |
} | |
return buffer.map { $0! } | |
} | |
} |
This file contains hidden or 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
extension Result { | |
public func `catch`(_ handler: () throws -> Success) -> Result<Success, Error> { | |
flatMapError { _ in | |
.init { try handler() } | |
} | |
} | |
public func `catch`(_ handler: (Failure) throws -> Success) -> Result<Success, Error> { | |
flatMapError { error in | |
.init { try handler(error) } |
This file contains hidden or 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 MapKit | |
struct ContentView: View { | |
@State private var region = MKCoordinateRegion( | |
// Apple Park | |
center: CLLocationCoordinate2D(latitude: 37.334803, longitude: -122.008965), | |
span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01) | |
) |
This file contains hidden or 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
// | |
// AppDelegate.swift | |
// StatusBarTest | |
// | |
// Created by hiroki on 2021/02/11. | |
// | |
import UIKit | |
import SwiftUI |
This file contains hidden or 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 | |
// Create color using P3 color space | |
let linearColor = UIColor(displayP3Red: 1, green: 0.5, blue: 0.2, alpha: 1) | |
do { | |
var r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0 | |
linearColor.getRed(&r, green: &g, blue: &b, alpha: &a) | |
print(r, g, b, a) // 1.07, 0.46, 0.0, 1.0 - not the expected values | |
} |
This file contains hidden or 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 Firebase | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { | |
FirebaseApp.configure() | |
return true | |
} | |
} |