Skip to content

Instantly share code, notes, and snippets.

View Cykelero's full-sized avatar

Nathan Manceaux-Panot Cykelero

View GitHub Profile
@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")
@jamesjlyons
jamesjlyons / cozy-kagi-theme.css
Last active August 8, 2025 16:06
A cozy theme for Kagi Search. Be sure to set the default Kagi themes to "Calm Blue" and "Moon Dark" for the themes to apply properly.
:root {
--sand1: hsl(50, 20%, 99%);
--sand2: hsl(60, 7.7%, 97.5%);
--sand3: hsl(59, 6.5%, 95.1%);
--sand4: hsl(58, 6.1%, 92.9%);
--sand5: hsl(57, 6%, 90.7%);
--sand6: hsl(56, 5.9%, 88.4%);
--sand7: hsl(55, 5.9%, 85.2%);
--sand8: hsl(51, 6%, 77.1%);
--sand9: hsl(50, 2%, 55.7%);
@macshome
macshome / IOKit.swift
Last active February 25, 2025 20:26
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
@myleshyson
myleshyson / Command.swift
Last active July 7, 2025 15:54
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 {
@gavinmn
gavinmn / KeyboardAttachedView.swift
Created August 20, 2024 02:38
Attach a view to the keyboard with interactive dismissal support
//
// ContentView.Swift
// KeyboardAttachedView
//
// Created by Gavin Nelson on 8/19/24.
//
import SwiftUI
import UIKit
@macshome
macshome / Usernames.swift
Last active June 2, 2025 13:55
A playground to understand how to find the current username on macOS.
// Some Swift code for different ways to find the current username on macOS.
//
// You can run this in a Playground, or compile it with `swiftc`. Compiling
// it will let you experiment with different ways of running the command.
print("********** Foundation Usernames **********")
// If you are only importing Foundation you have a few options to get the current user.
// Note that if run from the CLI they will report the CLI user running them.
import Foundation