Skip to content

Instantly share code, notes, and snippets.

View djtech42's full-sized avatar

Dan Turner djtech42

View GitHub Profile
@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 / 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
@djtech42
djtech42 / allScriptsExecutable.sh
Last active August 29, 2015 14:27
Grant Executable Permission for All Shell Scripts in Directory
#!/bin/bash
chmod +x *.sh
@djtech42
djtech42 / largeCacheFinder.sh
Last active August 29, 2015 14:27
Show Largest Caches in OS X User Library
#!/bin/bash
du -s ~/Library/Caches/* | sort -n -r
@djtech42
djtech42 / xcodeInstances.sh
Last active August 29, 2015 14:27
Warn if there is more than one instance of Xcode running (Ex. Xcode and Xcode Beta are running at the same time)
#!/bin/bash
NUMOFLINES=`pgrep -ax Xcode | wc -l `
if [ $NUMOFLINES -eq 1 ]
then
echo "Everything's fine. Only one instance of Xcode running."
elif [ $NUMOFLINES -eq 0 ]
then
echo "No instances of Xcode are running."
else
echo "Warning! $NUMOFLINES Xcode instances running"