Skip to content

Instantly share code, notes, and snippets.

@scriptingosx
scriptingosx / firefox.cfg
Last active August 29, 2015 14:14
Firefox Configuration File for USC Labs
// This file sets some default prefs for use at USC Labs
// and locks down some other prefs.
//
// Safari Migration
lockPref("browser.migration.version", 1);
lockPref("browser.places.importBookmarksHTML", false);
lockPref("network.cookie.prefsMigrated", true);
// application updates
lockPref("app.update.enabled", false);
@scriptingosx
scriptingosx / Lock Mac.scpt
Created February 3, 2015 19:40
Use these scripts to lock and unlock your Mac with GeoHopper.
on processIsRunning(appName)
tell application "System Events"
return process appName exists
end tell
end processIsRunning
on GoGoGeohop(email, subject)
-- pause iTunes
if processIsRunning("iTunes") then
tell application "iTunes"
@scriptingosx
scriptingosx / Check with flake8.applescript
Last active August 29, 2015 14:19
BBEdit: Check Python with flake 8
(*
run flake8 against the frontmost BBEdit document
You need to install flake8 with
sudo easy_install flake8
more info here http://flake8.readthedocs.org/en/latest/
*)
@scriptingosx
scriptingosx / ssh-installer.sh
Created October 17, 2016 12:25
ssh-installer tool for macOS to `scp` a package to a remote host and install it
#!/bin/sh
PATH=/usr/bin:/bin:/usr/sbin:/sbin export PATH
# ssh-installer
# copies a pkg with scp and runs installer on target
# usage: ssh-installer [USER@]HOST PKGFILE [other installer options]
TMPPKGDIR="/private/tmp/ssh-installer/"
@scriptingosx
scriptingosx / shellcheck
Last active January 13, 2017 19:24
check frontmost BBEdit window with spellcheck http://shellcheck.net
tell application "BBEdit"
if not (exists text document 1) then
return
end if
if source language of text document 1 is not "UNIX Shell Script" then
set thename to name of text document 1
display dialog "Document '" & thename & "' does not seem to be a shell script!"
return
end if
global html
global processedURLs
on appendLineWithDoc(theDoc)
tell application "Safari"
tell theDoc
try
my appendHTML(" <li>")
my appendHTML("<a href=\"" & URL & "\">")
my appendHTML(name)
@scriptingosx
scriptingosx / .bash_profile
Last active June 4, 2017 19:55
Sample bash_profile file for the article: http://wp.me/p69KII-64
# ENVIRONMENT VARIABLES
# add my ~/bin dir to path
PATH=${PATH}:~/bin
export PATH
# simple prompt
# default macOS prompt is: \h:\W \u\$
export PS1="\W \$ "
@scriptingosx
scriptingosx / computerimage.py
Created January 9, 2018 14:37
Cocoa Python code to generate an image file for the current Mac model
#!/usr/bin/python
from Cocoa import NSImage, NSImageNameComputer, NSSize, NSMakeSize, NSMakeRect, NSBitmapImageRep, NSPNGFileType, NSData
from CoreGraphics import CGImage
from objc import NULL
size = NSMakeSize(512, 512)
image = NSImage.imageNamed_(NSImageNameComputer)
image.setSize_(size)
<?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>PayloadContent</key>
<dict>
<key>com.apple.driver.AppleHIDMouse</key>
@scriptingosx
scriptingosx / EmptyProfile.mobileconfig
Last active August 17, 2018 12:14
Empty Mobile Configuration file suitable as a placeholder for certain operations
<?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>PayloadDescription</key>
<string>Empty Profile that controls nothing</string>
<key>PayloadDisplayName</key>