Skip to content

Instantly share code, notes, and snippets.

View kdeda's full-sized avatar

Klajd (Cyde) Deda kdeda

  • id-design, inc.
View GitHub Profile
@kdeda
kdeda / Request+AppleJWTExtensions.swift
Last active October 22, 2024 04:40
Verifying a Sign in with Apple JWT in Vapor 4
// The model
public struct UserCredentials: Equatable, Codable {
// This silly variable can come nback as emoty, but no fret it is encrypted inside the jwtToken
// and the server will be able to extract it.
public var email: String
public var jwtToken: String
public var userId: String
public var isEmpty: Bool {
email.isEmpty
@kdeda
kdeda / View+NSWindow.swift
Last active January 17, 2025 12:09
Open/Close NSWindow from SwiftUI.View
import SwiftUI
/**
hack to avoid crashes on window close, and remove the window from the
NSApplication stack, ie: avoid leaking window objects
*/
fileprivate final class WindowDelegate: NSObject, NSWindowDelegate {
func windowShouldClose(_ sender: NSWindow) -> Bool {
NSApp.removeWindowsItem(sender)
return true