Skip to content

Instantly share code, notes, and snippets.

@colejd
colejd / Davider.swift
Last active January 27, 2022 19:07
Horizontal SwiftUI divider with content embedded in center
/// Embeds its content between two horizontal dividers.
struct Davider<Content: View>: View {
let content: Content
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
var body: some View {
HStack {

This page is now depreacted!

Check out the repo instead. The Wisdom of Quinn Now with 100% more archived PDFs.

The Wisdom of Quinn

Informative DevForum posts from everyone's favorite DTS member.

(Arranged newest to oldest)

@jordansinger
jordansinger / iPod.swift
Created July 27, 2020 21:19
Swift Playgrounds iPod Classic
import SwiftUI
import PlaygroundSupport
struct iPod: View {
var body: some View {
VStack(spacing: 40) {
Screen()
ClickWheel()
Spacer()
}
@baz8080
baz8080 / GetId.swift
Created May 21, 2020 11:29
Getting the Request ID from a newly created request
let createRequest = ZDKCreateRequest()
createRequest.subject = "Hello?"
createRequest.requestDescription = "Is it me you're looking for?"
let requestProvider = ZDKRequestProvider()
requestProvider.createRequest(createRequest) { (response, error) in
if (error != nil) {
// Display / Handle the error
return
@AliSoftware
AliSoftware / Demo.swift
Last active October 31, 2023 12:25
NestableCodingKey: Nice way to define nested coding keys for properties
struct Contact: Decodable, CustomStringConvertible {
var id: String
@NestedKey
var firstname: String
@NestedKey
var lastname: String
@NestedKey
var address: String
enum CodingKeys: String, NestableCodingKey {
@mdiep
mdiep / diff-values.swift
Last active February 13, 2024 21:01
Diff values with Codable, CaseIterable, and KeyPaths
import Foundation
// Diff objects for better test assertions.
//
// Implemented in a way that:
// 1. The compiler generates as much code as possible
// 2. You'll get a compiler error if you forget a property
//
// Nested support and collections left as an exercise for the reader.
@zntfdr
zntfdr / firebase-iOS-breakdown.swift
Last active May 28, 2024 12:49
Firebase iOS Version breakdown
// How to:
// 1. Open the Firebase Analytics Dashboard
// 2. Scroll to bottom, where you see the "Users by Device model" widget
// 3. Click "View device models" in that widget (this opens the "Tech details" Firebase Analytics page)
// 4. Above the table shown in the new page, click on the “Device model” drop down menu and select “OS with Version”
// 5. Make sure to select “OS with version” and not “OS Version”
// 6. On the top right corner of the page, click on the “Share this report” icon (next to the date)
// 7. Click “Download file” on the new side bar, then “Download CSV"
// 8. Open the file and select the iOS/Android breakdown raw data
// 9. Replace the sample data in this script with your data
@douglashill
douglashill / KeyboardTableView.swift
Last active March 30, 2023 22:01
A UITableView that allows navigation and selection using a hardware keyboard.
// Douglas Hill, December 2018
// Made for https://douglashill.co/reading-app/
// Find the latest version of this file at https://github.com/douglashill/KeyboardKit
import UIKit
/// A table view that allows navigation and selection using a hardware keyboard.
/// Only supports a single section.
class KeyboardTableView: UITableView {
// These properties may be set or overridden to provide discoverability titles for key commands.
@jrturton
jrturton / testimage.swift
Created November 19, 2018 14:59
Make a date-stamped test image
let renderer = UIGraphicsImageRenderer(size: CGSize(width: 400, height: 400))
let image = renderer.image {
context in
UIColor.lightGray.setFill()
UIRectFill(context.format.bounds)
UIColor.black.set()
UIRectFrame(context.format.bounds)
let text = "TEST IMAGE \n\(Date())" as NSString
let paragraph = NSMutableParagraphStyle()
paragraph.alignment = .center
@kaishin
kaishin / snapshot.swift
Created January 10, 2016 14:29
NSView Snapshot
extension NSView {
var snapshot: NSImage {
guard let bitmapRep = bitmapImageRepForCachingDisplayInRect(bounds) else { return NSImage() }
bitmapRep.size = bounds.size
cacheDisplayInRect(bounds, toBitmapImageRep: bitmapRep)
let image = NSImage(size: bounds.size)
image.addRepresentation(bitmapRep)
return image
}
}