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
from bs4 import BeautifulSoup | |
# Run: | |
# $ pip install beautifulsoup4 | |
# For more info: https://github.com/linkwarden/linkwarden/issues/555 | |
INPUT_FILE = "pinboard_export.html" | |
def reverse_bookmarks(): |
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 Foundation | |
extension Result { | |
public func flatMap<NewSuccess>( | |
_ transform: (Success) async -> Result<NewSuccess, Failure> | |
) async -> Result<NewSuccess, Failure> { | |
switch self { | |
case let .success(success): | |
await transform(success) | |
case let .failure(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 | |
/// Wraps the content in a ScrollView that only bounces | |
/// if the content size exceeds the visible area; | |
/// and makes the content fill the ScrollView if desired. | |
/// Per default, the content fills the ScrollView only | |
/// vertically. | |
/// | |
/// Usage: | |
/// |
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
// MIT License | |
// | |
// Copyright (c) 2022 Manuel Maly | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
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 Foundation | |
/// Provides a safe stream of `values`. | |
public struct AsyncPassthroughSubject<T> { | |
public let values: AsyncStream<T> | |
private let input: AsyncStream<T>.Continuation | |
private var isFinished = false | |
public init( | |
bufferingPolicy: AsyncStream<T>.Continuation.BufferingPolicy = .unbounded |
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
public extension Task { | |
/// Cancels this `Task` when the surrounding `Task` is cancelled. | |
/// This is necessary if `Task {}` and `Task.detached {}` | |
/// should be automatically cancelled - otherwise, such Tasks | |
/// just run until finished. | |
/// | |
/// Usage: | |
/// | |
/// await Task { await myAsyncFunc() }.autoCancel() | |
func autoCancel() async -> Void { |
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 Foundation | |
// Props to @pteasima and @MichalKleinJr: | |
// https://twitter.com/pteasima/status/1544723987606929408?s=21&t=JL1oIuL87Ms_VPBQBZQ7Rg | |
public extension AsyncSequence { | |
func eraseToAsyncStream() -> AsyncStream<Element> { | |
return AsyncStream { continuation in | |
let task = Task { | |
do { | |
for try await value in self { |
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
When setting `foregroundStyle` on a `AxisValueLabel`, the rendered text color does not change. | |
Example Code: | |
``` | |
Chart([(0,0), (1,1), (2, 2), (3, 3), (4, 4)], id: \.0) { point in | |
LineMark(x: .value("X", point.0), y: .value("Y", point.1)) | |
} | |
.chartYAxis { | |
AxisMarks { _ in |
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 Foundation | |
import UIKit | |
/// Renders the first page of the given PDF file to a `UIImage`. If | |
/// `maxLength` is given, then the resulting image is scaled to a | |
/// matching size. | |
/// | |
/// Example: If `maxLength` is set to `100.0`, this might result in | |
/// the following dimensions (since aspect ratio is preserved): | |
/// |
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
// Original version from the authors of ComposableArchitecture here: | |
// https://github.com/pointfreeco/isowords/blob/fcff52ccf176f40db55951d5897def7cd9b879cf/Sources/TcaHelpers/OnChange.swift | |
// | |
// The following adds a method for filtering changes with a predicate. | |
// This is written using reactiveswift-composable-architecture, but can be adapted very quickly for Combine. | |
import ComposableArchitecture | |
import ReactiveSwift | |
public extension Reducer { |
NewerOlder