Skip to content

Instantly share code, notes, and snippets.

import CloudKit
import Combine
/// Fetches the user's CloudKit Account status.
///
/// - Parameter container: The container to check the status in.
///
/// - Returns: A deferred future that resolves to the user's CloudKit Account status.
func getAccountStatus(for container: CKContainer) -> AnyPublisher<CKAccountStatus, Error> {
Deferred {
extension Reducer {
/// Wraps a reducer to inject a debounced action back into the reducer.
///
/// Use this higher order reducer when you want to schedule some work to happen after any other action is recieved by
/// the reducer.
///
/// **Usage:**
/// ```
/// otherReducer.debounceReactiveAction(
/// id: DebounceID(),
/**
This sample code is available under the MIT license.
*/
@available(iOS 12.0, *)
public final class ShortcutManager {
/**
This enum specifies the different intents available in our app and their various properties for the `INIntent`.
Replace this with your own shortcuts.
@simme
simme / CKError.swift
Created June 9, 2021 14:05
CloudKit publishers
import CloudKit
extension Error {
/// `true` if the error represents a CloudKit conflict.
var isCloudKitConflictError: Bool {
(self as? CKError).map { $0.code == CKError.Code.serverRecordChanged } ?? false
}
/// `true` if the error represents a CloudKit zone deleted error.
@simme
simme / UITextView+FadeLast.swift
Last active April 25, 2021 21:57
Fades the last line of a `UITextView` horizontally, instead of truncating it.
extension UITextView {
var lineFrames: [CGRect] {
let numberOfGlyphs = layoutManager.numberOfGlyphs
var numberOfLines = 0
var index = 0
var lineRange = NSRange()
let maxNumberOfLines = textContainer.maximumNumberOfLines
var lineRects = [CGRect]()
while (index < numberOfGlyphs) {
@simme
simme / StateStoreCell.swift
Created December 10, 2020 14:40
Composable Architecutre helpers
import Combine
import ComposableArchitecture
import UIKit
/// The state store cell is a cell superclass designed to work with Composable Architecture state stores. It removes
/// much of the boiler plate involved with creating a custom cell subclass.
open class StateStoreCell<State: Equatable, Action>: UICollectionViewCell {
// MARK: Properties
/**
A default implmentation that provides a few convenience methods for starting and stopping coordinators.
*/
extension Coordinator {
// Default implementation, so that we don't have to do this for all coordinators.
func startChild<T: NSObject where T: Coordinator>(coordinator coordinator: T, withIdentifier identifier: String, callback: CoordinatorCallback?) -> T {
childCoordinators[identifier] = coordinator
coordinator.start(withCallback: callback)
return coordinator
//
// ParallaxHeader.swift
// MealPlanUI
//
// Created by Simon Ljungberg on 2017-11-15.
// Copyright © 2017 Filibaba. All rights reserved.
//
import Foundation
import UIKit

Keybase proof

I hereby claim:

  • I am simme on github.
  • I am simmelj (https://keybase.io/simmelj) on keybase.
  • I have a public key ASADuVzngznoJZLHqpiRN_Xf1Ky1CmfWOBrffVicRrhCRAo

To claim this, I am signing this object:

" Use Vim settings
set nocompatible
set encoding=utf-8
" Use , as leader
let mapleader=","
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()