Skip to content

Instantly share code, notes, and snippets.

@agiletortoise
agiletortoise / example.swift
Created August 24, 2023 18:56
Intent Dependency
// create an object to inject
struct AppIntentDependencyManager {
func hello() {}
// whatever methods you need....
}
// in didFinishLaunching or similar inject your dependency like...
if #available(iOS 16.0, *) {
AppDependencyManager.shared.add(key: "AppIntentDependencyManager", dependency: AppIntentDependencyManager())
@agiletortoise
agiletortoise / view+background.swift
Created July 31, 2023 16:13
Useful way to provide backward compatible widget backgrounds
extension View {
@ViewBuilder
func widgetBackground<V>(@ViewBuilder content: () -> V) -> some View where V : View {
if #available(macOSApplicationExtension 14.0, iOSApplicationExtension 17.0, *) {
containerBackground(for: .widget) {
content()
}
} else {
background {
content()
@agiletortoise
agiletortoise / GitHub Style.html
Created March 29, 2019 15:33
Example preview template for Drafts for Mac. Place file in /iCloud Drive/Drafts/Library/Templates to make it available.
<html>
<!--
Based on https://github.com/sindresorhus/github-markdown-css
-->
<head>
<style>
@font-face {
font-family: octicons-link;
src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAZwABAAAAAACFQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEU0lHAAAGaAAAAAgAAAAIAAAAAUdTVUIAAAZcAAAACgAAAAoAAQAAT1MvMgAAAyQAAABJAAAAYFYEU3RjbWFwAAADcAAAAEUAAACAAJThvmN2dCAAAATkAAAABAAAAAQAAAAAZnBnbQAAA7gAAACyAAABCUM+8IhnYXNwAAAGTAAAABAAAAAQABoAI2dseWYAAAFsAAABPAAAAZwcEq9taGVhZAAAAsgAAAA0AAAANgh4a91oaGVhAAADCAAAABoAAAAkCA8DRGhtdHgAAAL8AAAADAAAAAwGAACfbG9jYQAAAsAAAAAIAAAACABiATBtYXhwAAACqAAAABgAAAAgAA8ASm5hbWUAAAToAAABQgAAAlXu73sOcG9zdAAABiwAAAAeAAAAME3QpOBwcmVwAAAEbAAAAHYAAAB/aFGpk3jaTY6xa8JAGMW/O62BDi0tJLYQincXEypYIiGJjSgHniQ6umTsUEyLm5BV6NDBP8Tpts6F0v+k/0an2i+itHDw3v2+9+DBKTzsJNnWJNTgHEy4BgG3EMI9DCEDOGEXzDADU5hBKMIgNPZqoD3SilVaXZCER3/I7AtxEJLtzzuZfI+VVkprxTlXShWKb3TBecG11rwoNlmmn1P2WYcJczl32etSpKnziC7lQyWe1smVPy/Lt7Kc+0vWY/gAgIIEqAN9we0pwKXreiMasxvabDQMM4riO+qxM2ogwDGOZTXxwxDiycQIcoYFBLj5K3EIaSctAq2kTYiw+ymhce7vwM9jSqO8JyVd5RH9g
@agiletortoise
agiletortoise / ViewController.swift
Created October 5, 2017 15:20
How to update input accessory view to handle iPhone X with external keyboard
//
// ViewController.swift
// TEST_InputViewX
//
// Created by Greg Pierce on 10/5/17.
// Copyright © 2017 Agile Tortoise. All rights reserved.
//
// Demonstrates how to update an input accessory view
// to work on iPhone X with external keyboard attached
// using safe area insets.
// RATER MODULE for Appcelerator Titanium
/*
WHAT IS IT:
Create a cycling reminder to go rate your app at the App Store. Tracks
the app launch count, and reminds the user every 20 launches (configurable) to
rate the app, with a click to launch the app page in the App Store.
Reminders stop if the user clicks the "Rate Now" or "Don't Remind Me" options.
USAGE:
@agiletortoise
agiletortoise / PointerEnabledButton.swift
Created March 24, 2020 20:00
PointerEnabledButton class demonstrating pointer support for iPadOS 13.4
import UIKit
class PointerEnabledButton: UIButton {
override init(frame: CGRect) {
super.init(frame: frame)
if #available(iOSApplicationExtension 13.4, *) {
enablePointer()
}
}
@agiletortoise
agiletortoise / content.md
Created May 6, 2020 14:03
Gist from Drafts

This is bold test.

@agiletortoise
agiletortoise / fileName
Created May 6, 2020 13:58
Gist from Drafts
This **is bold** test.
@agiletortoise
agiletortoise / content.md
Created May 6, 2020 13:46
Gist from Drafts

This is bold test.

var pathForContextualMenuPointer: UIBezierPath {
let combinedShape = UIBezierPath()
combinedShape.move(to: CGPoint(x: 12.5, y: 0))
combinedShape.addCurve(to: CGPoint(x: 25, y: 12.5), controlPoint1: CGPoint(x: 19.4, y: 0), controlPoint2: CGPoint(x: 25, y: 5.6))
combinedShape.addLine(to: CGPoint(x: 25, y: 12.5))
combinedShape.addLine(to: CGPoint(x: 25, y: 23.01))
combinedShape.addCurve(to: CGPoint(x: 23.02, y: 25), controlPoint1: CGPoint(x: 25, y: 24), controlPoint2: CGPoint(x: 24, y: 25))
combinedShape.addLine(to: CGPoint(x: 23.02, y: 25))
combinedShape.addLine(to: CGPoint(x: 12.5, y: 25))