Skip to content

Instantly share code, notes, and snippets.

@grahamgilbert
grahamgilbert / clean_old_apple_updates.py
Created May 9, 2018 16:35
Clean out old apple updates (older than 24 hours) because softwareupdate often refuses to install them
#!/usr/bin/python
"""
Removes cached apple updates that are older than 24 hours
"""
import datetime
import os
import shutil
import sys
@grahamgilbert
grahamgilbert / SnowLeoAndLionPrintDrivers.catalog
Created July 23, 2012 10:30
Updated Apple printer drivers for InstaDMG
# Please comment-out unneeded updates as necessary (as this would add multiple GBs to your image)
# It is possible not all of these are 10.6-compatible, please test as applicable
# via https://github.com/thisisdave/instaCATS/blob/master/printers.catalog
# and https://raw.github.com/n8felton/Mac-OS-X-Scripts/master/InstaDMG/CatalogFiles/printers.catalog
Apple Updates:
Brother Printer Drivers 2.9 for OS X http://support.apple.com/downloads/DL894/en_US/BrotherPrinterDrivers2.9.dmg sha1:ced12cc349a6990094796395f8da579ba07ec5b7
Canon Printer Drivers v2.9 for OS X http://support.apple.com/downloads/DL899/en_US/CanonPrinterDrivers2.9.dmg sha1:d6dc46eeaf3d976966fa6c413b817314df867b38
Epson Printer Drivers v2.11 for OS X http://support.apple.com/downloads/DL1398/en_US/EPSONPrinterDrivers2.11.dmg sha1:40861b8d791ecb692612e9e2aff698a3cfbae982
FujiXerox Printer Drivers v2.3 for OS X http://support.apple.com/downloads/DL904/en_US/FujiXeroxPrinterDrivers.dmg sha1:e6275c6b766dc657255d8356766c8f5f3949a634

Keybase proof

I hereby claim:

  • I am grahamgilbert on github.
  • I am grahamgilbert (https://keybase.io/grahamgilbert) on keybase.
  • I have a public key ASDdB4_Tt3Pfh7-qvEoOSZCAfoUJoxgTtv8YoyA3MTGHdwo

To claim this, I am signing this object:

select username,uuid,uid,gid,description,directory, case WHEN uuid in (SELECT users.uuid FROM user_groups INNER JOIN users ON user_groups.uid = users.uid WHERE user_groups.gid = 80) THEN "admin" ELSE "standard" END AS user_type from users;
@grahamgilbert
grahamgilbert / profileenforcer.py
Created November 2, 2018 20:57
Profile enforcer. This is an example, no warranty expressed or implied. Use at your own risk.
import sal.plugin
import requests
from django.conf import settings
SETTINGS = settings.PROFILE_SETTINGS
class Profileenforcer(sal.plugin.Widget):
description = 'Enforces profiles via MDM'
@grahamgilbert
grahamgilbert / base64_plist.py
Created September 5, 2016 11:03
Writing a base64 encoded string into a plist
#!/usr/bin/python
import base64
import plistlib
import errno
import os
def mkdir_p(path):
try:
os.makedirs(path)
@grahamgilbert
grahamgilbert / API.md
Created June 24, 2017 15:44
Proposed changes to the API docs

Sal has a REST API. You will need to create an API key before using it. You should send your private key and public key as headers (publickey and privatekey). Some actions can only be performed by API keys that have been marked as read / write in Sal.

General notes

Sal's API will generally return a response similar to the following:

{"count":362,"next":"https://sal.example.com/api/conditions/?condition=machine_type&page=2","previous":null,"results":[...]}
<?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.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>PayloadType</key>
<string>com.apple.applicationaccess.new</string>
<key>PayloadVersion</key>
@grahamgilbert
grahamgilbert / autotimezone.sh
Created August 3, 2016 06:23
Enable Auto TimeZone
#!/bin/bash
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
uuid=`/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57`
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.$uuid LocationServicesEnabled -int 1
/usr/sbin/chown -R _locationd:_locationd /var/db/locationd
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
/usr/sbin/systemsetup -setusingnetworktime on
@grahamgilbert
grahamgilbert / com.grahamgilbert.crypt.launcher.plist
Created December 12, 2013 17:19
LaunchDaemon, LaunchAgent and script to run Crypt as root at login without using a loginhook. The user can click on the desktop and quit the app, but it does get around any networking issues that might happen when running before login is finished.
<?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.0">
<dict>
<key>Label</key>
<string>com.grahamgilbert.crypt.launcher</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/crypt/Crypt.app/Contents/MacOS/Crypt</string>
</array>