Skip to content

Instantly share code, notes, and snippets.

View adam-zethraeus's full-sized avatar
🏔️

adamz adam-zethraeus

🏔️
View GitHub Profile
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@adam-zethraeus
adam-zethraeus / emoji-trie.json
Last active March 7, 2023 09:29
json emoji trie from annotations_en.xml
This file has been truncated, but you can view the full file.
{
"c": "*",
"e": [],
"n": {
"(": {
"c": "(",
"e": [],
"n": {
"b": {
"c": "b",
@krzysztofzablocki
krzysztofzablocki / Versionable.swift
Created May 26, 2021 09:16
Extension of http://merowing.info/2020/06/adding-support-for-versioning-and-migration-to-your-codable-models./ that supports a situation when you shipped app without versioning and want to add it now
import Foundation
public protocol VersionType: CaseIterable, Codable, Comparable, RawRepresentable {}
public extension VersionType where RawValue: Comparable {
static func < (a: Self, b: Self) -> Bool {
return a.rawValue < b.rawValue
}
}
@saagarjha
saagarjha / library_injector.cpp
Last active June 17, 2025 13:55
Load a library into newly spawned processes (using DYLD_INSERT_LIBRARIES and EndpointSecurity)
// To compile: clang++ -arch x86_64 -arch arm64 -std=c++20 library_injector.cpp -lbsm -lEndpointSecurity -o library_injector,
// then codesign with com.apple.developer.endpoint-security.client and run the
// program as root.
#include <EndpointSecurity/EndpointSecurity.h>
#include <algorithm>
#include <array>
#include <bsm/libbsm.h>
#include <cstddef>
#include <cstdint>
@kylehughes
kylehughes / TornRectangle.swift
Last active March 31, 2025 13:21
A rectangle shape for SwiftUI that can render any edge like a torn piece of paper.
// Copyright 2021 Kyle Hughes
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
// Software.
//
import PackageDescription
import Foundation
import Swift
extension PackageDescription.Product {
public static func iOSApplication(
name: Swift.String,
targets: [Swift.String],
bundleIdentifier: Swift.String? = nil,
teamIdentifier: Swift.String? = nil,
@adam-zethraeus
adam-zethraeus / RandomPastelUIColor.swift
Last active March 7, 2023 09:28
UIColor extension to generate a random pastel
import UIKit
public extension UIColor {
private static var randomLightness: CGFloat {
Double.random(in: 0...1)
}
private static var randomRGB: UIColor {
UIColor(
import SwiftUI
struct ContentView: View {
@State var pictureExpanded = false
var body: some View {
VStack(alignment: .leading, spacing: 20.0) {
Text("Once upon a time there was a turtle named George who made friends with a giraffe at the local water park and then they went on lots of adventures together.")
Button {
@pesterhazy
pesterhazy / building-sync-systems.md
Last active July 12, 2025 00:44
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@swiftui-lab
swiftui-lab / tree-layout-example.swift
Last active February 25, 2025 12:46
A Tree Layout Example (SwiftUI)
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: A Tree Layout example
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct TreeNode: Identifiable {
var parentId: UUID? = nil
let id: UUID = UUID()
let name: String