Skip to content

Instantly share code, notes, and snippets.

View adriannier's full-sized avatar

Adrian Nier adriannier

View GitHub Profile
uniqueFilePath('~/Library/Preferences/com.apple.finder.plist')
function uniqueFilePath(parentFolderPath, fileName, suffix) {
/*
Only for use with JavaScript for Automation (JXA)
Generates a unique path by appending a number
to the end of the file name.
-- Create a new Log Manager instance
set LOGGER to newLogManager("~/Desktop/LogManagerTest.log")
tell LOGGER
-- Test by sending 30,000 messages; this should cause the auto archive feature to trigger
repeat 10000 times
infoLog("This is an informational message")
errorLog("This is an error")
debugLog("This is a debug message")
(*
Allows the user to grab a screen selection and places a scaled version on the clipboard.
*)
on run
try
-- Kill current Firefox process, if any
try
do shell script "killall firefox"
end try
-- Delete data
do shell script "rm -rf ~/Library/Application\\ Support/Firefox"
do shell script "rm -rf ~/Library/Caches/Firefox"
do shell script "rm -rf ~/Library/Caches/Mozilla"
do shell script "rm -rf ~/Library/Preferences/org.mozilla.firefox.plist"
on run
(*
iOS QuickTime Viewer
Version 0.2
AppleScript to assist a user to view an iOS devices’ screen
on a Mac using QuickTime Player
/* Open with Apple’s Script Editor in OS X 10.10 or later and set language to JavaScript */
function run(argv) {
try {
// Create a new Quatermain instance
var qm = new Quatermain()
// Make sure Safari is running
@adriannier
adriannier / open_console_as_administrator.applescript
Last active November 23, 2017 12:40
Adds standard user temporarily to admin group, launches Console.app, and removes user from admin group right away.
global gADMIN_USER
global gADMIN_PASSWORD
on run
try
-- Check system requirements
if requireMinimumSystemVersion("10.12.4") is false then return
set thePatterns to "/(r\\s*\\d\\s*\\d\\s*[-\\s]*\\d\\s*\\d\\s*\\d\\s*\\d\\s*\\d)/i"
set theStrings to "R17-11517 r17-11518 r17-11519 R17-11518 R17-11519"
repeat 7 times
set thePatterns to thePatterns & return & thePatterns
set theStrings to theStrings & return & theStrings
end repeat
use framework "Foundation"
use scripting additions
set thePatterns to "(r\\s*\\d\\s*\\d\\s*[-\\s]*\\d\\s*\\d\\s*\\d\\s*\\d\\s*\\d)"
set theStrings to "R17-11517 r17-11518 r17-11519 R17-11518 R17-11519"
repeat 7 times
set thePatterns to thePatterns & return & thePatterns
set theStrings to theStrings & return & theStrings
end repeat
@adriannier
adriannier / count_filemaker_variables.applescript
Created January 10, 2018 23:37
Processes FileMaker scripts or script steps on the clipboard and displays how many times each variable is used.
(*
AppleScript: Count FileMaker Variables
Processes FileMaker scripts or script steps on the clipboard
and displays how many times each variable is used
-----------------------------------------------------------------------------------
Copyright (c) 2018 by Adrian Nier (http://adriannier.de)