Skip to content

Instantly share code, notes, and snippets.

View AndrewWCarson's full-sized avatar
🐦

Andrew Worth Carson AndrewWCarson

🐦
View GitHub Profile
@AndrewWCarson
AndrewWCarson / Addigy Packages Size (readable).sh
Created November 30, 2022 05:12
An example Custom Fact for Addigy to report the packages file size in human readable format.
#!/bin/zsh
packagesDir="/Library/Addigy/ansible/packages"
if [ ! -d "${packagesDir}" ]; then
echo "0B"
else
/usr/bin/du -h -d 0 /Library/Addigy/ansible/packages | awk '{print $1}'
fi
@AndrewWCarson
AndrewWCarson / Uninstall Wacom Tablet.sh
Created October 27, 2021 19:23
A "best effort" uninstall of Wacom Tablet drivers and files.
#!/bin/zsh
# Wacom Files
declare -a systemFiles=('/Applications/Wacom Tablet'
'/Library/Application Support/Tablet'
'/Library/Frameworks/WacomMultiTouch.framework'
'/Library/Internet Plugins/WacomTabletPlugin.plugin'
'/Library/Launch Agents/com.wacom.wacomtablet.plist'
'/Library/LaunchDaemons/com.wacom.displayhelper.plist'
'/Library/LaunchDaemons/com.wacom.RemoveTabletHelper.plist'
@AndrewWCarson
AndrewWCarson / IOKit Discovery.swift
Last active July 14, 2021 14:02
Simple usage of the IOKit framework for macOS in Swift. Note: IOKit is not compatible with App Sandbox and is not suitable for the App Store.
//
// IOKit Discovery.swift
//
// Created by Andrew Worth Carson on 7/13/21.
//
import Foundation
import IOKit
enum CFType {
@AndrewWCarson
AndrewWCarson / getWordsFromPhoneNumber.py
Created July 11, 2021 09:32
A simple python solution to the phone number word search problem here: https://www.youtube.com/watch?v=PIeiiceWe_w
#!/usr/bin/env python
import math
# Function: numberFromWord
# - wordString: a String representative of the word
# Returns:
# - number: an Integer representative of the screen based on map
def numberFromWord(wordStr):
phoneMap = {"a": 2, "b": 2, "c": 2,
@AndrewWCarson
AndrewWCarson / List User Directory Sizes.sh
Created June 16, 2021 09:36
Prints all non-system users, their home directory, and the size of the directory in human-readable format.
#!/bin/zsh
for user in $(dscl . list /Users UniqueID | awk '$2 >= 500 {print $1}'); do
userHome=$(dscl . read /Users/"$user" NFSHomeDirectory | sed 's/NFSHomeDirectory://' | grep "/" | sed 's/^[ \t]*//')
if [ -d "$userHome" ]; then
size=$(/usr/bin/du -h -d 0 "$userHome" 2> /dev/null | awk '{print $1}')
echo "$user:$userHome:$size"
fi
done
@AndrewWCarson
AndrewWCarson / runelite-logstream.tsv
Created July 4, 2020 05:15
Runelite Logstream macOS 11
error 22:07:37.003796-0700 Finder LAUNCH: No architectures specified in launch archictectures [ NULL ] for app=file:///Applications/RuneLite.app which likely is an error.
default 22:07:37.004149-0700 runningboardd Executing launch request for app<application.net.runelite.launcher.6564800.6564806(501)> (LS launch net.runelite.launcher)
default 22:07:37.004201-0700 runningboardd Creating and launching job for: app<application.net.runelite.launcher.6564800.6564806(501)>
default 22:07:37.009486-0700 runningboardd [app<application.net.runelite.launcher.6564800.6564806(501)>:7150] This process will not be managed.
default 22:07:37.009515-0700 runningboardd Now tracking process: [app<application.net.runelite.launcher.6564800.6564806(501)>:7150]
default 22:07:37.009558-0700 runningboardd Using default underlying assertion for app: [app<application.net.runelite.launcher.6564800.6564806(501)>:7150]
default 22:07:37.009598-0700 runningboardd Calculated state for app<application.net.runelite.launcher.6564800.6564806(501
@AndrewWCarson
AndrewWCarson / Add Python to Privacy--Location Services List.py
Last active July 23, 2021 00:49
This adds an app to the list displayed in System Preferences -> Privacy -> Location Services. It does not enable the app there.
#!/usr/bin/python
import CoreLocation
CLValidAuth = [CoreLocation.kCLAuthorizationStatusAuthorized]
def locationServicesEnabled():
if CoreLocation.CLLocationManager.locationServicesEnabled():
return True
else:
@AndrewWCarson
AndrewWCarson / homebrew-self-service-install.sh
Created December 13, 2019 18:36
Homebrew Self Service Install
#!/bin/bash
osascript << EOF
tell application "Terminal"
activate
set user to do shell script "stat -f%Su /dev/console"
do script "sudo -u " & user & ' /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"' in window 2
tell application "System Events" to key code 36
end tell
EOF
@AndrewWCarson
AndrewWCarson / marketing.py
Created December 5, 2019 22:52 — forked from pudquick/marketing.py
Using PrivateFrameworks to get marketing model information for Apple Macs without hitting their internet API (where possible) via python and pyobjc
# Tested on 10.11
# Note:
# The marketing information embedded in the ServerInformation.framework is not the same as what
# About This Mac displays - there are differences.
#
# For example:
# ServerInformation: 15" MacBook Pro with Retina display (Mid 2015)
# About This Mac: MacBook Pro (Retina, 15-inch, Mid 2015)
#
@AndrewWCarson
AndrewWCarson / enable-current-user-to-manage-print-queue.sh
Created December 5, 2019 20:20
Enable Current User to Manage Print Queue
#!/bin/bash
user=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
dseditgroup -o edit -a "$(user)" _lpoperator