Safari 3.1

Eric Hodel | Tue, 18 Mar 2008 21:08:26 GMT

Safari 3.1 fixed a bug I found with urlbar-less tab reloading and removed the Debug menu, with the important bits split off into the Developer menu. To get the Debug menu from Safari 3.x and earlier, set the IncludeInternalDebugMenu pref via the command line. (I don’t think you’ll need it, though.)

The new Network Timeline is pretty sweet, hit opt-cmd-n to bring it up. Click on the file name to view the file, click on the rest of the line to see the request and response headers.

Posted in  | no comments

OS X 10.4.7 and /usr/bin/ruby

Eric Hodel | Wed, 28 Jun 2006 16:37:36 GMT

Beware! OS X 10.4.7 reinstalls /usr/bin/ruby, so depending upon how you’ve replaced Apple’s install of ruby you may start running 1.8.2 unexpectedly!

By the way, if you’re running a hand-built ruby on OS X, build with -O instead of -O2, you won’t get that annoying undefined method for Fixnum exception.

Posted in ,  | 2 comments

Finder Automator Plug-ins

Eric Hodel | Thu, 30 Mar 2006 22:41:46 GMT

Apple’s Automator allows you to perform drag and drop scripting for OS X applications. So far I’ve only written two Automator workflows, one that loads selected photos into iPhoto I call “Import Photos” and one script that attaches selected files to a new email I call “Mail Selection”.

For the Import Photos workflow grab the “Get Selected Finder Items” action then drop the “Import Photos into iPhoto” action below it. I add my photos to Library. Then select Save As Plug-in from the File menu and it will show up in the Automator item of Finder’s context menu.

The attach as email workflow is practically identical, it consists of “Get Selected Finder Items” followed by “New Mail Message”. Selecting “Mail Selection” from Finder gives me a new mail message with whatever items I had selected attached.

Posted in ,  | 1 comment

Fast memcached on OS X

Eric Hodel | Fri, 03 Mar 2006 00:39:00 GMT

For those of you experiencing a painfully slow memcached on OS X, Noah M. Daniels wrote up instructions on making memcached fast for OS X:

Two simple changes:

First, in memcached.c (in the memcached source directory) add (anywhere above line 105, which reads #ifdef TCP_NOPUSH) the line:

#undef TCP_NOPUSH

I just added it on the line above the #ifdef line.

Rebuild memcached (just do a make && sudo make install, don’t need to re-run configure if you’ve already done it)

then, set the environment variable EVENT_NOKQUEUE to 1

in csh and derivatives: setenv EVENT_NOKQUEUE 1

in sh and derivatives (like bash): export EVENT_NOKQUEUE=1

then start memcached, and it should be fast (it certainly made a difference here)

Posted in ,

Undefined method for Symbol on OS X

Eric Hodel | Mon, 20 Feb 2006 02:02:00 GMT

For the past few months people have been getting messages looking like undefined method `push’ for :compact!:Symbol (NoMethodError) when using DRb on OS X.

Eventually a simpler example of the problem showed up and in [ruby-core:7305] Mauricio Fernandez thought it could be either OS X’s malloc() alignment or the address at which malloc() first returns memory.

Today I decided to figure out what the real problem was. Apple’s documentation showed that malloc() gives you regions of memory aligned on 16 byte boundaries removing the possibility of an alignment problem.

That left only the second possibility, that malloc() on OS X returns memory lower than on most *NIX platforms.

It turns out that low addresses returned by OS X’s malloc() is the culprit. In Ruby a Symbol’s ID is mapped onto a VALUE in memory by sym = ID << 8 | 0x0e so a Symbol’s object_id ends up being a low address, typically outside the range of valid VALUEs.

On FreeBSD it takes many Symbols for a Symbol to overlap a real VALUE since malloc() first returns addresses up around 0×400000. OS X, however, returns addresses around 0xd0000 so it is already overlapping the built-in set of symbols:

p :x.object_id.to_s(16)
p Object.new.object_id.to_s(16)

On OS X:

<samp>"26e90e" 
"e7bce"</samp>

The object_id of a newly created objects is already less than the first newly created Symbol. (New objects will first decrease in object_id, then jump up when the next Ruby heap section is allocated.)

On FreeBSD:

<samp>"26910e" 
"403b536"</samp>

Here the first object is well above the first Symbol, so we won’t have to worry about anything until we’ve generated a lot of Symbols.

The full example is in [ruby-core:7401].

Posted in ,

Array#pack vs Tiger defeats ruby-growl

Eric Hodel | Tue, 15 Nov 2005 05:53:00 GMT

Tiger’s Ruby thinks its running on an x86, so I had to release ruby-growl 1.0.1.

The meat of the change was

pack_format.gsub!(/n/, 'v') if BROKEN_PACK
where
BROKEN_PACK = [1].pack("n") != "\000\001"

Thanks to Aslak Hellesoy for bringing this up, I’ve been running my own Ruby and only using ruby-growl from a FreeBSD box so never would have known it was broken.

Posted in ,