drew

Words on your display.

Serving a large file through PHP without hitting memory_limit

without comments

Ran into a little problem hitting the memory limit for PHP when serving 100MB+ files through a script like:

$file = @fopen($filename,"r");

if ($file)
{
while(!feof($file))
{
    print(fread($file, 1024*4));
    flush();
    ob_flush();
}
@fclose($file);
}

Found that you need to call ob_flush() as well as flush() since flush() has no effect on the buffering scheme of your web server.

Just thought I’d throw that out there for anyone else.

Written by Drew

September 10th, 2008 at 11:44 pm

MultiTouch Trackpad Gestures For The Rest Of Your Apps

without comments

If you’re one of the lucky ones to be able to get one of the latest MacBooks with Multi-Touch, you’ve probably asked the same question I have: “How can I get Firefox to use the swipe gesture to go forwards and backwards like Safari does?”

Answer: MultiClutch

This neat little Preference Pane addition will allow you to associate trackpad gestures with keyboard shortcuts; per application.

So this gives you exactly what you’re looking for: navigation for Firefox 3 (beta) via trackpad gestures. Only apps built with Cocoa are supported right now, so this won’t work with Firefox 2, sorry!

If you found that app useful, please consider making a small donation to Will! It helps make the world go round. =)

Written by Drew

April 12th, 2008 at 2:28 pm

Cycle Your Batteries!

without comments

MacBook Battery UsageWhen buying portable products, I usually like to be (over) prepared for whatever situation may arrive.  When I bought my Panasonic HD camcorder, I also searched the web thoroughly and bought two extra batteries and a 16GB SD Card.  Plenty of power and plenty of space.

So I found myself looking at an extra battery for my recent MacBook Pro purchase so that I’m never caught dead.  As I do before buying anything electronic over $50 I started reading the reviews, which all seemed to be horrible, dating back to 2005 even.  I was a little confused since I went the entire weekend without having to charge my MacBook Pro, and even found myself on Sunday night waiting for the battery to die before I went to bed so I could give it a full cycle.

MacBook Battery HistoryObviously I didn’t use my notebook more than 5 hours (the rated time it can/should last).  I didn’t do any work this weekend (that’s a first really), so nothing more than looking up movie times, checking bank statements and researching some thing (ok, so maybe I did a little work)… but battery life was more than adequate. So I didn’t quite understand all these reviews; especially some claiming “my battery doesn’t last more than 10 minutes!”.

For any MacBook user, you’ll find a wonderfully cool program called CoconutBattery that tells you the actual and rated battery capacity at any time. (Just don’t leave the application open, I found that it locks up my entire system after prolonged use.) So armed with that, and with Apple’s battery notebook care, you’ll have everything you need to help get the most out of your battery.

As you can see from my battery history, as I started to completely drain my battery (2008-04-04), my battery’s maximum capacity increased. April 06 was when I completely drained and charged the battery for the first time.  I’m willing to bet that many (the “average”?) user doesn’t know or understand how batteries work. They understand (and I remember thinking in my teenage years) that batteries fill up and drain; there’s nothing else to them.

And who knew you could calibrate your battery to ensure an accurate reading?

This is also great advice for anyone using anything that has a battery.  Batteries need to be used to be kept healthy.  Windows users can use tools like BatteryMon (30-day trial, $24) to get battery capacity monitoring and recording.

iPhone users should take this advice to heart also, especially since replacing the iPhone battery is only free within your first year of purchase under the warranty; and that’s only if the battery is holding less than 50% of what it should. Otherwise you’re looking at almost $90 and a week or two without your phone.

In short, use your batteries!

Written by Drew

April 7th, 2008 at 10:49 am

Getting Organized with Spaces

with 3 comments

Spaces ImageUpon getting my Mac, Spaces was one of the first things I checked out. I had tried Virtual Desktops in Windows and Linux, but never found them to be too terribly helpful. Not to mention I used a dual monitor setup with my Windows machine, so I felt I had plenty of room for things.

Despite having a nice big 24″ screen, I have often felt my desktop to be cramped and cluttered; especially coming from a dual monitor setup. So the idea of Spaces seemed perfect, except using the keyboard shortcuts felt too slow and like to much work just to get to another application or space. (F8 + Click on a space OR Cmd + Arrow) So this tip from Mac Os X Hints sounded like the perfect solution. Although they don’t actually offer a tip on how to do it (just the tip to do it), this is what I’ve done:

1. Assign Spaces to use the Cmd + Arrow keys too switch between Spaces.
2. Use SteerMouse to assign the right and left mouse scroller to use those combinations (Cmd + Right Arrow) (Cmd + Left Arrow)
3. There is no three!

I’m using 6 spaces now, for web browsing, coding, FTP, RSS Feeds, iChat and iTunes.

Any other suggestions on a good/better way to do the key assigning let me know!

Written by Drew

March 2nd, 2008 at 5:35 pm

Posted in Hardware, Mac

Tagged with , , , ,

My Mac crashed on me, and I lived to tell about it.

with 2 comments

I’ve been a Mac user now for 24 days; and I’m loving it. I’ve been anxious to write several blog posts about the highlights of my experience in switching to a Mac + PC workstation. I have several stickies on my desktop with notes about what to include in these blog posts; and to be sure I’ll still write them.

But my experience just 15 minutes ago with my brand new 24″ iMac scared me like my Windows machine has never done before; and has prompted (or incited) me to be active on this blog.

I’m really getting the hang of the Mac OSX system. I’ve already purchased Coda for a development environment and I have lots of things going on at once when I’m developing. This is about the time when a kernel panic decided to happen. I’ve read about it before. The Mac equivalent of the famous Windows blue screen of death. But I have now experienced it first hand. Some people even think this is a good joke (and it is).

It happened when I had clicked on a link in my browser, so I figured perhaps some javascript had really done Firefox wrong and in turn messed everything else up. So per the on screen instructions, I held the power button down to reboot. I was greeted with 2 low beeps, followed by 3 beeps (repeated). Not cool. I was initially a bit upset (read: mad)… this is not supposed to happen. This is a Mac, right? I thought it’s just supposed to work.

I ran through standard problems: overheating (it does get hot), bad hard drive, bad motherboard. Unfortunately, it turns out the beeps meant bad RAM. I have switched over just about everything to my Mac (except e-mail), and I don’t have a backup Mac (yet) in case something like this happens. Lucky for me, I had bought 4GB of RAM to be used as a Christmas gift for my dad for his Mac. And lucky for me, the RAM is just about the only accessible thing on the iMac.

Sure enough, popped the 1GB stick out and put the new one in and it’s up and running again. Not cool Apple. Is this really the type of RAM you charge $700 for a 4GB upgrade? (No, I didn’t buy my 4GB from Apple). Could just be a fluke though, I’ll give them that. =) But it is frustrating… what if I didn’t happen to have that 4GB of RAM sitting around for Christmas? I would be dead in the water until I took it to an Apple service center or went and just bought (read: spent more money) for RAM.

Written by Drew

December 7th, 2007 at 3:10 am

Posted in Mac

Tagged with , , ,