How To Type Curly Quotes In Mac OS X
Mac OS X has an easy way to type “curly” quotes and apostrophes instead of "straight" versions. I used both versions in that sentence to show the difference. Here is a bigger version to make the distinction more visible:
Many people think “curly” quotes look better than "straight" ones.
You can use the following keyboard shortcuts to type a single or double curly quote:
- Single quote open (‘) — option ]
- Single quote close (’) — shift option ]
- Double quote open (“) — option [
- Double quote close (”) — shift option [
However, I think it makes more sense to use [ and ] for open and close versions instead of the shift key. I found myself constant typing “mismatched‘ quotes. I also wanted to use the shift key for double quotes since that’s how the normal keyboard button works.
- Single quote open (‘) — option [
- Single quote close (’) — option ]
- Double quote open (“) — option shift [
- Double quote close (”) — option shift ]
Since OS X supports custom key bindings, I looked for a way to fix this. The trick is to create a file called DefaultKeyBinding.dict in the KeyBindings folder inside your Library folder. You can use this file to override the default key bindings for most applications.
Here are my changes. Please feel free to copy the settings below and save them to your own computer. You may need to create the KeyBindings folder if it isn’t already there.
/*
Updates Apple's default keybindings for curly quotes.
See http://www.danandcheryl.com/1072
Save this file here:
/Users/<name>/Library/KeyBindings/DefaultKeyBinding.dict
*/
{
"~[" = ("insertText:", "‘");
"~]" = ("insertText:", "’");
"~{" = ("insertText:", "“");
"~}" = ("insertText:", "”");
}
Someone Cool Wants To Buy My Car
On my way to work today, while waiting at a stop light, a guy in the car next to me leaned out of his window, smiled and signaled that he wanted to talk. I took off my sunglasses, pulled my earphones out and rolled down my window.
“Want to sell your car?” he asked. I admit to being a little taken aback. My car isn’t for sale. He was in a van obviously owned by his employer with another guy driving. He’d seen my car and had the guts to ask a complete stranger waiting at an intersection if he wanted to sell the car he was driving.
“Sure,” I smiled. I don’t really want to sell my car. Not for market value anyway. It’s too much hassle to replace. But if he’s really interested, maybe I could get a good deal. I suppose he already knew how awesome an old Honda Civic can be.
“How much?” he wanted to know. “I have no idea,” I shrugged. He asked how many miles it had (about 200,000) and got my phone number as the light changed.
“I’ll call you,” he promised as we drove off in different directions. I guess I’ll find out. Meanwhile, I am taking a look around my life to see if there is something I want that I haven’t had the guts to ask for.
Family Pictures Summer 2010
We took the kids down to get their pictures taken recently. We ordered digital copies of the pictures this time because I’m too lazy to scan them into the computer. They turned out great.
Review: Good To Great
A few months ago, I joined a company called Imagine Learning that makes software to teach kids English. One thing I love about the company (it’s my second time working for them — yeah, long story :-) is that they choose a book each year, purchase a copy for every employee, and encourage them to read it. Last year’s book was Good To Great by Jim Collins which I was asked to read during my first few weeks on the job.
In short, the book is really good. The principles can be applied in non-work settings, to any group of people working toward a shared objective. The biggest downside is that, to be useful, those principles must be adopted by the leader of the group. The CEO of Imagine Learning is an advocate, which is one of things I like best about the company.
The principles, in the order in which they need to be applied, are:
- Leaders who are ambitious for the success of the company over themselves.
- Getting the right people into the company (and the wrong ones out) before making other decisions.
- Honest assessment of the present combined with optimism about the eventual future.
- Exclusive focus on a single idea at the intersection of passion, economics and being the best.
- Freedom and responsibility within a disciplined system.
- Selective use of technology to accelerate success.
Some excerpts should help illustrate why I like the book so much.
You must maintain unwavering faith that you can and will prevail in the end, regardless of the difficulties, AND at the same time have the discipline to confront the most brutal facts of your current reality, whatever they might be. (p13)
The purpose of compensation is not to ‘motivate’ the right behaviors from the wrong people but to get and keep the right people in the first place. (p50)
Put your best people on your biggest opportunities, not your biggest problems. (p58)
The entire management team would lay itself open to searing questions and challenges from [people] who dealt directly with customers. (p72)
Focusing solely on what you can potentially do better than any other organization is the only path to greatness. (p100)
The purpose of bureaucracy is to compensate for incompetence and lack of discipline. (p121)
Mediocrity results first and foremost from management failure, not technological failure. (p156)
If you want to build an enduring and financially successful company, I don’t know of a better place to start than Good To Great.
How to Check the System Idle Time Using Cocoa
There is sample code on the Internet for programmatically checking the system idle time using IOKit and Cocoa (see here, for example). However, most of the examples seem overly long (see Paul Graham’s Succinctness is Power). The code below works in Tiger/10.4 and later and is about as concise as I can make it while still handling errors properly.
#include <IOKit/IOKitLib.h>
/**
Returns the number of seconds the machine has been idle or -1 if an error occurs.
The code is compatible with Tiger/10.4 and later (but not iOS).
*/
int64_t SystemIdleTime(void) {
int64_t idlesecs = -1;
io_iterator_t iter = 0;
if (IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem"), &iter) == KERN_SUCCESS) {
io_registry_entry_t entry = IOIteratorNext(iter);
if (entry) {
CFMutableDictionaryRef dict = NULL;
if (IORegistryEntryCreateCFProperties(entry, &dict, kCFAllocatorDefault, 0) == KERN_SUCCESS) {
CFNumberRef obj = CFDictionaryGetValue(dict, CFSTR("HIDIdleTime"));
if (obj) {
int64_t nanoseconds = 0;
if (CFNumberGetValue(obj, kCFNumberSInt64Type, &nanoseconds)) {
idlesecs = (nanoseconds >> 30); // Divide by 10^9 to convert from nanoseconds to seconds.
}
}
CFRelease(dict);
}
IOObjectRelease(entry);
}
IOObjectRelease(iter);
}
return idlesecs;
}
I consider this code to be in the public domain. Please feel free to copy and paste.
How to Print a PDF File Using Cocoa
Mac OS X is well known for its great support for PDF files. You can create a PDF file from anything you can print. I thought that using Apple’s PDFKit framework would make it easy to program a way to print an existing PDF file. That turned out not to be the case.
Sending a file to a printer using the lp command is easy. However, this approach does not work for PDF files formatted for landscape printing. You can specify landscape orientation, but I wanted a way to detect the orientation automatically.
PDFKit has a PDFView object that has a printWithInfo:autoRotate: method. However, adding a PDFDocument to a PDFView and telling it to print doesn’t work. I eventually stumbled onto the fact that PDFDocumenthas a secret method that makes printing easy. So here is the code:
#import <Quartz/Quartz.h>
- (void)printPDF:(NSURL *)fileURL {
// Create the print settings.
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
[printInfo setTopMargin:0.0];
[printInfo setBottomMargin:0.0];
[printInfo setLeftMargin:0.0];
[printInfo setRightMargin:0.0];
[printInfo setHorizontalPagination:NSFitPagination];
[printInfo setVerticalPagination:NSFitPagination];
// Create the document reference.
PDFDocument *pdfDocument = [[[PDFDocument alloc] initWithURL:fileURL] autorelease];
// Invoke private method.
// NOTE: Use NSInvocation because one argument is a BOOL type. Alternately, you could declare the method in a category and just call it.
BOOL autoRotate = YES;
NSMethodSignature *signature = [PDFDocument instanceMethodSignatureForSelector:@selector(getPrintOperationForPrintInfo:autoRotate:)];
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];
[invocation setSelector:@selector(getPrintOperationForPrintInfo:autoRotate:)];
[invocation setArgument:&printInfo atIndex:2];
[invocation setArgument:&autoRotate atIndex:3];
[invocation invokeWithTarget:pdfDocument];
// Grab the returned print operation.
NSPrintOperation *op = nil;
[invocation getReturnValue:&op];
// Run the print operation without showing any dialogs.
[op setShowsPrintPanel:NO];
[op setShowsProgressPanel:NO];
[op runOperation];
}
I consider this code to be in the public domain. Please feel free to copy and paste.
Cold Water Shaving
After reading about shaving with cold water, I’ve tried it several times over the last few days. It’s a much better experience for me.
Shaving with cold water seems like a hardship, a practice that must be endured in Spartan living conditions. After all, it’s wet shaving doctrine that a man must always shave with hot water. It not only feels nice, it softens the beard and supposedly gives you a more comfortable shave.
But what if that advice is wrong? What if it’s actually better to shave with cold water…?
Well, according to a bunch of authors in the 19th century, cold water shaving is indeed superior to shaving with hot water.
The biggest improvements for me were:
- Much easier to cut my hair. I have a smoother shave with one pass than I was getting with two.
- Getting fewer nicks and cuts on my face.
I have to admit, I’m sold.
Family Pictures Fall 2009
A few months ago, we dragged grandma up into the mountains and took some family pictures. We took a lot of pictures, but very few seemed to turn out. Now that we’re finally finished sifting and editing, I’ve uploaded some of the best ones.
We got some really good pictures of Grandma with the grandkids.
And Cheryl always seems photogenic.
The Cheerios Sugar Factor
Like many people, I often eat cereal for breakfast. When my wife went on a no-sugar diet a while back, it wreaked havoc on our cereal eating habit because, you see, most breakfast cereals are stuffed with sugar or high fructose corn syrup.
Reading the nutrition labels, however, taught me something interesting: Cheerios has by far the lowest sugar content of any cereal we eat. While shopping, I found myself in disbelief, telling random people in the super market, “Do you know this stuff has twelve times as much sugar as Cheerios?” I started calling it the Cheerios Factor.
To give you an idea, here is a list of some breakfast cereals and their sugar content. Full nutrition information is available online from General Mills, Kellog’s and Quaker. However, Post prefers to summarize it for you.
| Cereal | Serving Size | Sugar | Factor |
|---|---|---|---|
| Apple Jacks | 28g | 12g | 12.0x |
| Froot Loops | 29g | 12g | 11.6x |
| Lucky Charms | 27g | 11g | 11.4x |
| Frosted Flakes | 30g | 11g | 10.3x |
| Golden Grahms | 31g | 11g | 9.9x |
| Cinnamon Toast Crunch | 31g | 10g | 9.0x |
| Honey Nut Cheerios | 28g | 9g | 9.0x |
| Raisin Bran | 59g | 19g | 9.0x |
| Cinnamon Life | 32g | 8g | 7.0x |
| Honey Bunches of Oats | 30g | 7g | 6.5x |
| Multigrain Cheerios | 27g | 6g | 6.2x |
| Frosted Mini Wheats | 51g | 10g | 5.5x |
| Life | 32g | 6g | 5.3x |
| Total | 30g | 5g | 4.7x |
| Wheaties | 27g | 4g | 4.1x |
| Special K | 31g | 4g | 3.6x |
| Rice Krispies | 33g | 4g | 3.4x |
| Corn Flakes | 28g | 3g | 3.0x |
| Kix | 30g | 3g | 2.8x |
| Corn Chex | 31g | 3g | 2.7x |
| Rice Chex | 27g | 2g | 2.1x |
| Grape-Nuts | 58g | 4g | 1.9x |
| Cheerios | 28g | 1g | 1.0x |
| Fiber One | 30g | 0g | None |
Yes, Cheerios has half the sugar of Grape-Nuts. The only cereal I’ve found that beats Cheerios at its own game is Fiber One, which I’ve never actually eaten.
There’s No Progress Like Personal Progress
My wife works with the young women in our church and is helping with the New Beginnings program this year. During one of the planning meetings, someone suggested singing a song with custom lyrics to a popular tune. Cheryl is good at that sort of thing and immediately piped up with “There’s No Progress Like Personal Progress.” The others liked the idea and asked her to come up with something.
So she wrote some lyrics.
And sang them.
Then asked me to mix it with the music from the original Broadway show.
And here is the finished version:
There’s no progress like personal progress
To help your testimony grow
Getting your medallion is so thrilling
There is so much more for you in store
If you just keep your feet a-moving
Then you are proving that you are more
Than before
There’s no people like you people
There’s no people I know
Setting goals will help you and you will go far
It doesn’t matter where you are
This is your movie and you’re the star
Let’s get on with our goals
Let’s get on with our goals
They are planning to perform the song for the girls during the program. Should be fun. :)
We’ve places the lyrics into the public domain. Please feel free to use them.
UPDATE: Here is a video of the leaders performing. Cheryl was disappointed she was out of town and couldn’t be there.











