Skip to content

Instantly share code, notes, and snippets.

View leogdion's full-sized avatar

leogdion leogdion

View GitHub Profile
@leogdion
leogdion / XcodeApplication.swift
Last active July 16, 2024 18:37
Xcode Script Bridging
import AppKit
import ScriptingBridge
@objc public protocol SBObjectProtocol: NSObjectProtocol {
func get() -> Any!
}
@objc public protocol SBApplicationProtocol: SBObjectProtocol {
func activate()
@leogdion
leogdion / Database.swift
Last active July 22, 2024 12:57
Sample Code for ModelActor
public protocol Database: Sendable {
func delete<T: PersistentModel>(
where predicate: Predicate<T>?
) async throws
func insert(_ closuer: @Sendable @escaping () -> some PersistentModel) async
func fetch<T, U : Sendable>(
_ selectDescriptor: @escaping @Sendable () -> FetchDescriptor<T>,
with closure: @escaping @Sendable ([T]) throws -> U
@leogdion
leogdion / split_swift.sh
Created July 23, 2024 19:43
Split Swift File by Brackets
#!/bin/bash
# Check if a filename was provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <filename>"
exit 1
fi
filename=$1
sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Add to /etc/fstab to make permanent
echo '/swapfile swap swap defaults 0 0' | sudo tee -a /etc/fstab
sudo yum update -y && sudo yum install docker -y && sudo yum install git -y && sudo yum install libicu -y &&
sudo systemctl start docker
sudo systemctl enable docker