Skip to content

Instantly share code, notes, and snippets.

@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
@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
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.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>fb254145378030027</string>
<string>isupr8</string>
<string>fb176151905794941</string>
<string>recipeSearch-iPad</string>
<string>airfile</string>
<string>univision</string>
import Foundation
import XCTest
extension XCTestCase {
/// Waits for an escaping closure to be invoked with a result value for the specified timeout duration and returns the value.
///
/// When using this method, you must trigger work inside the `performWork` closure that invokes the `completion` closure exactly once.
/// Failure to do so within the specified `timeout` will result in an error being thrown.
///
/// ```swift
@liamnichols
liamnichols / sign_in_with_apple.yml
Created February 21, 2020 14:53
Localisations of the "Sign in with Apple" string taken from Xcode 11.1
SIGN_IN_WITH_APPLE:
- de: Mit Apple anmelden
- he: התחברות באמצעות Apple
- en_AU: Sign in with Apple
- ar: تسجيل الدخول باستخدام Apple
- el: Σύνδεση μέσω Apple
- ja: Appleでサインイン
- en: Sign in with Apple
- uk: Увійти з Apple
- es_419: Iniciar sesión con Apple
@liamnichols
liamnichols / gist:7505120
Last active July 8, 2022 22:32
Detects iBeacons in the area and parses their data (mac app using CBCentralManager)
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.manager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:nil];
}
-(void)centralManagerDidUpdateState:(CBCentralManager *)central
{
if (self.manager.state == CBCentralManagerStatePoweredOn)
{
[self.manager scanForPeripheralsWithServices:nil options:nil];
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "StaticSwiftSyntaxParser",
products: [
.library(name: "StaticSwiftSyntaxParser", type: .static, targets: ["StaticSwiftSyntaxParser"])
],
@liamnichols
liamnichols / UIImage+ImageEffects.h
Created November 5, 2013 12:32
Apples UIImage category for creating blurred UIImages
/*
File: UIImage+ImageEffects.h
Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur.
Version: 1.0
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or