This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: brown; icon-glyph: file-code; | |
// To use this script, you need to configure an OAuth App on GitHub. | |
// Follow the instructions on the link below to create your OAuth App. | |
// | |
// When you are asked to put in a redirect URL, you should put the URL for running this script in Scriptable. Assuming the name of this script is "Create Gist", the URL is scriptable:///run?scriptName=Create%20Gist | |
// | |
// https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/ | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* I needed a property wrapper that fulfilled the following four requirements: | |
* | |
* 1. Values are stored in UserDefaults. | |
* 2. Properties using the property wrapper can be used with SwiftUI. | |
* 3. The property wrapper exposes a Publisher to be used with Combine. | |
* 4. The publisher is only called when the value is updated and not | |
* when_any_ value stored in UserDefaults is updated. | |
* | |
* First I tried using SwiftUI's builtin @AppStorage property wrapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: deep-purple; icon-glyph: apple-alt; | |
const TITLE = "One More Thing" | |
const DATE = "2020-11-10T17:00:00Z" | |
const IMG_URL = "https://i.ibb.co/f2SN2Wb/bg.png" | |
let widget = await createWidget() | |
if (config.runsInWidget) { | |
Script.setWidget(widget) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final class ToolbarController, NSObject, NSToolbarDelegate { | |
var isBackButtonEnabled = false { | |
didSet { | |
if isBackButtonEnabled != oldValue { | |
reloadBackItem() | |
} | |
} | |
} | |
func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem? { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
struct Proxy<EnclosingType, Value> { | |
typealias ValueKeyPath = ReferenceWritableKeyPath<EnclosingType, Value> | |
typealias SelfKeyPath = ReferenceWritableKeyPath<EnclosingType, Self> | |
static subscript( | |
_enclosingInstance instance: EnclosingType, | |
wrapped wrappedKeyPath: ValueKeyPath, | |
storage storageKeyPath: SelfKeyPath | |
) -> Value { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: deep-blue; icon-glyph: file-signature; | |
let text = args.shortcutParameter | |
let fm = FileManager.iCloud() | |
let filePath = args.fileURLs[0] | |
let content = fm.readString(filePath) | |
let newText = content + "\n" + text | |
fm.writeString(filePath, newText) | |
Script.complete() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We'll store a UIViewController as an associated object and don't want to store a strong reference to it. | |
private final class WeakBoxedValue<T: AnyObject>: NSObject { | |
private(set) weak var value: T? | |
init(_ value: T?) { | |
self.value = value | |
} | |
} | |
// Use associated objects to a UIViewController that should determine the status bar appearance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You must generate and insert your own API key for Google Maps + Directions JS SDK. | |
// The script uses Google Maps to display the scooters on a map as well as the route to the nearest scooter. Follow the guide on the link below to obtain an API key. | |
// https://developers.google.com/maps/documentation/javascript/get-api-key | |
let googleApiKey = "" | |
// Choose the enabled rental companies. Set to true to enable the rental company and false to disable it. | |
let COMPANIES = { | |
bird: true, | |
lime: true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: pink; icon-glyph: file-import; | |
let fm = FileManager.iCloud() | |
let bookmarkName = "Shortcut Links" | |
let filePath = fm.bookmarkedPath(bookmarkName) | |
let contents = fm.readString(filePath) | |
let links = contents.split("\n") | |
importLinks(links) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
####################################################################### | |
# Generates documentation for a target, for example a Swift package, | |
# that supports both iOS and macOS. | |
# | |
# The script is designed to be placed in the root of a Swift package. | |
# Change the paths as needed if your project structure is different. | |
# | |
# In order for DocC to annotate all symbols with the platforms |
NewerOlder