Skip to content

Instantly share code, notes, and snippets.

View djtech42's full-sized avatar

Dan Turner djtech42

View GitHub Profile
@djtech42
djtech42 / safariBookmarks.sh
Last active February 20, 2017 05:53
Get Number of Safari Bookmarks on OS X
#!/bin/bash
echo $(ls ~/Library/Caches/Metadata/Safari/Bookmarks | wc -l) bookmarks
@djtech42
djtech42 / randomwords.py
Last active August 29, 2015 14:11
Output Random Words to Terminal
import random
import time
def main():
numOfWords = 50 # change this number to modify how many words show up
word_file = "/usr/share/dict/words" # word file in Unix
words = open(word_file).read().splitlines() # file -> list
dup = ""; word = ""; # initialize strings
@djtech42
djtech42 / trash.sh
Last active August 29, 2015 14:16
Show User Trash Contents
#!/bin/bash
cd ~/.Trash
echo $(ls | wc -l) items in trash
ls
@djtech42
djtech42 / safariHistoryCount.sh
Last active February 20, 2017 05:53
Get Number of Items in Safari History
#!/bin/bash
echo $(ls ~/Library/Caches/Metadata/Safari/History | wc -l) websites in history
@djtech42
djtech42 / revertosxrootless.sh
Last active May 1, 2018 18:11
Disable Rootless Feature (System Integrity Protection) in OS X El Capitan (Updated)
#!/bin/bash
#Beta 4 to Final Public Release (Must be run in Recovery Mode)
csrutil disable
#Beta 1-3
sudo nvram boot-args="rootless=0";sudo reboot
@djtech42
djtech42 / SubviewClosure.swift
Last active August 29, 2015 14:24
Process subviews of a specific type recursively
/**
Perform function on all views that match type specified by function parameter.
*/
func iterateThroughViewsIn<SpecificViewType>(view: UIView, function: SpecificViewType -> Void) {
for subview in view.subviews {
if let viewOfSpecificType = subview as? SpecificViewType {
function(viewOfSpecificType)
}
iterateThroughViewsIn(subview, function: function)
}
@djtech42
djtech42 / icloudscreenshots.sh
Last active August 29, 2015 14:25
Set Up iCloud Drive to Sync OS X Screenshots
#!/bin/bash
defaults write com.apple.screencapture location ~/Library/Mobile\ Documents/com~apple~CloudDocs/Screenshots
killall SystemUIServer
@djtech42
djtech42 / AlcatrazUpdatePlugins.sh
Last active August 29, 2015 14:26
Update All Alcatraz Plugins for Latest Xcode Version (Stable and Beta)
#!/bin/bash
# Update for latest stable Xcode release
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add `defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
# Update for latest beta Xcode release
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add `defaults read /Applications/Xcode-beta.app/Contents/Info DVTPlugInCompatibilityUUID`
@djtech42
djtech42 / dammitXcode.sh
Last active August 29, 2015 14:27
Force Quit Xcode and Don't Open Projects on Reopen
#!/bin/bash
killall Xcode
rm -rf ~/Library/Autosave Information/
rm -rf ~/Library/Saved Application State/com.apple.dt.Xcode.savedState
@djtech42
djtech42 / icloudDriveStatus.sh
Last active August 29, 2015 14:27
Monitor Status of iCloud Drive Files on OS X
#!/bin/bash
brctl log --wait --shorten