Archive forNovember, 2003

Thanksgiving

I’ve been gallivanting around the Bay Area all week with Eyal, my best friend from high school. He’d been planning to come out to California for five or six years now, but every time we planned a trip something came up and it had to be canceled. This time we finally pulled it off.

In retrospect, we didn’t get to do all that much, but that’s perhaps more because there’s so much to see and do in the Bay Area than anything else. We wandered around Stanford’s campus, drove the 17-mile drive in and around Pebble Beach, visited the beaches at Carmel, joined friends for a delicious deep-fried turkey on Thanksgiving, walked through Muir Woods, and enjoyed the chocolate heaven of Ghirardelli Square. A great time was had by all.

Eyal’s visit gave me a perfect excuse to try out my new digital camera. Personally, I’m amazed. I’ve never before taken pictures that looked so sharp and colorful. The best part is that this is without any fiddling with the camera at all — I just point, zoom (sometimes), and click.

Here’s a quick sample:

Muir Woods

Muir Woods

Point Joe on the 17-mile drive:

Point Joe

Sunset near Pebble Beach

Sunset near Pebble Beach

The moon from Carmel (with some splotches that ought to be Photoshopped out, but I don’t really know how to do that)

The moon from Carmel

Comments (1)

Finally fixing my AirPort network

I complained a while back that my home wireless network was having problems. After a few days, I realized that the problems were due to poor channel selection and changed the channel on my graphite base station.

That helped for a little while, but not for long. The first-generation AirPort base stations don’t to automatic channel selection, so as the neighbors’ access points jumped around to other channels they started to interfere with my base station.

I figured a newer base station would work much better, so I bought an AirPort Extreme base station this week. I got the version with antenna support so if the channel selection support didn’t work I could just buy an antenna and blast a stronger signal than the neighbors. (Take that, you WiFi weaklings!)

It looks like I won’t have to declare a signal strength war after all. With the new base station set up, I’m seeing four bars on my PowerBooks for the first time since I moved here. Since they’re only about five feet away from the base station I should have had that all along, but the old base station just couldn’t do that without a lot of hand-holding. The new one works great, even though I’m not using 802.11g at all.

Comments off

Just a little bit out of the loop

It’s kind of sad that I had to rely on Dave Hyatt to find out that a new Final Fantasy game was just released. I think I might’ve randomly come across something about FFX-2 a few months ago and promptly forgot about it. Now I just have to get around to buying a PS2 so I can play it.

Comments off

Today I’ll use my Wednesday keyboard….

Wordherd’s Unicode keyboard generator for Mac OS 9 and Mac OS X looks pretty interesting. Just think of the possibilities — you could generate random keyboards, one for every day of the week, or one for every different application you use….

Comments off

WebKit, previews, and scrolling

Wolf Rentzsch complains that BBEdit 7.1’s new Preview in BBEdit feature resets the scroll position every time the text it’s previewing changes. I’ve complained a couple of times that NetNewsWire’s weblog editor’s Preview window does the same thing. I wonder if it’s just a coincidence that both applications have the same problem or if maintaining the scroll position is simply very difficult or impossible with WebKit.

Comments (2)

restFP and saveFP

I frequently see questions from people who are wondering why their code reports restFP and saveFP as undefined symbols when linking on Mac OS X. In the hopes that this’ll be picked up by Google, I’ll answer that here.

restFP and saveFP are defined in /usr/lib/libgcc.a. This is usually added to your link line by the compiler or to your project by Xcode, but sometimes it isn’t. This often happens if you directly invoke ld to link.

To fix this, add -lgcc to your link line or link against /usr/lib/libgcc.a.

If you’re curious, you can verify that restFP is defined in libgcc.a by running

	nm /usr/lib/libgcc.a | grep restFP

You’ll see a line like this in the output:

	00000050 T restFP

The T means that the symbol is defined and exported.

Comments (6)

Windows 95 meets Mac OS X

My roommate is applying to law school. She’s filled out her applications and is just about to send them in. Unfortunately, the online law school application process uses ActiveX, so it only runs on Windows. That’s forced her to fill out the applications on her ancient Thinkpad 310D, running Windows 95 at a blazingly fast 133 MHz. So far so good — albeit slow — until the time came to print the applications.

Her old printer doesn’t seem to be working correctly. I don’t have any ink cartridges for my printer. She can’t print at work or at Kinko’s because the ActiveX control for the law school applications isn’t installed on those computers and she doesn’t have permission to install it. What to do?

I vaguely remembered that Windows could print to a file. Apparently it typically spits out printer-specific files, but if you’re printing to a PostScript printer, the *.prn files that it creates are actually PostScript files. And Panther’s Preview can convert PostScript to PDF.

Windows 95 let me install an HP LaserJet 4MP PostScript printer without having one attached and without having to download drivers. I could even set it up to print straight to a file every time. Now she as she prints each application to a file, I FTP it over to my PowerBook, rename it to have a .ps extension, double-click it to open it in Preview (I could use /usr/bin/pstopdf, but I like the UI), and save it as a PDF file. When we’re done, I’ll mail her the PDF files so she can print them out either at work or at Kinko’s.

This is quite a convoluted process to get around the lack of a working printer, but it’s interesting to see how all of the technologies fit together. And, of course, it’d be a lot harder without Panther, since I’d have to download a PostScript viewer and print each of them to PDF or build my own ps2pdf. Panther just makes it easier.

Comments (1)

Testing for valid pointers

A long time ago on Apple’s carbon-development mailing list, someone asked how to test if a give pointer is valid on Mac OS X. Today, the same question came up on the xcode-users list. I answered the original question, but the answer is buried in the depths of Apple’s mailing list archives. For the benefit of future Web searchers, then, here’s my answer.

I should note that you shouldn’t be doing this in production code. All it’s really telling you is whether the address you pass is mapped into your process’ address space. An uninitialized pointer could just as easily end up in your mapped address space as not. Also, this call is not cheap. It’s less expensive than some other alternatives, but it certainly isn’t free.

#include <stdio.h>
#include <stdlib.h>
#include <mach/mach.h>

int IsPointerValid(const void *ptr) {
    kern_return_t result;
    vm_address_t address;
    vm_size_t size;
    struct vm_region_basic_info info;
    mach_msg_type_number_t count;
    mach_port_t objectName = MACH_PORT_NULL;

    address = (vm_address_t) ptr;
    count = VM_REGION_BASIC_INFO_COUNT;
    result = vm_region(mach_task_self(), &address, &size,
                       VM_REGION_BASIC_INFO, (vm_region_info_t) &info,
                       &count, &objectName);
    if (objectName != MACH_PORT_NULL) {
        mach_port_deallocate(mach_task_self(), objectName);
    }
    if (result != KERN_SUCCESS || address > (vm_address_t) ptr ||
        info.protection == VM_PROT_NONE) {
        return 0;
    }
    return 1;
}

void TestPointer(const void *ptr) {
    if (IsPointerValid(ptr)) {
        printf("%p is valid!\n", ptr);
    } else {
        printf("%p is not valid!\n", ptr);
    }
}

int main(void) {
    int foo;
    char *ch;

    TestPointer(NULL);
    TestPointer(&main);
    TestPointer((void *) 0x12345678);
    TestPointer(&foo);
    TestPointer((void *) 0xffffffff);
    ch = (char *) malloc(5);
    TestPointer(ch);
    return 0;
}

Comments (4)

New iTunes

Queen’s Bohemian Rhapsody appeared on the iTunes Music Store today. I’d been waiting for it for a while now, so I had to buy it immediately. (A version from “Live Magic” has been available for weeks, but it isn’t nearly as good as this one.)

That continues the song-buying spree I’ve been on lately. In the past week I’ve bought Sarah McLachlan’s “Mirrorball” (my first Sarah McLachlan album, and certainly not my last), Don McLean’s “The Best of Don McLean” (just for “American Pie”; I don’t really like the rest of the album), and a bunch of singles:

  • “Einstein on the Beach (For an Eggman)” by Counting Crows
  • “Spark” by Tori Amos
  • “Running on Empty”, “Stay”, and “Doctor My Eyes” by Jackson Browne

I think I felt bad about having fewer than a thousand songs in iTunes or something like that, so I’m trying to make up for it. I’m only up to 935 now, so I guess I have a lot of shopping to do.

The thing is, that’s only 4.3 GB of music. How on earth does anyone fill a 40 GB iPod? Better yet, how do they pay for that much music?

Comments (7)

mpt on security certificates

mpt takes on security certificates in a terrific rant that reads as if it was written by John Gruber, except that it wasn’t.

Comments (1)

« Previous entries