tinyapps.org / blog


Preparing a Mac for resale or donation (Sierra edition) #

  1. Securely erase internal storage, install macOS, create temporary admin account (e.g., tempuser), install apps and updates, etc.
  2. Log in normally as tempuser and run:
    $ sudo dscl . -delete /Groups/admin GroupMembership tempuser
    $ sudo dscl . -delete /Users/tempuser
  3. Restart in Single User Mode and run:
    # fsck -fy
    # mount -uw /
    # rm -R /Users/tempuser
    # rm /var/db/.AppleSetupDone
    # shutdown -h now

Sources

Regarding iLife and iWork apps

/mac | Feb 18, 2017

Reset Safari 10 in OS X 10.11 El Capitan #

Turn this:

Safari junk

into this:

Safari clean

#!/bin/bash

# Reset Safari 10 for current user. Developed and tested under OS X 10.11.6 El Capitan.

# Backup bookmarks to Desktop, exiting if unsuccessful
cp -v ~/Library/Safari/Bookmarks.plist ~/Desktop/Bookmarks-`date +%Y%m%d%H%M%S`.plist
if [[ $? -ne 0 ]]; then exit 1; fi

# Delete main Safari data directory
rm -rfv ~/Library/Safari

# Delete caches
rm -rfv ~/Library/Caches/com.apple.Safari
rm -rfv ~/Library/Caches/com.apple.Safari.SearchHelper
rm -rfv ~/Library/Caches/com.apple.safaridavclient
rm -rfv ~/Library/Caches/com.apple.WebKit.PluginProcess
rm -rfv ~/Library/Caches/Metadata/Safari
rm -rfv ~/Library/Caches/SafariNotificationAgent
rm -rfv ~/Library/Caches/com.apple.commerce.safari/SafariLibrary

# Delete cookies
rm -rfv ~/Library/Cookies/Cookies.binarycookies
rm -rfv ~/Library/Cookies/com.apple.safari.cookies
rm -rfv ~/Library/Cookies/com.apple.CaptiveNetworkAssistant.binarycookies
rm -rfv ~/Library/Cookies/com.apple.Safari.SafeBrowsing.binarycookies
rm -rfv ~/Library/Cookies/com.apple.Safari.SearchHelper.binarycookies

# Delete preferences
rm -rfv ~/Library/Preferences/com.apple.Safari.LSSharedFileList.plist
rm -rfv ~/Library/Preferences/com.apple.Safari.RSS.plist
rm -rfv ~/Library/Preferences/com.apple.Safari.plist
rm -rfv ~/Library/Preferences/com.apple.Safari.Extensions.plist
rm -rfv ~/Library/Preferences/com.apple.WebFoundation.plist
rm -rfv ~/Library/Preferences/com.apple.WebKit.PluginHost.plist
rm -rfv ~/Library/Preferences/com.apple.WebKit.PluginProcess.plist
rm -rfv ~/Library/Preferences/com.apple.commerce.safari.plist

# Delete saved state
rm -rfv ~/Library/Saved\ Application\ State/com.apple.Safari.savedState

# Delete RSS feeds subscribed in Safari or Mail
# More info on PubSub database and command:
# http://krypted.com/mac-os-x/managing-mail-and-safari-rss-subscriptions-from-the-command-line/
rm -rfv ~/Library/PubSub/Database

# Delete yet more Safari data (cannot find any definitive documentation on this directory)
rm -rfv ~/Library/WebKit/com.apple.Safari

# Delete SharedFileList
rm -rfv ~/Library/Application Support/com.apple.sharedfilelist/com.apple.LSSharedFileList.ApplicationRecentDocuments/com.apple.safari.sfl

# Delete LSOs / Flash cookies
rm -rfv ~/Library/Caches/Adobe/Flash\ Player

# Clear download history from all browsers, including Safari
# More info: http://osxdaily.com/2012/07/12/list-download-history-mac-os-x/
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'

# Delete QuickTime cache
rm -rfv ~/Library/Caches/QuickTime

printf "\n\n\033[1;32mSafari cleanup complete.\n\n\033[1;31mThe contens of /Library/Internet Plug-Ins and ~/Library/Internet Plug-Ins\nwill appear below after pressing Enter. Check output for unwated plugins.\nPreserve Quartz Composer.webplugin & Default Browser.plugin at a minimum.\033[0m\n\n"

read -p "Press Enter to continue."

# List contents of /Library/Internet Plug-Ins and ~/Library/Internet Plug-Ins
ls -Ah /Library/Internet\ Plug-Ins ~/Library/Internet\ Plug-Ins

Sources:

  1. Testing with fs_usage and File Buddy in a clean VM.
  2. completely reset Safari 9
  3. How to reset safari 9.0.3
  4. Reset Safari from command line
  5. Reset Safari doesn't really clean all the cookies of Safari web browser
  6. History in Safari
  7. Aborting a shell script if any command returns a non-zero value?
  8. In a bash script, how can I exit the entire script if a certain condition occurs?
  9. guapolo's answer to How to get osx shell script to show colors in echo

/mac | Feb 11, 2017

Still using Yahoo Mail? #

/misc | Feb 10, 2017

List all files on disk #

Even as root, ls and find produced too many errors ("Permission denied", "Not a directory", "directory causes a cycle", "Input/output error", etc) when attempting to list all files on disk. Tree worked a treat:

$ tree -a -i -f / > filesystemlist.txt

 -a All files are listed.
 -i Don't print indentation lines.
 -f Print the full path prefix for each file.
See also Tree for Windows and LINUX Recursively list all files in a directory including files in symlink directories.

/nix | Feb 06, 2017

Migrating from Mail.app to Thunderbird #

/mac | Feb 05, 2017

Batch remove all tiles from Windows 10 Start Menu #

Well, almost all tiles; the few that remain after running the script below (save as unpin.ps1 then right click and "Run with PowerShell") can be removed manually (right click tile > "Unpin from Start").

/windows | Feb 04, 2017

Convert asciidoc to markdown #

  1. Install pandoc and asciidoc

    $ sudo apt install pandoc asciidoc

  2. Convert asciidoc to docbook

    $ asciidoc -b docbook foo.adoc

    foo.xml will be output into the same directory as foo.adoc

  3. Convert docbook to markdown

    $ pandoc -f docbook -t markdown_strict foo.xml -o foo.md

  4. Unicode symbols were mangled in foo.md. Quick workaround:

    $ iconv -t utf-8 foo.xml | pandoc -f docbook -t markdown_strict | iconv -f utf-8 > foo.md

  5. Pandoc inserted hard line breaks at 80 characters. Removed like so:

    $ iconv -t utf-8 foo.xml | pandoc -f docbook -t markdown_strict --wrap=none | iconv -f utf-8 > foo.md

/nix | Jan 24, 2017

3 Mac file-related apps #

from a blog post (and related comments) on Robservatory:

/mac | Jan 23, 2017

Objections to veganism #

Vegan Sidekick has a handy guide to justifications for harming and exploiting animals. TL;DR: this comic covers much of it.

/misc | Jan 23, 2017

Direct download of Boot Camp drivers #

  1. From within Windows (or OS X) via Timothy Sutton's Brigadier Python script
  2. From within OS X via Boot Camp Assistant > Action > Download Windows Support Software
  3. From within a browser (for Windows 7/Boot Camp 4 & 5.1) via this Apple page

/mac | Dec 10, 2016


Subscribe or visit the archives