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
/** | |
* An object with different URLs to fetch | |
* @param {Object} ORIGINS | |
*/ | |
const ORIGINS = { | |
"darknews.ericlewis.workers.dev": "news.ycombinator.com" | |
} | |
async function handleRequest(request) { | |
const url = new URL(request.url) |
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
// | |
// StoreKit+Combine.swift | |
// | |
// Created by Eric Lewis on 12/11/20. | |
// | |
import StoreKit | |
import Combine | |
extension SKCloudServiceController { |
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 fetchOrder(type: FeedType) { | |
DispatchQueue.global(qos: .userInitiated).async { | |
let context = PersistenceController.shared.container.newBackgroundContext() | |
self.orderCancellable = self.ref.child(type.hackerNewsEndpoint).observeSingleEventPublisher(of: .value) | |
.compactMap { | |
$0.value as? [Int] | |
} | |
.flatMap { orders -> Publishers.Sequence<[Int], Never> in | |
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
extension DatabaseReference { | |
func observeSingleEventPublisher(of eventType: DataEventType) -> AnyPublisher<DataSnapshot, Error> { | |
Future<DataSnapshot, Error> { [weak self] completion in | |
self?.observeSingleEvent(of: eventType) { | |
completion(.success($0)) | |
} | |
} | |
.eraseToAnyPublisher() | |
} | |
} |
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
// | |
// LPMetadataProvider+Combine.swift | |
// Hacker | |
// | |
// Created by Eric Lewis on 9/22/20. | |
// | |
import SwiftUI | |
import LinkPresentation | |
import Combine |
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 LinkPresentation | |
import Combine | |
extension LPMetadataProvider { | |
func startFetchingMetadataPublisher(for url: URL) -> AnyPublisher<LPLinkMetadata?, Error> { | |
Future<LPLinkMetadata?, Error> { completion in | |
self.startFetchingMetadata(for: url) { meta, error in | |
guard let error = error else { | |
return completion(.success(meta)) | |
} |
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 CoreBluetooth | |
protocol ManagerDelegate: AnyObject { | |
func connected() | |
func disconnected() | |
} | |
class BluetoothManager: NSObject, CBCentralManagerDelegate, CBPeripheralDelegate { | |
var centralManager: CBCentralManager! |
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
class Store: ObservableObject { | |
@Published var id: String? = nil | |
init() { | |
id = UserDefaults.standard.string(forKey: "key") | |
let _ = $id.sink { | |
UserDefaults.standard.set(id, forKey: "key") | |
} | |
} |
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 | |
import XcodeGenKit | |
import ProjectSpec | |
import XcodeProj | |
import PathKit | |
import Files | |
import SwiftSyntax | |
enum Errors: Error { | |
case MainNotModified |
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 | |
extension Int: Identifiable { | |
public var id: Self { | |
self | |
} | |
} | |
struct HList<C: RandomAccessCollection, V: View>: View where C.Element: Identifiable { | |
var data: C |