Skip to content

Instantly share code, notes, and snippets.

@ftiff
ftiff / sucatalog_pkg.txt
Created September 5, 2017 08:41
Packages from 10.13 seed
# curl https://swscan.apple.com/content/catalogs/others/index-10.13seed-10.13-10.12-10.11-10.10-10.9-mountainlion-lion-snowleopard-leopard.merged-1.sucatalog.gz
002_Card.pkg
002_Card_Preview_DE.pkg
002_Card_Preview_EN.pkg
002_Card_Preview_ES.pkg
002_Card_Preview_FR.pkg
002_Card_Preview_IT.pkg
002_Card_Preview_JA.pkg
002_Card_Preview_NL.pkg
@ftiff
ftiff / EnableButtonIfAtLeastOneCheckboxIsSelected.swift
Created May 23, 2017 19:49
How to enable a button if one or more checkbox is selected
//
// EnableButtonIfAtLeastOneCheckboxIsSelected.swift
// SplashBuddy
//
// Created by François Levaux on 23.05.17 (Swift 3)
// Copyright © 2017 François Levaux-Tiffreau. All rights reserved.
//
// Create 5 checkboxes & link them to this file
// Create one button, bind "Enabled" to "Enable Button If At Least One Checkbox Is Selected"
// with Model Key Path set to "self.atLeastOneSelectedButton"
@ftiff
ftiff / prefs_to_json.swift
Last active March 22, 2017 07:21
get json from preferences
//
// main.swift
// prefs
//
// Created by Francois Levaux on 21.03.17.
// Copyright © 2017 Francois Levaux. All rights reserved.
//
// Similar to $ plutil -convert json /Library/Preferences/io.fti.SplashBuddy.plist -o - -r
import Foundation
@ftiff
ftiff / mycliapp-launchdaemon.sh
Last active February 10, 2017 10:00
mycliapp-launchdaemon.sh
#!/bin/bash
plist=/Library/LaunchDaemons/io.fti.mycliapp.plist
# Scenario 1 -- app:killed instantaneously -- plist:removed -- launchdaemon:removed
/Applications/MyCliApp.app/Contents/MacOS/MyCliApp &
rm $plist
launchctl remove io.fti.mycliapp
Topic Binding Not Binding
@ftiff
ftiff / updateCasperLocation.swift
Created July 20, 2016 16:28
Set email and username for current computer in JSS
//
// updateCasperLocation.swift
//
// Created by Francois 'ftiff' Levaux-Tiffreau on 18.07.16.
// Licence = MIT (https://tldrlegal.com/license/mit-license)
/*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
@ftiff
ftiff / getSerialnumber.swift
Created July 20, 2016 16:26
Get Serial Number from macOS as String
//
// getSerialnumber.swift
//
// Created by Francois 'ftiff' Levaux-Tiffreau on 18.07.16.
// Licence = MIT (https://tldrlegal.com/license/mit-license)
/*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
@ftiff
ftiff / currentUser.swift
Created April 26, 2016 07:43
Check who is the current user (uses undocumented function from CoreGraphics)
import CoreGraphics
@_silgen_name("CGSSessionCopyAllSessionProperties") private func CGSSessionCopyAllSessionProperties() -> CFArray?
func getCurrentUser() -> String? {
if let sessions: NSArray = CGSSessionCopyAllSessionProperties() {
for session in sessions {
let dict = session as! Dictionary<String, AnyObject>
if dict["kCGSSessionOnConsoleKey"] as! Bool {
return dict["kCGSSessionUserNameKey"] as? String
import CoreGraphics
import AppKit
// http://stackoverflow.com/questions/30038203/cggetonlinedisplaylist-usage-in-swift-array-as-a-parameter
let maxDisplays: UInt32 = 2
//var displays: UnsafeMutablePointer<CGDirectDisplayID> = nil
var displays = [CGDirectDisplayID](count: Int(maxDisplays), repeatedValue: 0)
var displayCount: UInt32 = 0
CGGetOnlineDisplayList(2, &displays, &displayCount)
@ftiff
ftiff / com.apple.loginwindow.plist
Last active February 15, 2017 10:30
Default Login Window payload profile for Casper Suite
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1">
<dict>
<key>SHOWFULLNAME</key>
<false/>
<key>HideLocalUsers</key>
<false/>
<key>HideMobileAccounts</key>
<false/>