Skip to content

Instantly share code, notes, and snippets.

import Combine
@_functionBuilder
struct FlatMapBuilder {
static func buildBlock<C: Publisher>(_ component: C) -> C
{
component
}
static func buildEither<F: Publisher, S: Publisher>(first component: F) -> EitherPublisher<F, S>
@sidepelican
sidepelican / sheet2.csv
Last active March 25, 2021 02:58
BackgroundTasks調査
サーバ日付 id value
2021/03/24 11:03:04 testing4 0
2021/03/24 11:03:04 testing1 0
2021/03/24 11:04:07 testing4 1
2021/03/24 11:04:07 testing1 1
2021/03/24 11:04:08 testing2 1
2021/03/24 11:05:11 testing1 2 私物iPadでスケジュール中。電源に接続されたりされてなかったり、他のアプリを起動してたりしてなかったりする
2021/03/24 11:05:11 testing4 2
2021/03/24 11:05:12 testing2 2
2021/03/24 11:05:13 testing3 2 〜ここでバックグラウンドにした〜
import Foundation
public struct Airport: Codable {
let name: String
let iata: String
let icao: String
let coordinates: [Double]
public struct Runway: Codable {
enum Surface: String, Codable {
import DiffableDataSources
import UIKit
class CollectionViewConcatDataSource<SectionIdentifierType: Hashable>: NSObject, UICollectionViewDataSource {
typealias ItemIdentifierType = AnyHashable
public typealias SupplementaryViewProvider = (UICollectionView, String, IndexPath) -> UICollectionReusableView?
private var innerDataSource: CollectionViewDiffableDataSource<SectionIdentifierType, AnyHashable>!
private var adapterMap: [SectionIdentifierType: DiffableDataSourceSectionAdapterType] = [:]
var defaultSupplementaryViewProvider: SupplementaryViewProvider? = nil
class A {
class var className: String { "A" }
init() {}
func setup() {
name = {
return Self.className
}
}
var name: (() -> String)?
}
extension ObservableType where Element == Void {
func pagenation<
Token,
Source: ObservableConvertibleType,
PagingElement
>(
startWith token: Token,
selector: @escaping (Token) throws -> Source
) -> Observable<(usedToken: Token, PagingElement)>
where
@sidepelican
sidepelican / Iconv.swift
Created May 2, 2020 14:13
uses libiconv.2.tbd, swift5.2
import Darwin.POSIX.iconv
class Iconv {
enum Error: Swift.Error {
case illegalByteSequence
case invalidArgument
case invalidResult
case unknownError(errno: Int32)
}
@sidepelican
sidepelican / main.rs
Created December 29, 2019 15:09
generics function overload
use std::marker::PhantomData;
struct T<A> {
_phantom: PhantomData<A>,
}
impl<U> T<&[U]> {
fn f(_: &[U]) {
println!("f(_: &[U])")
}
import RxSwift
import RxCocoa
import UIKit
extension SharedSequence {
func assertStartWithEvent(file: StaticString = #file, line: UInt = #line) -> Self {
let deadline = Observable<Element>.create { observer -> Disposable in
fatalError("Event didn't come immediately after subscribe.", file: file, line: line)
}
.delaySubscription(.nanoseconds(0), scheduler: SharingStrategy.scheduler)
@sidepelican
sidepelican / TypeExtract.swift
Created September 17, 2019 14:04
雪だるま型パラから型を順番に取り出すやつ
import Foundation
protocol _View {
static var specialType: Any.Type { get }
}
protocol View: _View {
associatedtype Body: View
associatedtype Special
var body: Body { get }