Skip to content

Instantly share code, notes, and snippets.

View jacobsalmela's full-sized avatar
:octocat:
To all that makes us unique

Jacob Salmela jacobsalmela

:octocat:
To all that makes us unique
View GitHub Profile
@jacobsalmela
jacobsalmela / removeLoginItems.sh
Created March 3, 2015 20:22
Removes the current user's login items
osascript -e 'tell application "system events" to delete login items'
@jacobsalmela
jacobsalmela / enforceMacHD.sh
Created February 26, 2015 20:03
Reset the volume name to "Macintosh HD" if it is different.
#!/bin/bash
volumeName=$(diskutil info / | awk '/Volume Name/ {print substr ($0, index ($0,$3))}')
echo "Current volume name: $volumeName"
# If the volume is not named Macintosh HD
if [ "$volumeName" != "Macintosh HD" ];then
# Rename it
diskutil renameVolume "$volumeName" "Macintosh HD"
volumeName=$(diskutil info / | awk '/Volume Name/ {print substr ($0, index ($0,$3))}')
echo "Root volume is now named: $volumeName"
@jacobsalmela
jacobsalmela / removeSSID.sh
Created February 26, 2015 20:01
Remove an SSID from the preferred networks list
#!/bin/bash
#----------VARIABLES---------
undesiredNetwork="SSID-To-Remove"
wifiOrAirport=$(/usr/sbin/networksetup -listallnetworkservices | grep -Ei '(Wi-Fi|AirPort)')
echo $wifiOrAirport
wirelessDevice=$(networksetup -listallhardwareports | awk "/$wifiOrAirport/,/Device/" | awk 'NR==2' | cut -d " " -f 2)
echo $wirelessDevice
#-----------SCRIPT-----------
# Remove the SSID from the list of preferred networks
@jacobsalmela
jacobsalmela / unshare_all_printers.sh
Last active August 20, 2022 13:57 — forked from rmanly/unshare_all_printers.bash
Unshares printers and disables Printer Sharing
#!/bin/bash
#while read -r _ _ printer _; do
# /usr/sbin/lpadmin -p "${printer/:}" -o printer-is-shared=false
#done < <(/usr/bin/lpstat -v)
# Slightly faster when there are a lot of printers
lpstat -p | grep printer | cut -d" " -f2 | xargs -I{} lpadmin -p {} -o printer-is-shared=false
# Also disable Printer Sharing in the Sharing pane
cupsctl --no-share-printers
@jacobsalmela
jacobsalmela / disable-animations.sh
Created January 13, 2015 19:54
Disables a bunch of animations
#!/bin/bash
# opening and closing windows and popovers
defaults write -g NSAutomaticWindowAnimationsEnabled -bool false
# smooth scrolling
defaults write -g NSScrollAnimationEnabled -bool false
# showing and hiding sheets, resizing preference windows, zooming windows
# float 0 doesn't work
defaults write -g NSWindowResizeTime -float 0.001
@jacobsalmela
jacobsalmela / rename.sh
Created January 12, 2015 20:21
Rename computers to prepend something
#!/bin/bash
# Get the entire computer name and save it in a variable
#existingName=$(hostname | cut -d'-' -f2-)
existingName=$(hostname)
# Set the computer name to Repurpose-"Existing computer name"
scutil --set LocalHostName "Repurpose-$existingName"
scutil --set ComputerName "Repurpose-$existingName"
scutil --set HostName "Repurpose-$existingName"
serialNum=$(ioreg -l | awk '/IOPlatformSerialNumber/ { split($0, line, "\""); printf("%s\n", line[4]); }')
@jacobsalmela
jacobsalmela / open-in-chrome.sh
Created January 9, 2015 16:32
Opens TestNav in Chrome
# Open test site
osascript -e 'tell application "Google Chrome"
activate
open location "https://testnav.com/mn/testnav-7.5.22.36/"
end tell'
@jacobsalmela
jacobsalmela / enable-accessibility.sh
Created January 5, 2015 18:54
00.Enable accessiblity
case ${OSTYPE} in
# Snow Leopard through Mountain lion
darwin10*) touch /private/var/db/.AccessibilityAPIEnabled;;
darwin11*) touch /private/var/db/.AccessibilityAPIEnabled;;
darwin12*) touch /private/var/db/.AccessibilityAPIEnabled;;
# Mavericks and Yosemite
darwin13*) sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT INTO access VALUES('kTCCServiceAccessibility','com.apple.systemevents',0,1,1,NULL);";
sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT INTO access VALUES('kTCCServiceAccessibility','com.apple.RemoteDesktopAgent',0,1,1,NULL);";;
darwin14*) sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT INTO access VALUES('kTCCServiceAccessibility','com.apple.systemevents',0,1,1,NULL);";
sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT INTO access VALUES('kTCCServiceAccessibility','com.apple.RemoteDesktopAgent',0,1,1,NULL);";;
@jacobsalmela
jacobsalmela / app-store-pkgs.sh
Created December 30, 2014 03:15
Save App Store downloads as .pkgs
#!/bin/bash
appStoreFolder=$(sudo find /private/var/folders -type f -name "*.pkg")
i=0
for package in $appStoreFolder
do
sudo ln $package ~/Downloads/_MAS_$i.pkg
i=$(($i+1))
done
@jacobsalmela
jacobsalmela / safari-exceptions.sh
Last active August 20, 2022 13:57
Adds URLs to Safari's exception list
killall Safari > /dev/null
# Set your variable values here
bud='/usr/libexec/Plistbuddy'
plist='/Users/student/Library/Preferences/com.apple.Safari.plist'
urls=('https://www.testnav.com/mn/testnav-7.5.22.36/'
'https://proctorcaching.pearsonaccess.com/ems/systemCheck/systemCheck.jsp?acc=mn'
'https://testnav.com/mnqc/testnav-7.5.22.36/epatLogin.jsp?testnavTestId=TRG10R14&testnavFormId=S01M4'
'https://testnav.com/mnqc/')