Cool Stuff

I intend to put quite a bit more on this page. There are just so many useful little snippits of cool tools and timesavers around for OS X that I'd like to share a few.

Javascript in browser bookmarks (cross platform)

One new feature of browsers that I like very much is their ability to run javascript within bookmarks. I have several of these in the bookmark toolbars of both Safari and Firefox. I thought I'd share the most useful of these. They can be copied and used by simply dragging the links I have provided to the bookmark toolbar of your browser (or anywhere in your bookmark collection). You should probably shorten the names of the bookmarks you put in your toolbar to save space.

When clicked, the link will resize your browser's window to 1024x970 pixels.
Resize browser window to 1024x970
javascript:self.moveTo(20,0);self.resizeTo(1024,970);

Resizes your browser window to full screen.
Resize browser window to full screen
javascript:self.moveTo(20,0);self.resizeTo(screen.availWidth-10,screen.availHeight);

Clicking bookmark prints the current browser page.
Print current page
javascript:self.print();

My favorite bookmark. Select some text on a page and click the bookmark to Google what you selected. Eliminates the copy - paste steps.
Search Google for selected text
javascript:x=escape(getSelection());window.location=%20%20'http://www.google.com/search?q='+x;

Use the w3.org HTML validator service.
Validate current page's HTML
javascript:void(document.location='http://validator.w3.org/check?uri='+document.location);

Check the links on your browsers current page. Best demonstrated by trying it as a bookmark and not as a clickable link on this page due to all the javascript in the links here.
Validate Links (HREFs) for Current Page
javascript:void(document.location='http://validator.w3.org/checklink?url='+document.location);

Test arbitrary lines of javascript.
Execute arbitrary javascripts
javascript:var%20c='document.location.href',r='';while(c=prompt(r+'Enter%20the%20code%20to%20be%20executed:',c)){try{r='Returned:%20'+eval(c)+'\n';}catch(err){r='Error:%20'+err.message+'\n';}}

Show a web page's DIV Borders with their IDs
Show DIV Borders with their IDs
javascript:var%20a=document.getElementsByTagName('div');var%20aspan;var%20txtNode;for(var%20b=0;%20b%20%3C%20a.length;b++){%09a[b].style.border='1px%20solid%20red';%09%09if(a[b].id%20!=%20''){%09%09aspan%20=%20document.createElement('span');%09%09aspan.setAttribute('id',%20't_ttp'%20+%20a[b].id);%09%09aspan.setAttribute('style',%20'position:relative;top:1px;left:1px;%20margin:10px%200px%200px%2010px;background-color:%20beige;max-width:220;padding:%202px%2010px%202px%2010px;border:%201px%20solid%20#C0C0C0;font:%20normal%2010px/12px%20verdana;color:%20%23000;text-align:left;display:%20block;');%09%09txtNode%20=%20document.createTextNode('div:%20'%20+%20a[b].id);%09%09aspan.appendChild(txtNode);%09%09a[b].appendChild(aspan);}}

Mac OS X Terminal and Defaults

These are the defaults commands which I find most useful. Most of these commands were discovered at macosxhints.com. Defaults commands are potentially destructive as well as very useful. Use them sparingly and with caution. As in any good relationship, try not to give too many commands ;-)

Add a library listing to iTunes that contains everything - Music, movies, audiobooks etc.
This comes from Doug Adams, who maintains Doug's AppleScripts for iTunes, the web's best and last word for scripting iTunes. Quit iTunes prior to running these commands.

Run the following commands in Terminal:
defaults write com.apple.iTunes show-library-playlist -bool TRUE
defaults write com.apple.iTunes hide-library-playlist -bool FALSE

To return to the previous settings:
defaults write com.apple.iTunes show-library-playlist -bool FALSE
defaults write com.apple.iTunes hide-library-playlist -bool TRUE

Force links that spawn new windows to open in new tabs in Safari
defaults write com.apple.Safari TargetedClicksCreateTabs -bool TRUE
To undo, change TRUE to FALSE

Disable iTunes store arrow links in iTunes 8
defaults write com.apple.iTunes show-store-arrow-links -bool FALSE
To undo, change FALSE to TRUE

Make Help Viewer display a normal window - i.e. not always in front of everything
defaults write com.apple.helpviewer NormalWindow -bool TRUE
To undo, change TRUE to FALSE

Disable shadow in screen window captures
defaults write com.apple.screencapture disable-shadow -bool TRUE
To undo, change TRUE to FALSE

Stuff for no good reason:

An AppleScript based random quote generator
About 2000 famous quotes and misattributions called randomly. Has a "Try Again" button if you don't like what comes up.
Open Random Quote Generator in Script Editor