Useful Stuff

Here are some files and other stuff that I have found useful over the years.


Dictionary to JSON in the Xcode debugger

If you are stopped at a break point while developing an iOS application in Objective-C, and you have an NSDictionary or NSMutableDictionary that you want to turn into JSON text, you can enter this command into the debugger, where you would substitute your dictionary for ‘theDictionary’ below:

po [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:theDictionary options:1 error:nil] encoding:4]

Hide icons on MacOS desktop

To hide all of the icons from the desktop of your MacOS machine, open the Terminal application and enter this command:

defaults write com.apple.finder CreateDesktop false; killall Finder

Then, once you are done with your screen capture or recording, you can use this command to restore icons back:

defaults write com.apple.finder CreateDesktop true; killall Finder

Finding files by name on a Mac

If you want to find all the files on your Mac that match a particular file name or pattern with wildcards, go into Terminal and enter the following command:

sudo find ./ -name "filename*.ext"

The sudo may require an administrative password, but will likely keep you from seeing a bunch of “Permission denied” errors.


Finding files by contained text on a Mac

If you want to find all the files on your Mac that contain a particular text string, go into Terminal and enter one of the following commands:

grep -r 'TextToFind' .
grep -r 'TextToFind' . --include=*.txt

The first one will recursively search all files starting at the current directory, and the second one will only search the files with a .txt file extension. Also, please keep in mind that the text search is case sensitive.


Removing .svn folders on a Mac

After you open up the Terminal and change to the root directory where the .svn folders start, enter the following command:

find ./ -name ".svn" | xargs rm -Rf

Windows 7 batch file command

enquire.com batch file command — I used this for the longest time in on my 32-bit Windows dev boxes to collect key presses inside of my batch files. Unfortunately, this application does not work on my Windows 7 Ultimate 64-bit OS, so I have to modify all of my batch files to use the choice command instead.


Animated GIFs

daffy_swinging

bugs_and_daffy

black_lab

Leave a Reply