Archive for September, 2010

Speeding up Safari (Mac) by turning off its cache

WARNING: This procedure worked for me but I do not guarantee it will work for everyone. Use at your own risk.

I primarily use Apple’s Safari browser, along with Google Chrome and Opera. Chrome is almost to the point where I might be willing to switch, but right now I’m very comfortable with Safari. With one major exception: after an hour or two of heavy use (multiple tabs and windows, reloading pages, lots of script-heavy pages) the browser’s performance drops to a level that is just unacceptable, especially on a 2.4GHz Core 2 Duo MacBook Pro with 4GB RAM. Page loads are sluggish and almost every click on a page results in a beachball for a few seconds. After a bit of Googling and experimenting I narrowed the problem to the browser cache. It seems that Safari’s mechanism for searching its cache is, let’s say, suboptimal.

Unlike most other browsers, Safari provides no user-accessible preference for adjusting or disabling its cache. So I looked deeper.

  1. Close all Safari tabs and windows. Don’t exit Safari, just close all its windows.
  2. Empty Safari’s cache: Safari menu -> Empty cache
  3. Exit Safari.
  4. Open Terminal*: Applications -> Terminal or Spotlight -> “Terminal”
  5. In the Terminal window, type:
    chmod a-w Library/Caches/com.apple.Safari/Cache.db
    (the above should be all one line; hit Return or Enter at the end of the line)
  6. Type: ls -al Library/Caches/com.apple.Safari/Cache.db
    (the above should be all one line; hit Return or Enter at the end of the line)
    You should see:
    -r--r--r-- 1 [your user name] staff 26624 Sep 28 17:33 Library/Caches/com.apple.Safari/Cache.db
    The details will differ, but the important part is -r--r--r-- which is Unix for “read-only for everyone”. That means Safari can’t write to its cache file, effectively turning it off.
  7. Relaunch Safari and browse normally. If your results are like mine, you’ll note that the sluggish performance of Safari after an hour or two of heavy use is now just gone.

*Just re-emphasizing the warning at the top of this post. If you follow these instructions exactly, nothing untoward should happen. However, Terminal is the window into the deepest, darkest inner workings of Mac OS X. It’s possible to really screw things up with a simple typo. If you have any doubt, don’t do it.

Comments off

SFGate with no comments: a Greasemonkey script

After a few months (sorry!) of downtime, my SFGate-NoComments Greasemonkey script is back up at Userscripts.

I realize the previous sentence makes very little sense to anyone but me, so I’ll expand it:

After a few months (sorry!) of downtime

You saw my to-do list(s), right?

SFGate-NoComments

The “comments” sections in SFGate (San Francisco Chronicle’s Web site) articles are disgusting, horrible, rude, homophobic (?!), racist and in every other way awful. I wanted a way to read stories on SFGate without even having to force myself not to look at the comments section.

Greasemonkey script

Greasemonkey is a mechanism by which arbitrary code can be injected into Web pages during load or after they are completely loaded. It’s available for almost every modern browser*. Some common uses for Greasemonkey scripts are adjusting font sizes and colors on pages where the Web developer apparently worked on a 30″ inch screen and has 20/10 uncorrected vision and the color sense of a three year old, removing page elements and otherwise enhancing usability of Web pages.

Userscripts

Userscripts.org is an online repository of thousands of user-submitted Greasemonkey scripts. I placed my script there when I first wrote it early this year.

How does it work, you ask? Pretty simple in concept, a real hair-tearer in execution. Using Greasemonkey scripts’ ability to access the structural elements of a Web page, and knowing (from examining the page source code) how comments sections are named and placed, my code goes through the DOM looking for specific items. When it finds them, it makes them disappear. This was made more difficult by the fact that SFGate is now using a third-party comments solution which loads after most of the rest of the page has already finished loading, so I had to make my code wait until the page, including comments, had fully loaded before executing. The result is that the comments links and sections do show for a second before disappearing, but I find that acceptable considering the outcome.

This was an interesting challenge for me and as usual, it was impossible until it became easy. I would be willing to look at extending or duplicating it for other sites with similarly offensive comments sections. Let me know in the comments below if you’re interested. Yes, I realize the irony.

*Greasemonkey for:

  • Safari/Mac: Greasekit** or NinjaKit. I haven’t tried NinjaKit yet.
  • Opera: Enable user scripts and point it to the directory where you’ve downloaded your scripts.
  • Chrome: Native support, just click “Install” from Userscripts pages.
  • IE: See links here. I haven’t tried any of these because I use IE only under extreme duress.

**Use this version of GreaseKit if you are on OS X Leopard. The current posted version was compiled for Snow Leopard.

Comments off

Disappointed in @DIRECTV today

Posted here because it’s too long to Tweet and I dislike serializing Tweets.

I’ve been a DIRECTV subscriber for around twelve years. Through all that time I’ve almost always been pleased with both the actual TV service and their customer service people. There has been the occasional hiccup, as you’d expect, but overall it’s been great and I wouldn’t hesitate to strongly recommend the service. (In fact, if you’re considering it, click the “Contact Me” link on this page for a $100 referral credit.)

DIRECTV recently, some would say “finally” introduced their whole-home DVR service- essentially the same as the local share ability built in to TiVo since the beginning- and since I have two of their HD DVRs (one upstairs, one downstairs) and an ever-growing list of subscribed series, I decided to order it. Unlike TiVo networking, which is free except for customer-provided equipment, the DIRECTV service costs $3 per month plus installation. I have a very strong wireless-N network but apparently HD signals require more bandwidth so they install a hardwire network for the DVRs.

I called last Friday and had one of the single best customer service experiences in my life. The rep was friendly, knowledgable and very helpful. She got the service ordered, gave me a break on the installation charge and took care of a few other unrelated issues on my account. We scheduled the service installation to take place a week later, today, between 4 and 8 pm. All would be well and I was quite pleased.

This morning, I received a call from someone who, almost completely unintelligably, claimed to be the DIRECTV installer and said he wouldn’t be coming today because he “has no equipment.” That’s a direct quote. He’s a DIRECTV installer and he can’t make it because he “has no equipment.”

I didn’t know what to say to that so I agreed to wait for his call next week when, presumably, he’d have some equipment. Then I got on the phone to DIRECTV customer service to find out what the hell was going on. The rep could only tell me that the appointment was still scheduled and she didn’t see anything to suggest that the installer wouldn’t be there as scheduled. She said she’d have “Dispatch” call me back shortly to confirm it.

Well, “Dispatch” never called and no installer ever showed. I blocked time for this today and it was wasted. I’m surprised and disappointed.

I’ll call back tomorrow, I guess, and try to reschedule. I will insist on a different installer because I will not allow the one I talked to this morning into my house.

Updates as events warrant.

Comments (4)

If I could be any character from a book, it would be…

Who wouldn't want to be the Stainless Steel Rat?

He's a master thief, a disguise artist and a traveler of space and time. He can go anywhere, be anyone, steal anything. And he does it all within the bounds of an ironclad, if slightly bent, sense of ethics:



Life is precious – don't kill anyone.

Only steal from those who can afford it and likely will never notice.



The Stainless Steel Rat books by Harry Harrison were favorites of mine in my formative years (which probably explains a lot) and I still like to pick them up again from time to time.



N.B. I would have answered "Harry Dresden" but for the events in the latest book.

Powered by Plinky

Comments off

On data mining and consumer loyalty cards

The last time I was at Borders (buying Daemon and PHP: The Good Parts) they were running a charity promotion where you could buy a children’s book to donate to a local children’s hospital (I think). There were several books on display and I selected The Monster at the End of this Book because it’s always been special to me. I had a percent-off coupon linked to my Borders Rewards card, which I used on the PHP book. As usual, this resulted in my purchases being logged to my Borders Rewards account. All of which is normal and expected. Now for the unexpected:

Recommendations in the weekly Borders email I received today included, along with a science fiction and computer language selection…


The Poky Little Puppy.

Comments (1)