Skip to content

Instantly share code, notes, and snippets.

View dndydon's full-sized avatar

Don Sleeter dndydon

  • San Francisco Bay Area
View GitHub Profile
@T1T4N
T1T4N / Memoize.swift
Created June 21, 2024 07:48
Swift memoization helpers
// Source: https://www.hackingwithswift.com/plus/high-performance-apps/using-memoization-to-speed-up-slow-functions
// Source: https://medium.com/@mvxlr/swift-memoize-walk-through-c5224a558194
typealias MemFn<Input, Output> = (Input) -> Output
// work with any sort of input and output as long as the input is hashable
// accept a function that takes Input and returns Output, and return a function with the same signature
func memoize<Input: Hashable, Output>(
_ work: @escaping MemFn<Input, Output>
) -> MemFn<Input, Output> {

Twitter abuses all media file uploads, each type in its own way. If we want to upload a good looking animation loop from some low-color, high-detail generative art, we have to game their system's mechanisms.

  • don't upload a video file, they will re-encode it into absolute 💩

  • create a GIF, which they will auto-convert into a video file 😱

  • The frames of the GIF will be resized to an even-sized width using an extremely naive algorithm. Your GIF should be an even size (1000, 2000,

@ts95
ts95 / Dial.swift
Last active June 13, 2024 22:21
Dial component in SwiftUI
import SwiftUI
struct Dial: View {
@Binding public var value: Double
public var minValue: Double = 0
public var maxValue: Double = .greatestFiniteMagnitude
public var divisor: Double = 1
public var stepping: Double = 1
@State private var dialAngle: Angle = .zero
@State private var dialShadowAngle: Angle = .zero
@rxwei
rxwei / ad-manifesto.md
Last active November 9, 2023 09:58
First-Class Automatic Differentiation in Swift: A Manifesto
@mackuba
mackuba / wwdc16.md
Last active March 5, 2023 21:28
New stuff from WWDC 2016

Following the tradition from last year, here's my complete list of all interesting features and updates I could find in Apple's OSes, SDKs and developer tools that were announced at this year's WWDC. This is based on the keynotes, the "What's New In ..." presentations and some others, Apple's release notes, and blog posts and tweets that I came across in the last few weeks.

If for some reason you haven't watched the talks yet, I really recommend watching at least the "State of the Union" and the "What's New In" intros for the platforms you're interested in. The unofficial WWDC Mac app is great way to download the videos and keep track of what you've already watched.

If you're interested, here are my WWDC 2015 notes (might be useful if you're planning to drop support for iOS 8 now and start using some iOS 9 APIs).


OSX → macOS 10.12 Sierra

@natecook1000
natecook1000 / NSTimer+Closure.swift
Last active July 12, 2024 05:11
Scheduled NSTimer with a Swift closure
extension NSTimer {
/**
Creates and schedules a one-time `NSTimer` instance.
- Parameters:
- delay: The delay before execution.
- handler: A closure to execute after `delay`.
- Returns: The newly-created `NSTimer` instance.
*/