Skip to content

Instantly share code, notes, and snippets.

View liamnichols's full-sized avatar
💭
I may be slow to respond.

Liam Nichols liamnichols

💭
I may be slow to respond.
View GitHub Profile
@liamnichols
liamnichols / Example.swift
Last active March 14, 2024 12:22
Embed a SwiftUI view inside a UITextView/UITextField inputAccessoryView to present it above the keyboard
import SwiftUI
import UIKit
class ViewController: UIViewController {
private lazy var textField: UITextField = {
let textField = UITextField()
textField.borderStyle = .roundedRect
textField.translatesAutoresizingMaskIntoConstraints = false
textField.setInputAccessoryView(height: 56) {
ScrollView(.horizontal) {
require_relative './helpers/config_item_validation_helpers'
require 'trainer'
module Fastlane
module Actions
class ExportBitriseTestReportAction < Action
extend ConfigItemValidationHelpers
class Runner
attr_reader :name, :xcresult_path, :test_result_dir, :deploy_dir
import Foundation
public struct Localizer {
/// Returns the best match localized string for the given locale based on the languages available as part of the bundle.
///
/// This method is similar to the system `NSLocalizedString(_:tableName:bundle:value:comment:)` function, but its resolution is much more granular.
///
/// With `NSLocalizedString`, if the current language is missing a phrase for the specified `key`, it would return the `value`, or the `key` even if the bundle contained the phrase in a different (but relevant) language.
///
/// Using this method, a lookup list will be made using `Bundle.preferredLocalizations(from:forPreferences:)` instead, and each language in the order of most preferable will be searched instead.
@liamnichols
liamnichols / README.md
Created January 30, 2024 10:31
A bit of an overview of issues using offset-based pagination when concerned with mutation of the paginated content

Offset based pagination and mutating lists

Offset pagination offers a simple solution when it comes to paging a collection of data where the contents of the collection infrequently updates.

When using offset-based pagination, the client will specify the page of data that they require, and the size of the page. For example, lets consider requesting letters of the alphabet. When working with a page size of 5, the data will be broken out into the following pages:

Letter | A B C D E  F G H I J  K L M N O  P Q R S T  U V W X Y  Z
 Page  | 1 1 1 1 1  2 2 2 2 2  3 3 3 3 3  4 4 4 4 4  5 5 5 5 5  6
@liamnichols
liamnichols / RefreshControl.swift
Last active June 24, 2024 10:38
A UIRefreshControl subclass that you can start animating before adding to the view hierarchy without worrying about broken animations and what not
import UIKit
/// A subclass that improves the usability of `UIRefreshControl` by:
///
/// 1. Providing the `isRefreshing` boolean binding.
/// 2. Deferring calls to `beginRefreshing()` until the time of appearance to avoid glitches.
/// 3. Automatically scrolling the parent scrollView to reveal the refresh control when scrolled to the top.
///
/// When using this subclass, you should not use ``beginRefreshing()`` or ``endRefreshing()`` and instead set the ``isRefreshing`` property to show and hide the refresh control.
///