This file contains hidden or 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
# ----------------------------------------------------------------------------- | |
# AI-powered Git Commit Function | |
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It: | |
# 1) gets the current staged changed diff | |
# 2) sends them to an LLM to write the git commit message | |
# 3) allows you to easily accept, edit, regenerate, cancel | |
# But - just read and edit the code however you like | |
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/ | |
gcm() { |
This file contains hidden or 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/zsh | |
# Test if the Swift compiler knows about a particular language feature. | |
# | |
# Usage: | |
# | |
# swift-has-feature [--swift SWIFT_PATH] [--language-version LANGUAGE_VERSION] FEATURE | |
# | |
# The feature should be an upcoming or experimental language feature, | |
# such as `"StrictConcurrency"` or `"ExistentialAny"`. |
This file contains hidden or 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
// | |
// ContentView.swift | |
// Animating Cirlce | |
// | |
// Created by Moussa on 23/1/2024. | |
// | |
import SwiftUI | |
This file contains hidden or 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
# Add to your zsh profile | |
function devicepid() { | |
if [ -z "$1" ]; then | |
echo "Usage: devicepid <device-name> <search>" | |
echo "Example: devicepid 'iPhone 15 Pro Max' SpringBoard" | |
return 1 | |
fi | |
if [ -z "$2" ]; then |
This file contains hidden or 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
import SwiftUI | |
/* | |
Put these in a file that is compiled for iOS only. | |
Note that these are just a few examples of things that worked well in my project. | |
They may or may not be useful to you, but they give an idea of how typealias + extensions | |
could be used to keep your code tidy. | |
*/ |
This file contains hidden or 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
import SwiftUI | |
/// Provides a text label appropriate for the current platform. | |
/// | |
/// Specifically, this provides a `Label` with the specified system image on iOS and `Text` without an image on macOS. | |
struct MultiplatformLabel: View { | |
// MARK:- Properties | |
/// A title generated from a localized string. |
This file contains hidden or 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
import SwiftUI | |
import WidgetKit | |
@available(iOS 16.0, macOS 13.0, *) | |
public enum MultiplatformWidgetFamily: CaseIterable { | |
/// A small widget. | |
/// | |
/// The small system widget can appear on the Home Screen or in the Today View in iOS and iPadOS, or in the Notification Center on macOS. | |
case systemSmall |
This file contains hidden or 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
import SwiftUI | |
import WidgetKit | |
@available(iOS 14.0, macOS 11.0, *) | |
public extension WidgetFamily { | |
/// Returns the value for the current widget family. | |
/// | |
/// If no value is provided for the current widget family, the method will return the `defaultValue`. | |
/// |
This file contains hidden or 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
import Foundation | |
/* | |
Put these global functions in a file that is compiled for all platforms. | |
*/ | |
/// Returns the value for the current device from the values that are provided. | |
/// | |
/// - Parameters: | |
/// - phoneValue: The value to use for iPhone. |
This file contains hidden or 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
import Foundation | |
/// Returns the value for the current platform from the values that are provided. | |
/// | |
/// - Parameters: | |
/// - iOSValue: The value to use for the iOS platform. | |
/// - macOSValue: The value to use for the macOS platform. | |
func valueForPlatform<Value>(iOS iOSValue: @autoclosure () -> Value, macOS macOSValue: @autoclosure () -> Value) -> Value { | |
#if os(iOS) | |
iOSValue() |
NewerOlder