Thursday, January 14, 2016

Create a custom PDF quartz filter

1. Open Color Sync utility in /Applications/Utilities
2. Go to Filter 
3. Select the right triangle of Reduce File Size and choose Duplicate 
4. Rename the duplicated filter and adjust the parameters as needed.
5. The duplicated filter will be saved in ~/Libraray/Filters. Move the file *.qfilter to /Library/Filters so that Preview can use it.

Wednesday, December 16, 2015

External hard drive and Spotlight indexing

Spotlight indexing may prevent an external hard drive from being rejected.
The command

sudo lsof | grep /Volumes/Mac\ Backup\ HD/

shows which files on the mounted volume are being accessed.

To disable spotlight, use

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

To enable spotlight,

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist


To disable indexing without turn off spotlight,

mdutil -i off -d /Volumes/REDSTAR

Wednesday, September 30, 2015

Bash shell

Which Bash config to run depends on two conditions -- Interactive vs. Non-interactive, and Login vs. Non-login

Login shell
- Start with 'bash --login' or 'bash -'
- Run the following config files: /etc/profile, ~/.bash_profile, then ~/.bash_login and lastly ~/.profile. When login shells exit, they read ~/.bash_logout.

Nonlogin shell
- Read .bashrc
- Should not put any output-producing code in this file because the standard stream could be redirected.

Wednesday, September 9, 2015

Keep tracks of defaults write and Useful defaults write commands

In .bashrc, create the line

PROMPT_COMMAND='echo "$(history 1 | grep "defaults")" | sed '/^$/d' >> ~/Documents/defaults.txt'

To undo the changes, use 'defaults delete'. For example,
defaults write xxx - bool false
defaults delete xxx

- Change to transparent dock in Mavericks

defaults write com.apple.dock hide-mirror -bool true;killall Dock

- Change screen capture file format

defaults write com.apple.screencapture type jpg; killall SystemUIServer
defaults write com.apple.screencapture disable-shadow -bool false

- Add 'Save as' back to applications

defaults write com.apple.iWork.Keynote ApplePersistence - bool no
defaults write com.apple.TextEdit ApplePersistence - bool no
defaults write com.apple.Preview ApplePersistence - bool no







Sunday, August 2, 2015

Reduce Keynote file size

Whenever a custom theme is applied to a Keynote presentation, several unused theme files will be added automatically (Unzip the keynote file and look in the theme-files directory). This makes the file size 5-6 MB larger. 

So, to have a small keynote file, do the following
1. Select a plain Keynote theme, e.g., White
2. Customize the look and feel of slides as desired.
3. Save the file as a normal Keynote presentation, say template.key
The file size should be about a few hundred KB.
Disable "Include Preview in the document". Otherwise the file will be large.
4. Create a new presentation from template.key, not from a theme chooser.
This prevents Keynote from saving unused theme files in the presentation and 
will keep the presentation file size small. 

A keynote file is actually just a compressed folder.
For an existing Keynote file with large size, you can unzip the keynote file and look inside 
to see if 
- it contains a large preview file
- it contains theme files  
- it includes large image files 

Unused theme files can be deleted and touched to make it zero bytes with the following bash script:
#!/bin/bash

for file in $(ls stone*.jpg); do
  echo "Processing $file ... "
  rm -f $file
  touch $file
done

Then, compressed the keynote folder and rename the zip file back to .key extension. 



Tuesday, June 9, 2015

Change Font Smoothing

To decrease the level of anti-aliasing, use

defaults -currentHost write -globalDomain AppleFontSmoothing -int 1

Level 0  = No anti-aliasing
Level 3  = Max anti-aliasing (Default)

Log out and log in for the change to take effect.

Monday, June 8, 2015

How to become a root in MAC OS X

From Terminal when logged in as an admin user -
dsenableroot to enable,
dsenableroot -d to disable