Skip to content

Instantly share code, notes, and snippets.

@opshope
opshope / gam_add_suspended_users_to_group.sh
Created May 2, 2016 17:49
Adds suspended google apps users to a google group. Useful for ignoring suspended users when importing accounts to OneLogin.
GROUP_TO_ADD_TO="suspended"
gam print users suspended | grep -iv '@operationhopeboard.org'| grep 'True' |
cut -d',' -f1 | while read user; do
gam update group "$GROUP_TO_ADD_TO" add member user "$user"
done
@opshope
opshope / google_translate_div.html
Created March 28, 2016 15:53
Google Translate Button for operationhope.org
<div id="google_translate_element"></div><script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
@opshope
opshope / automatic_time_zone.sh
Last active October 19, 2022 18:58
Enable location services and set time zone automatically Mac
#stolen from https://jamfnation.jamfsoftware.com/discussion.html?id=12979
/bin/echo "set time zone automatically using current location"
# enable location services
/bin/launchctl unload /System/Library/LaunchDaemons/com.apple.locationd.plist
uuid=`/usr/sbin/system_profiler SPHardwareDataType | grep "Hardware UUID" | cut -c22-57`
/usr/bin/defaults write /var/db/locationd/Library/Preferences/ByHost/com.apple.locationd.$uuid LocationServicesEnabled -int 1
/usr/sbin/chown -R _locationd:_locationd /var/db/locationd
/bin/launchctl load /System/Library/LaunchDaemons/com.apple.locationd.plist
# set time zone automatically using current location
@opshope
opshope / yosemite_loading_bar_freeze_fix.sh
Created January 4, 2016 17:48
Fixes a freezing loading bar at boot screen. Run from single user mode or over ssh.
#!/usr/bin/env bash
#try resetting pram & smc first
#try to ssh into the the machine if it appears to be stuck booting (50% loading bar)
#if that fails, try booting holding command+r and repair disk/repair disk permissions
#some comment from internet: verify if the user has the attribute which again in our case they always do when this issue happens because there were some machines that were manually bound a long time ago by some of the PC techs and they weren't paying attention to the checkboxes in Directory Utility so this attribute would get created.
#dscl . -read /Users/<user> OriginalHomeDirectory
#dscl -u <admin username> . -delete /Users/<user> OriginalHomeDirectory
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport && sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
rm -Rfv ~/Library/Preferences/*luetooth*
rm -Rfv ~/Library/Preferences/ByHost/*luetooth*
sudo rm -Rfv /Library/Preferences/*luetooth*
nvram -c
sudo reboot
@opshope
opshope / reveal_autologin_password.sh
Created November 17, 2015 18:02
Decrypt the auto-login password stored in /etc/kcpassword on OSX
sudo ruby -e 'key = [125, 137, 82, 35, 210, 188, 221, 234, 163, 185, 31]; IO.read("/etc/kcpassword").bytes.each_with_index { |b, i| break if key.include?(b); print [b ^ key[i % key.size]].pack("U*") }'
@opshope
opshope / ProgressDialog.py
Created November 9, 2015 17:42 — forked from pudquick/ProgressDialog.py
This is python for a portable, self-contained class called "ProgressDialog" which allows you to create a Cocoa progress indicator dialog for OS X while you do things in a script. Enjoy.
class ProgressDialog(object):
def __init__(self, message, title, use_bar=True):
super(self.__class__, self).__init__()
self.message = message
self.title = title
self.use_bar = use_bar
self.queue = None
self.process = None
def display(self):
# [ begin black magic ]
@opshope
opshope / revert_core_storage.sh
Created November 2, 2015 18:20
Faronics DeepFreeze CoreStorage Fix
disk="$(diskutil cs list | grep -i revert -B4 | grep -i disk | awk '{print $2}')"
diskutil cs revert /dev/"$disk" && reboot
@opshope
opshope / find_scriptable_plist_settings.sh
Created September 23, 2015 23:35
A tool to figure out which settings are stored in which plist after changing a preference
defaults read > a
#Change the setting
defaults read > b
diff a b