Skip to content

Instantly share code, notes, and snippets.

@myleshyson
myleshyson / Command.swift
Last active July 10, 2024 20:36
Execute CLI Commands with Swift. Supports generating output, streaming output, and running sudo commands.
import Foundation
struct ShellCommand {
@discardableResult
static func stream(_ command: String) -> Int32 {
let outputPipe = Pipe()
let task = self.createProcess([command], outputPipe)
outputPipe.fileHandleForReading.readabilityHandler = { fileHandle in self.streamOutput(outputPipe, fileHandle) }
do {
@macshome
macshome / IOKit.swift
Last active April 29, 2024 14:42
This playground shows you a few different ways to get device info via IOKit.
// This playground shows you a few different ways to get device info via IOKit.
// If you want to explore IOKit and look for interesting data I would download
// the Additional Developer Tools from Apple and use the IORegistryExplorer app.
// It makes it super easy to poke around in the IOKit planes.
import IOKit
import Foundation
// For convient access we can make a computed getter for the PlatformExpert.
// Traditionally this has been where you go to find all sorts of data about the
@kirb
kirb / Device.swift
Last active January 2, 2024 04:18
Get Mac device image based on device class - https://kirb.me/2023/04/15/mac-device-icon-by-device-class.html
import Cocoa
import UniformTypeIdentifiers
extension UTTagClass {
static let deviceModelCode = UTTagClass(rawValue: "com.apple.device-model-code")
}
extension UTType {
static let macBook = UTType("com.apple.mac.laptop")
static let macBookWithNotch = UTType("com.apple.mac.notched-laptop")
@christianselig
christianselig / Locale+SFSymbol.swift
Created September 3, 2021 21:54
Returns an SF Symbol currency image that match's the device's current locale, for instance dollar in North America, Indian rupee in India, etc.
extension Locale {
/// Returns an SF Symbol currency image that match's the device's current locale, for instance dollar in North America, Indian rupee in India, etc.
func currencySFSymbol(filled: Bool, withConfiguration configuration: UIImage.Configuration? = nil) -> UIImage {
// Default currency symbol will be the Animal Crossing Leaf coin 􁂬 to remain impartial to any specific country
let defaultSymbol = UIImage(systemName: "leaf.circle\(filled ? ".fill" : "")")!
guard let currencySymbolName = currencySymbolNameForSFSymbols() else { return defaultSymbol }
let systemName = "\(currencySymbolName).circle\(filled ? ".fill" : "")"
return UIImage(systemName: systemName, withConfiguration: configuration) ?? defaultSymbol
@IsaacXen
IsaacXen / README.md
Last active July 17, 2024 08:21
(Almost) Every WWDC videos download links for aria2c.
@atomicbird
atomicbird / wwdc2019-online-sessions.md
Last active May 29, 2020 22:59
WWDC 2019 Online-only Sessions

At WWDC 2019 Apple released some videos directly online, with no corresponding live session. This is a list of those videos with links to the video pages.

Some sessions were presented during WWDC but then split into multiple videos when posted online. This list includes the online versions, since they don't appear in the WWDC schedule. For example WWDC included session 711, "Introducing Combine and Advances in Foundation". This was split into two online videos-- 722, "Introducing Combine", and 723, "Advances in Foundation". Both 722 and 723 are included here.

@rhythmus
rhythmus / all-Unicode-BMP-chars-sorted-by-UCA.md
Created April 10, 2018 21:55
All Unicode characters, sorted alphabetically by Unicode Collation algorithm

All Unicode characters, sorted alphabetically

Using Unicode Collation Algorithm (as implemented by ICU Project).

See discussion at forum.glyphsapp.com.

҈ ҉ ؀ ؁ ؂ ؃ ؄ ؅ ـ ۝ ܏ ߺ ࠤ ࠨ ः ং ঃ ਃ ઃ ଂ ଃ ఁ ం ః ಂ ಃ ം ഃ ං ඃ ༾ ༿ ཿ း ះ ៈ ᠊ ᪾ ⃝ ⃞ ⃟ ⃠ ⃢ ⃣ ⃤ 〮 〯 ꙰ ꙱ ꙲ ﱞ ﱟ ﱠ ﱡ ﱢ ﱣ ﳲ ﳳ ﳴ ﹰ ﹱ ﹲ ﹳ ﹴ ﹶ ﹷ ﹸ ﹹ ﹺ ﹻ ﹼ ﹽ ﹾ ﹿ ゙ ゚    ‾ ﹉ ﹊ ﹋ ﹌ _ ︳ ︴ ﹍ ﹎ ﹏ _ ‗ - ﹣ - ֊ ᠆ ᠇ ‐ ‑ ‒ – ︲ — ︱ ﹘ ― ⸺ ⸻ ⁓ ⸗ ⹀ 〜 〰 ゠ ・ ・ , ︐ ﹐ , ⸴ ⸲ ⹁ ՝ ، ؍ ٫ ٬ ߸ ᠂ ᠈ 、 ︑ ﹑ 、 ﹅ ﹆ ; ; ︔ ﹔ ; ؛ ⁏ ⸵ : ︓ ﹕ : ⩴ ։ ؞ ܃ ܄ ܅ ܆ ܇ ܈ ࠰ ࠱ ࠲ ࠳ ࠴ ࠵ ࠶ ࠷ ࠸ ࠹ ࠺ ࠻ ࠼ ࠽ ࠾ ፡ ፣ ፤ ፥ ፦ ᠄ ᠅ ༔ ៖ ! ︕ ﹗ ! ‼ ⁉ ¡ ՜ ߹ ? ︖ ﹖ ? ⁈ ⁇ ¿ ⸮ ՞ ؟ ܉ ፧ ⳺ ⳻ ‽ ⸘ . ․ ﹒ . ‥ ︰ … ︙ ᠁ ۔ ܁ ܂ ። ᠃ ᠉ ⳹ ⳾ ⸰ ⸼ 。 ︒ 。 · · ⸱ ⸳ । ॥ ᰻ ᰼ ꤯ ၊ ။ ។ ៕ ܀ ߷ ჻ ፠ ፨ ⁕ ⁖ ⁘ ⁙ ⁚ ⁛ ⁜ ⁝ ⁞ ⸪ ⸫ ⸬ ⸭ ⸽ ⳼ ⳿ ⸙ ' ' ‘ ’ ‚ ‛ ‹ › " “ ” „ ‟ ⹂ 〝 〞 〟 « » ( ⁽ ₍ ︵ ﹙ ( ⑴ ⑽ ⑾ ⑿ ⒀ ⒁ ⒂ ⒃ ⒄ ⒅ ⒆ ⑵ ⒇ ⑶ ⑷ ⑸ ⑹ ⑺ ⑻ ⑼ ⒜ ⒝ ⒞ ⒟ ⒠ ⒡ ⒢ ⒣ ⒤ ⒥ ⒦ ⒧ ⒨ ⒩ ⒪ ⒫ ⒬ ⒭ ⒮ ⒯ ⒰ ⒱ ⒲ ⒳ ⒴ ⒵ ㈀ ㈎ ㈁ ㈏ ㈂

@DivineDominion
DivineDominion / FolderContentMonitor.swift
Last active March 10, 2023 15:50
Wrapper for using C FSEvents with Swift 4
//
// Based on: https://blog.beecomedigital.com/2015/06/27/developing-a-filesystemwatcher-for-os-x-by-using-fsevents-with-swift-2/
//
import Foundation
public struct Event: CustomStringConvertible {
public let eventId: FSEventStreamEventId
public let eventPath: String
@MattyAyOh
MattyAyOh / logUndoStack.m
Created December 8, 2015 16:01
Log out the undo and redo stack on an NSUndoManager using objc/runtime to access private ivars
@try
{
NSUndoManager* undoManager = [self undoManager];
id undostack = object_getIvar(undoManager, class_getInstanceVariable([NSUndoManager class], "_undoStack"));
id redostack = object_getIvar(undoManager, class_getInstanceVariable([NSUndoManager class], "_redoStack"));
NSLog(@"%@",[NSString stringWithFormat:@"(%lu entries) %@", (unsigned long)[undostack count], [undostack description]]);
NSLog(@"%@",[NSString stringWithFormat:@"(%lu entries) %@", (unsigned long)[redostack count], [redostack description]]);
}
@zwaldowski
zwaldowski / notes-specific-to-mac-os-x-10_9.md
Last active August 7, 2023 08:34
10.9 AppKit Release Notes