Archive for 2007

1 TB

Tuesday, October 16th, 2007

I recently started running MythTV on a Linux box I have sitting in my basement. This machine also acts as a home file, web, and print server, and it had a couple of internal hard drives in it already, plus an external USB drive for backup. MythTV soon ate up all the available space on my /home partition, so I went shopping for another drive to use for dedicated video storage. It’s amazing how cheap hard drives have become: I ended up getting a 500GB drive (which seems to be the current sweet spot for bytes-per-dollar) for $100 plus tax. After installing and formatting it, I took a look at the available disks in my system, and suddenly realized how much total storage there was:

$ df -H -t ext3
Filesystem             Size   Used  Avail Use% Mounted on
/dev/hda1               28G   4.3G    23G  16% /
/dev/hda2              216G   142G    63G  70% /home
/dev/sda1              316G   143G   158G  48% /mnt/bigboy
/dev/hdc1              493G   115G   353G  25% /mnt/video

That’s just about a terabyte! A few years ago I would never have imagined setting up a machine for personal use with a terabyte of storage. And now I have one, almost accidentally. Amazing.

View Source for Safari on iPhone

Monday, July 2nd, 2007

A lot of web development knowledge has been gleaned by viewing source. Unfortunately the iPhone’s version of Safari doesn’t have a View Source command. So if you visit a site on the iPhone, and find that they’re serving you up a different, iPhone-optimized version of the site, there’s no easy way to look at the source and see what they’re doing.

To work around this problem, I made myself a little View Source bookmarklet that works on the iPhone. Here it is:

View Source

To use, add the above bookmarklet to your Safari or IE bookmarks, and sync your iPhone. Then visit a web page on your iPhone, pull up your bookmarks and select “View Source”. A new page will open containing the source of the page you were viewing.

Unlike the traditional View Source command, this bookmarklet shows the generated source, not the original source. if the DOM has been modified by script you’ll see the modified version and not the original. Also, you’ll probably have to do lots of zooming and panning, since the lines of source code will be wide. If anybody wants to make a version that has nicer formatting, feel free to expand this code.

Here’s the original un-escaped javascript:

var sourceWindow = window.open('about:blank');
var newDoc = sourceWindow.document;
newDoc.open();
newDoc.write('<html><head>' +
    '<title>Source of ' + document.location.href + '</title>' +
    '</head><body></body></html>');
newDoc.close();
var pre = newDoc.body.appendChild(newDoc.createElement("pre"));
pre.appendChild(newDoc.createTextNode(
    document.documentElement.innerHTML));

A few iPhone Safari notes

Friday, June 29th, 2007

Some notes on Safari on the iPhone, from the perspective of a web developer: 

  • Poking around the DOM, I don’t see any special objects, with the possible exception of window.offscreenBuffering (set to true).
  • Bookmarklets work, although you have to go through the bookmarks menu to get to them.
  • The javascript shell bookmarklet is tantalizingly close to working, but doesn’t actually evaluate what you’ve entered when you hit enter – it just goes to a newline. This is probably easy to fix.
  • Update: the problem appears to be the fact that you only get an onkeypress event after you hit enter on the virtual keyboard, and even then the keyCode is equal to 0. I tried modifying the script to execute whenever keyCode is 0, but that made Safari crash! Does that make me the first civilian to crash Safari?
  • Safari crashes are handled gracefully – the main screen fades back in, and you can jump right back into Safari. It will then load page you were visiting when it crashed.
  • Drag and drop, and other behaviors based on picking up mousemove events, don’t work. CSS-based element drag and drop doesn’t work either. Dragging one finger around the iPhone’s version of Safari causes the window to scroll, and that’s it. I assume that scroll events do work. I’m sure somebody is already working on a version of drag and drop based on window scrolling.
  • For documents with no width set, the iPhone uses a default width of 980px.
  • alert() works.

I’ll post more things as I discover them, or feel free to add your own in the comments.

iPhone error correction really works

Friday, June 29th, 2007

A useful OS X command: pbcopy

Monday, June 25th, 2007

Today I learned about the pbcopy command in OS X. It lets you copy text to your clipboard from the command line. This means you can (among other things) copy the contents of a file on a remote server into your clipboard, ready for pasting:

ssh myserver -x "cat myfile" | pbcopy

Believe it or not, this actually came in very handy for a debugging task I was working on. There’s also a pbpaste command, which prints the current clipboard contents to stdout.

Multitasking

Monday, May 21st, 2007

Today I was catching up on my RSS feeds in Google Reader when iTunes started playing a song I didn’t feel like hearing. Without taking my eyes off the article I was reading, I typed Cmd-Space-n-e-x-t-Enter (Pull up Quicksilver, run “Next Song” script). I think that’s the first time I’ve done that without looking, and that seems significant.

Yes, there’s no such thing as true multitasking. But this makes me think that good software can dramatically reduce the overhead of switching tasks. When I run a task through Quicksilver, it preserves my foreground window, and keeps my hands on the keyboard. If I’ve memorized the command I want to run, I don’t even have to move my eyes to the Quicksilver dialog. Just think, type, go. And then continue what I was doing.

My one Apple phone prediction

Tuesday, January 9th, 2007

With Steve Jobs’ MWSF keynote speech just minutes away, I’m going to offer one prediction about the rumored Apple phone: Like the iPod, it will be PC-centric (and by PC, I mean “Mac or PC”). While a true mobile phone, it will also be designed to connect to your computer when you’re at home. You won’t be able to take full advantage of the phone without a computer running Apple software.

The iPod depends on iTunes, and iTunes lets you perform the more complicated tasks of buying, and organizing your music using the more powerful interfaces available on a PC. Moving more of the complexity onto the PC is what allows the iPod itself to be so simple, and appear so powerful despite having limited computational power. I think we’ll see something similar with the Apple phone – your computer will control the data on your phone. Syncing your music, photos, etc. will be almost transparent, easier then it’s ever been before. Unlike the iPod, though, the flow of information will be two-way. You’ll be able to take your songs and photos with you when you leave your computer, but you’ll also be able to record information – names, addresses, pictures – when you’re out and about, and have it all collected back onto your computer when you get home.

That’s how I imagine it, anyway.

Update: Well, the iPhone is pretty amazing, and much more powerful than I would have thought possible. So forget what I said about moving complexity to the PC. I still think there will be some slick two-way synching, though.