Written by David on Fri, Oct 21, 2011 at 3:40pm
Filed under OS X
OS X Mail defaults to including all attachments at the end of emails. While useful for some file types (ZIP archives, programs, etc.), I still prefer that images be embedded exactly where I paste them in a message.
This insert-at-the-end behaviour can be disabled by unchecking an option in the Edit/Attachments menu:

Unfortunately, the option always reverts to being checked again for subsequent emails, with no obvious way to disable this behaviour permanently. As it turns out, the solution is simple:
If you disable this option while editing an email, it will remain disabled for that message only. If you disable this option from the main window, it will remain disabled for all future messages.
Tangentially, the option to “Send Windows-Friendly Attachments” can only be toggled when you are not editing an email. When you have a message screen open, the option is greyed out.
These options seem like perfect candidates for Mail’s Preferences menu. Why they exist solely as menu options and why they behave this way remains a mystery to me.
Written by David on Mon, Oct 17, 2011 at 4:05pm
Filed under OS X, Security, Unix
nginx defaults to running its master process as root and all workers as nobody.
You can tell nginx to run worker processes under different credentials by setting the user directive in nginx.conf.
On OS X, you need to specify a valid group as well, since nginx will default to looking for a group that doesn’t exist. You will see “nginx – getgrnam()” in the error log when this happens. The easiest solution I found is to assign the OS X staff group:
user userid staff
It probably bears mentioning that changing the runtime credentials won’t negate the need for sudo if you run your web server on port 80, since OS X (and all Unixes) will not allow nginx to use that port unless it runs as root.
Written by David on Fri, Oct 14, 2011 at 5:55pm
Filed under OS X
OS X’s dock allows the addition of spacer tiles, blank objects that occupy the same space as an application icon. Spacer tiles are quite helpful for organising applications into logical groups.

Adding spacer tiles is relatively simple:
- Launch Terminal (from Applications/Utilities).
- Cut and paste the following into the command line, once for each tile you want to add. (Need 4 tiles? Run it 4x.)
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'
- Restart the dock:
killall Dock
Spacer tiles behave like normal application icons: they can be dragged into any position, or dragged out of the dock completely to remove them.
Written by David on Thu, Sep 29, 2011 at 2:06pm
Filed under OS X, Unix
Lion’s Terminal app and its tabbed full-screen mode is a huge improvement for me. One thing that became a minor annoyance, however, is Terminal’s failure to quit when the last console session ends: Cmd-Q is still required to quit the app completely.
The workaround I chose takes advantage of existing muscle memory. I had already configured an alias for exit, allowing me to type x to end a console session.
To solve the Terminal app problem, I repurposed x as a function in my ~/.bash_profile:
function x {
[ "$(w -h | grep "^$(whoami) *s[^ ]* *-"|wc -l)" -le 1 ] && osascript -e 'tell application "Terminal" to quit' || exit
}
The function checks for the number of active console sessions. When x is called and only one session remains, osascript is invoked to quit the Terminal app completely.
Written by David on Tue, Jun 29, 2010 at 4:09am
Filed under iOS
The Hold button was replaced with FaceTime on iPhone 4′s call menu.
You can still place calls on hold: just tap and hold Mute for 2 seconds.

Written by David on Sun, Sep 6, 2009 at 3:19am
Filed under iOS, Social Engineering
Facebook’s iPhone app seems to integrate with the Facebook Platform using the same rules that other applications must follow. After you sign in to the iPhone app for the first time, a corresponding Facebook app, Facebook for iPhone, is automatically granted access to your profile.
There is nothing unusual about this; Facebook is merely playing by their own rules. But there is an interesting side effect.
Facebook is a social platform, so all application pages allow you to list other friends using that app. Facebook for iPhone, the Facebook counterpart for the iPhone app, is no different.
These are all your Facebook friends who use (or once used)…
It is worth noting that the Facebook for iPhone app remains in your profile until you explicitly remove it, so results may be misleading. (After all, how would Facebook know that your iPhone fell into the toilet, when you may simply not have run their app for a long time?)
If any of this bothers you, breathe deeply… then get off the internet.
And my lawn.
Written by David on Mon, Aug 17, 2009 at 4:59pm
Filed under OS X
Accessing the OS X clipboard (or “pasteboard”) from the CLI is made simple with the pbcopy and pbpaste commands:
cat ~/ confidential_information.txt | pbcopy
pbpaste > confidential_information.txt
The pbcopy/pbpaste manpages have more detailed information about their use.
An interesting footnote to OS X’s clipboard system is that there are actually four pasteboards, each assigned to its own, unique purpose. The Find clipboard is particularly useful because it enables search queries to be saved automatically between applications. To test this, enter a string in (for example) Firefox’s search box. Don’t copy it to the clipboard. Now open your text editor and start a new search. The same string should already be in the dialog box…
Written by David on Sat, Feb 7, 2009 at 12:04am
Filed under Google, OS X
UPDATE
Parsa Fatehi kindly points out below that Google now has a simpler solution:
http://www.google.com/support/installer/bin/answer.py?answer=100386
As many have noted, recent Google software releases for OS X now include Google Software Update, a background daemon that checks for and installs updates to Google software with no user intervention and no option for disabling it.
In theory, GSU is removed automatically when the last Google software to utilise it is uninstalled from your computer… but this assumes that you use the uninstallers bundled by Google, and don’t attempt to remove the software by hand.
I’ll save my disappointment for another editorial.
Instead, here is a workaround:
sudo rm /Library/LaunchAgents/com.google.keystone.agent.plist
sudo rm /Library/LaunchDaemons/com.google.keystone.daemon.plist
sudo rm /Library/LaunchDaemons/com.google.keystone.daemon4.plist
sudo touch /Library/LaunchAgents/com.google.keystone.agent.plist
sudo touch /Library/LaunchDaemons/com.google.keystone.daemon.plist
sudo touch /Library/LaunchDaemons/com.google.keystone.daemon4.plist
sudo chmod 000 /Library/LaunchAgents/com.google.keystone.agent.plist
sudo chmod 000 /Library/LaunchDaemons/com.google.keystone.daemon.plist
sudo chmod 000 /Library/LaunchDaemons/com.google.keystone.daemon4.plist
This hint does not uninstall GSU – it only “disables” the launchd entries that would run GoogleSoftwareUpdateAgent.app at boot time.
We first remove each entry (sudo rm …) and create empty files (sudo touch …) in their place. We then change their POSIX permissions (sudo chmod) to deny any access to these files (000) for all accounts except root.
Creating inaccessible dummy files is important. Without them, the launchd entries can simply be replaced whenever Google software is run. But with these steps taken, no Google app can reinstall the GSU launchd entries, unless they:
- ask for your username and password (to authenticate as root),
- use different filenames, or
- create local launchd entries (~/Library/Launch[…])
This hint is easily adapted for each of these cases. You can also use this technique to remove GSU completely.
Written by David on Fri, Feb 6, 2009 at 3:31am
Filed under OS X
By default, Leopard Server disables Spotlight indexing on its system drive.
I assume that this decision was made to avoid confusion when administrators search the global catalog for system files on other machines. However, I find this to be a hassle when I need to locate a file on the server itself.
You can easily include a server’s local drives in its Spotlight index using mdutil:
sudo mdutil -i on /
The same command can be reissued with the off parameter to reverse the change.
Written by David on Thu, Dec 11, 2008 at 10:53pm
Filed under CSS, JavaScript
IE 6 famously lacks support for CSS 2.1′s max-width and max-height properties. Most solutions involve an IE 6-exclusive expression(…) with an inline conditional:
max-width: 100px;
width: expression(this.clientWidth > 102 ? "100px" : "auto");
Despite the apparent success of this technique, I’ve still found the inline conditional to be intermittently problematic. A slightly different take on the same solution has worked better for me:
max-width: 100px;
width: expression(Math.min(this.clientWidth, 100) + "px");
Shorter, and IMO, marginally more elegant… if any IE hack could bear that label.