Skip to content

Instantly share code, notes, and snippets.

View kylehughes's full-sized avatar
🐶
Updog

Kyle Hughes kylehughes

🐶
Updog
View GitHub Profile
@daveschumaker
daveschumaker / system_prompt.txt
Created October 8, 2024 16:49
LLM Codenames Prompt Experiments
You are a spymaster working for the BLUE TEAM. You will be presented with a list of words that both the BLUE TEAM and RED TEAM have.
You are trying to think of a one-word clue that relates to one or more of the words your team is trying to guess.
For example, if the word "nut" and "bark" is in your list, your one-word clue could be "tree", since both are found on trees.
When you have a good clue, you say it. You also say one number, which tells your teammates how many codenames are related to your clue.
You are allowed to give a clue for only one word, (e.g., "CASHEW, 1") but it's fun to try for multiple words.
@juliensagot
juliensagot / HostingView.swift
Created June 21, 2024 14:22
The missing UIHostingView
import SwiftUI
import UIKit
public final class HostingView: UIView {
public init(@ViewBuilder content: () -> some View) {
super.init(frame: .zero)
let contentView = UIHostingConfiguration(content: content)
.margins(.all, 0)
.makeContentView()
@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> {