Skip to content

Instantly share code, notes, and snippets.


Keybase proof

I hereby claim:

  • I am grahamgilbert on github.
  • I am grahamgilbert ( on keybase.
  • I have a public key ASDdB4_Tt3Pfh7-qvEoOSZCAfoUJoxgTtv8YoyA3MTGHdwo

To claim this, I am signing this object:

View gist:0ddb239a004fb2c2bbcda4a60d2b4d43
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 /
Created Nov 2, 2018
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
class Profileenforcer(sal.plugin.Widget):
description = 'Enforces profiles via MDM'
grahamgilbert /
Created May 9, 2018
Clean out old apple updates (older than 24 hours) because softwareupdate often refuses to install them
Removes cached apple updates that are older than 24 hours
import datetime
import os
import shutil
import sys
grahamgilbert / cloudSettings
Last active Jul 17, 2020
Visual Studio Code Settings Sync Gist
View cloudSettings
grahamgilbert /
Created Jun 24, 2017
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:

grahamgilbert /
Created Sep 5, 2016
Writing a base64 encoded string into a plist
import base64
import plistlib
import errno
import os
def mkdir_p(path):
/bin/launchctl unload /System/Library/LaunchDaemons/
uuid=`/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57`
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/$uuid LocationServicesEnabled -int 1
/usr/sbin/chown -R _locationd:_locationd /var/db/locationd
/bin/launchctl load /System/Library/LaunchDaemons/
/usr/sbin/systemsetup -setusingnetworktime on
View RepairPermissions-1.0.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
grahamgilbert /
Created Jan 5, 2016
Script that will check if an app has been inactive for five minutes and quits if needed
""" Graham Gilbert 5/1/16
Change TARGET_APP and the app name on line 53 to your chosen app to quit.
Run this as often as you'd like via a launchagent.
No warranty expressed or implied. If things go kaboom, it's your problem!
from AppKit import NSWorkspace
You can’t perform that action at this time.