Skip to content

Instantly share code, notes, and snippets.

View kylehughes's full-sized avatar
🐶
Updog

Kyle Hughes kylehughes

🐶
Updog
View GitHub Profile
@sindresorhus
sindresorhus / UIScreen-screens-deprecation-warning-fix.swift
Last active October 19, 2022 21:46
iOS 16 deprecated `UIScreen#screens`. Here's how to silence the deprecation until you can move to the new API.
private protocol SilenceDeprecationForUIScreenWindows {
var screens: [UIScreen] { get }
}
private final class SilenceDeprecationForUIScreenWindowsImplementation: SilenceDeprecationForUIScreenWindows {
@available(iOS, deprecated: 16)
var screens: [UIScreen] { UIScreen.screens }
}
extension UIScreen {
@EthanLipnik
EthanLipnik / Blur.swift
Last active March 6, 2024 04:00
Blur transition for SwiftUI
//
// Blur.swift
//
//
// Created by Ethan Lipnik on 11/21/22.
//
import SwiftUI
private struct BlurModifier: ViewModifier {
//
// CompareEquatableProperties.swift
// ListableUI
//
// Created by Kyle Van Essen on 7/28/22.
//
import Foundation
@chockenberry
chockenberry / AttributedString.swift
Created June 1, 2022 21:08
A playground that shows how to use Swift's AttributedString with Markdown
import UIKit
import Foundation
// NOTE: This playground shows how to use Swift's AttributedString with Markdown.
//
// This code was used to display Markdown content in the Tot iOS Widget <https://tot.rocks>
// MARK: - Helpful Links
// NOTE: The following links helped me figure this stuff out.
@insidegui
insidegui / FixSwiftUIMaterialInPreviews.m
Created May 13, 2022 21:27
Fixes SwiftUI's Material not being rendered correctly in Xcode previews
#if DEBUG
/*
This fixes SwiftUI previews not rendering translucent materials correctly by
swizzling a couple of properties on NSWindow.
Just drop into your project and add to the target being previewed (or something it links against).
Notice the #if DEBUG, so this code won't end up in release builds. It also checks for the
XCODE_RUNNING_FOR_PREVIEWS environment variable so that it won't affect regular debug builds of the app.
extension Error {
var code: Int { return (self as NSError).code }
var domain: String { return (self as NSError).domain }
var userInfo: [String:Any] { return (self as NSError).userInfo }
func timeAfterWhichToRetry(retryCount: Int) -> TimeInterval? {
// CloudKit suggests us retry too often, so slow us down as we retry a lot, up to 5 minutes
if let suggestedTimeout = suggestedTimeAfterWhichToRetry {
if suggestedTimeAfterWhichToRetry == 0 {
return 0
@colmmacc
colmmacc / wordle-cribs.md
Created January 3, 2022 01:12
Wordle Letter Frequency Cribs

Wordle Letter Frequency Table

If you're used to solving cryptic puzzles, or deciphering texts using crypt-analytical cribs, it can be useful to know the relative frequency of letters in the distribution of words. Wordle has a built-in list of 5-letter words. That list isn't the same as all of the five letter words in the dictionary, or even only the common ones. Perfectly common words like 'tudor' are omitted. This gist contains a few useful tables that are worth familiarizing yourself with if you want to solve wordle puzzles logically.

The raw frequency of each letter

// A view that can flip between its "front" and "back" side.
//
// Animation implementation based on:
// Chris Eidhof, Keyframe animations <https://gist.github.com/chriseidhof/ea0e435197f550b195bb749f4777bbf7>
import SwiftUI
// MARK: - Chris's keyframe animation design
struct Keyframe<Data: Animatable> {
@ShihabM
ShihabM / AppDelegate.gist
Created November 3, 2021 09:53
Dock Shooter - a game in your dock icon
//
// AppDelegate.swift
// Dock Shooter
//
// Created by Shihab Mehboob on 01/11/2021.
//
import Cocoa
@main
@kylehughes
kylehughes / TornRectangle.swift
Last active August 12, 2023 01:20
A rectangle shape for SwiftUI that can render any edge like a torn piece of paper.
// Copyright 2021 Kyle Hughes
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
// Software.
//