Skip to content

Instantly share code, notes, and snippets.

View Uhucream's full-sized avatar
:octocat:

Takashi Uhucream

:octocat:
View GitHub Profile
@zacwest
zacwest / ios-font-sizes.swift
Last active May 17, 2024 10:24
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]
@mono0926
mono0926 / commit_message_example.md
Last active May 16, 2024 08:05
[転載] gitにおけるコミットログ/メッセージ例文集100
@lukebrandonfarrell
lukebrandonfarrell / ExifData.swift
Created June 8, 2022 16:10
A Swift class for extracting exif data from URL, UIImage or Data types 🔭
//
// ExifData.swift
// Qeepsake
//
// Created by Luke Farrell on 26/05/2022.
//
import Foundation
import ImageIO
@wata
wata / EventStoreNotificationInfo.swift
Last active March 27, 2024 05:27
Parse EKEventStoreChanged notification user info
struct EventStoreNotificationInfo {
let changeType: Int
let calendarDataChanged: Bool
let remindersDataChanged: Bool
let changedObjectIDs: [NSObject]
let modifiedObjectIdentifiers: Set<String>? // Not included in iOS 16?
struct UserInfoKeys {
static let changeType = "EKEventStoreChangeTypeUserInfoKey"
static let calendarDataChanged = "EKEventStoreCalendarDataChangedUserInfoKey"
@mayankk2308
mayankk2308 / boost-low-pri-macOS.sh
Created July 17, 2018 17:35
Boost Low-Priority Tasks on macOS
# Useful for improving Time Machine backup prep. times, Mac App Store install speeds, etc.
sudo sysctl debug.lowpri_throttle_enabled=0
# To restore defaults
sudo sysctl debug.lowpri_throttle_enabled=1

202207041909 AppStorage extension for strongly typed keys

#appstorage #swiftui

The @AppStorage property wrapper for observable access to UserDefaults keys is stringified.

To get a strongly typed key access, I oriented myself on the @Environment(\.keyPath) wrapper and my experience with SwiftyUserDefaults and its subscript-based access.

// Use defaultValue from the key:
@AppStorage(\.showOnboarding) var showOnboarding
@dimohamdy
dimohamdy / KeyPath.swift
Last active December 11, 2023 14:58
Accessing Dictionaries with Key Paths
/*
Thanks for @olebegemann
code of keypath from this link
https://oleb.net/blog/2017/01/dictionary-key-paths/
*/
struct KeyPath {
var segments: [String]
var isEmpty: Bool { return segments.isEmpty }
@kshivang
kshivang / CombineFirebaseAuth+Publisher.swift
Last active November 18, 2023 19:51
Switch/Refresh publisher on Firebase Auth new login simple one-liner for rever-ai/CombineFirebase
func onLoginRefresher<T>(_ publisherGetter: @escaping () -> AnyPublisher<T, Never> ) -> AnyPublisher<T, Never> {
Auth.auth().stateDidChangePublisher
.filter { $0 != nil } // User LoggedIn
.map { _ in publisherGetter() }
.switchToLatest()
.eraseToAnyPublisher()
}
// e.g.: turn userDataPublisher to onLoginRefresher { userDataPublisher() } and done
//
@darrarski
darrarski / FetchedResultsPublisher.swift
Last active November 9, 2023 08:31
Swift-Combine-CoreData-Fetched-Results-Publisher
import Combine
import CoreData
public final class FetchedResultsPublisher
<ResultType>
: Publisher
where
ResultType: NSFetchRequestResult
{