Skip to content

Instantly share code, notes, and snippets.

import SwiftUI
import PlaygroundSupport
// constants
let cardWidth: CGFloat = 343
let cardHeight: CGFloat = 212
let spacing = 36
let animation = Animation.spring()
let cardColors = [
Color(UIColor.systemRed),
import SwiftUI
import MapKit
import PlaygroundSupport
struct Location {
var title: String
var latitude: Double
var longitude: Double
}
import SwiftUI
import PlaygroundSupport
struct ContentView: View {
@State var gradientAngle: Double = 0
var colors = [
Color(UIColor.systemRed),
Color(UIColor.systemOrange),
Color(UIColor.systemYellow),
Color(UIColor.systemGreen),
@shaps80
shaps80 / Font.swift
Last active May 21, 2024 09:52
A set of UIFont/NSFont helpers that matches the equivalent SwiftUI Font API. (Supports iOS 13+ and macOS 10.15+)
import SwiftUI
#if os(macOS)
public typealias Font = NSFont
public typealias FontDescriptor = NSFontDescriptor
#else
public typealias Font = UIFont
public typealias FontDescriptor = UIFontDescriptor
#endif
@MatthewWaller
MatthewWaller / gist:37a3d889b684691c9f6a70d9abe76f92
Created January 27, 2022 04:35
Swift Playgrounds AR App Starter Code
import ARKit
import Combine
import RealityKit
import SwiftUI
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
@othyn
othyn / App.swift
Last active January 30, 2024 10:58
How to disable default menu bar items in Swift / SwiftUI for macOS
//
// App.swift
//
// Created by Ben Tindall on 30/03/2022.
//
import Foundation
import SwiftUI
import Cocoa
@kylehowells
kylehowells / FreeSpaceViewController.swift
Created May 4, 2022 23:24
UIViewController subclass to show both the Settings app displayed free space, and the real free space.
//
// FreeSpaceViewController.swift
// Free Space
//
// Created by Kyle Howells on 04/05/2022.
//
import UIKit
class FreeSpaceViewController: UIViewController {
@SMUsamaShah
SMUsamaShah / List of in-browser VMs.md
Last active April 30, 2024 13:08
List of Javascript based virtual machines running in browser
@JadenGeller
JadenGeller / EventMonitor.swift
Last active April 2, 2024 02:06
for monitoring trackpad, touch, etc. events, useful in SwiftUI, similar to using CGTapCreate
import AppKit
struct EventMonitor: AsyncSequence {
typealias Element = NSEvent
enum Scope {
case local
case global
}
var scope: Scope = .local
@stephancasas
stephancasas / macos-modifier-keys-dec-map.json
Last active February 21, 2024 10:34
macOS Modifier Keys Decimal Values Map
{
"65536": [
"alphashift"
],
"131072": [
"shift"
],
"196608": [
"alphashift",
"shift"