Skip to content

Instantly share code, notes, and snippets.

@aerobounce
aerobounce / macOS System Preference Pane Links.md
Last active October 22, 2025 10:59
macOS System Preference Pane Links
@rmcdongit
rmcdongit / macOS_SytemPrefs.md
Last active April 18, 2026 06:33
Apple System Preferences URL Schemes

macOS 10.15 System Preference Panes

Below are a list of System Preference pane URLs and paths that can be accessed with scripting to assist users with enabling macOS security settings without having to walk them through launching System Preferences, finding panes, and scrolling to settings. Not all panes have an accessible anchor and some are OS specific.

To find the Pane ID of a specific pane, open the System Preferences app and select the desired Preference Pane. With the pane selected, open the ScriptEditor.app and run the following script to copy the current Pane ID to your clipboard and display any available anchors:

tell application "System Preferences"
	set CurrentPane to the id of the current pane
	set the clipboard to CurrentPane
@a1ip
a1ip / hostname.md
Last active April 24, 2025 13:33
How to set the Mac hostname or computer name from the terminal

How to set the Mac hostname or computer name from the terminal

  1. Open a terminal.
  2. Type the following command to change the primary hostname of your Mac: This is your fully qualified hostname, for example myMac.domain.com
sudo scutil --set HostName <new host name>
  1. Type the following command to change the Bonjour hostname of your Mac: This is the name usable on the local network, for example myMac.local.
@evici
evici / default-finder-view
Created January 16, 2020 18:28
Set Default Finder View and Arrange By Options
1. Backup com.apple.finder.plist
cp ~/Library/Preferences/com.apple.finder.plist ~/Desktop
2. Set top-level defaults using the defaults command
Default to list view:
defaults write com.apple.finder FXPreferredViewStyle Nlsv
Default Arrange By flags that don't seem to be effective:
defaults write com.apple.finder FXArrangeGroupViewBy kind
defaults write com.apple.finder FXPreferredGroupBy kind
@vorce
vorce / jerry.swift
Last active May 11, 2025 06:07
Mouse move and click test thing for macos in swift
import Cocoa
import Foundation
// Move around and click automatically at random places in macos, kinda human like in a cheap way.
// Moves the mouse pointer to `moves` random locations on the screen and runs the `action` function at
// each point with the point as argument.
func mouseMoveWithAction(moves: Int, action: (CGPoint) -> Void = defaultAction) {
let screenSize = NSScreen.main?.visibleFrame.size
First just enable battery monitoring:
UIDevice.current.isBatteryMonitoringEnabled = true
Then you can create a computed property to return the battery level:
var batteryLevel: Float {
return UIDevice.current.batteryLevel
}
To monitor your device battery level you can add an observer for the UIDeviceBatteryLevelDidChange notification:
@sughodke
sughodke / Output.png
Last active February 28, 2025 00:07
Read Mail.app Database
Output.png
@action456789
action456789 / .swift
Created December 4, 2017 08:45
[UIViewController自定义初始化方法] #Swift
class HomeRoomPageViewController: UIViewController {
var floor: FloorModel
init(floor: FloorModel) {
self.floor = floor
super.init(nibName: nil, bundle: nil)
....
}
required init?(coder aDecoder: NSCoder) {
@saelo
saelo / authorize.swift
Created July 6, 2017 07:31
Simple program to interact with authd via the macOS authorization API Raw
import Foundation
let rightname = "sys.openfile.readonly./tmp/cantread.txt"
var status: OSStatus
var authref: AuthorizationRef?
let flags = AuthorizationFlags([.interactionAllowed, .extendRights, .preAuthorize])
status = AuthorizationCreate(nil, nil, flags, &authref)
assert(status == errAuthorizationSuccess)