Autofocus vs. Shortcuts

Saturday, July 24th, 2010

A photograph of a street sign that reads "Short Cut"

I was reading HTML5 for Web Designers and was reminded again of the interesting debate about autofocus and keyboard shortcuts. If you’re unfamiliar, autofocus is a JavaScript technique for automatically putting the cursor in a particular form element when a user visits a web page. This happens when you visit Google: notice that you can just start typing without manually clicking in the search box first.

The concern that many people have is that autofocus impedes the use of certain keyboard shortcuts. Awhile ago on Twitter I noticed that Juriy Zaytsev (a prolific JavaScript blogger and Prototype.js core developer)  said that autofocus breaks the backspace button, which is a shortcut for back. In the aforementioned book I’m reading, the author suggests that you should think long and hard before using autofocus, since it breaks use of the space key to scroll down the page. In both cases, autofocus causes these keys to type or delete in the selected form element instead of executing the shortcut’s intended function.

It’s a shame that these prominent folks are dissuading people from using autofocus. Autofocus really is a time-saver. The real problem is bad keyboard shortcuts.

Keyboard shortcuts that are too likely to confuse the user and produce the wrong result are a bad idea. I’d argue that using backspace or spacebar as a keyboard shortcut is almost as harmful as using p or b. Keys that indicate that the user may be trying to type something should not be used as shortcuts. Unless paired with one of alt, control, option, etc.

The good news is that although there are some very common but very bad keyboard shortcuts available, you don’t have to use them. If you want to stop being bothered by autofocus, I have found that Firefox, Opera, Chrome, and Safari all support command-[ as an alternative to backspace that works even if a form element has focus. Further, fn-downarrow is a good alternatives to spacebar for scrolling down.

Start using good keyboard shortcuts! It'll keep you sane, and let web designers make use of helpful features like autofocus!

[image credit]

Note: All keyboard shortcuts tested on a Mac only. Though I assume in Windows you have similar options.

Chrome Web Store – I like it, though I may never use it.

Wednesday, May 19th, 2010

The Chrome Web Store Logo

I like the idea behind the newly-announced Chrome Web Store. It’s a store for web apps, which technically aren’t different from any other web sites like Google Docs. At first it feels like Google is just out to make a quick buck by mimicking Apple’s successful App Store. However, I think something more subtle is going on here. This is a a totally different approach to making money on the web.

Every now and then I think about making money from my side projects, but I’ve never done it. Why? Because making money on the web is called “ads”. If you’re selling t-shirts you probably don’t need ads, but if you want to make a website that’s fun or useful on its own merits, you don’t have a lot of options. Google makes 99% of its money from ads. The problem? I hate ads.

Ads pit you against your users. A user’s goal is just to use the app and have fun or perform some task. An advertiser’s goal is to get impressions. Do you hate the new ad overlays in Youtube? We all do, but Google has to pay the bills for Youtube to be free. Ever clicked a link, only to discover it wasn’t a link at all, it just triggered an irrelevant ad pop-up? They generate impressions. It’s a bait and switch, but someone is willing to pay for it, and someone has to write a check to Bob’s Discount Hosting at the end of the day.

Google has always known that people hate ads. That’s why they’ve put so much work into making ads painless. Their text ads are low-bandwidth and unobtrusive. Now and then, they can even be useful. That’s why Google is the clear leader in web advertising market share. Though now Google is asking themselves a few questions. What would the web be like without ads? And where would Google fit into such a web?

Are there websites don’t sell a more tangible product, don’t have ads, and exist only to be fun or useful? Sure. I made one, but the cost to run it is negligible. What would happen if it started generating millions of views a day, and my hosting company raised my rate? I’d need to take the site down, or find a way to make money. Inevitably, this would mean slapping ads on it. Yuck. Tons of interesting startups live in the same bubble I live in. Let’s just make a useful or fun app, and worry about money later, and only if we have to. With venture capital, you can live in this bubble for a long time. Sooner or later, though, reality sets in. Does this mean Twitter is going to have ads some day? Well, yes. They’re wrapping it up in a nice package, painfully aware of how much users hate ads, but that’s what they’re doing. That’s what you have to do.

This is why iPhone development is so appealing. You can make money without ads. Your app is just your app. I don’t understand in the least why Apple thinks creating an ad platform for iPhone apps is a good idea. They must underestimate how much people hate ads. I cringed when Steve Jobs acted genuinely excited when announcing this stuff. iPhone developers will continue to make it big when they make good software at a good price point. It’s such a better way.

As you think about all this, eventually you have to ask, why don’t web apps work like iPhone apps? Why are the choices “free” or “ads”? 37signals is pretty vocal in saying that you have to charge for your product. That works pretty well for the small-business collaboration and project management software that 37signals makes. But it doesn’t work as well the smaller the app is. On the iPhone, you can sell a nifty unit converter for $0.99. On the web? Not a chance. Google does it for free, as do countless other sites. Even if you have the best unit converter on the entire Internet that you spent weeks on developing and doing usability studies and designing gorgeous graphics for. The Internet just doesn’t sell web apps in that price range. You come across as a greedy jerk, even if you have a great product.

Can that be changed? Can we make it so that nifty bite-size web apps can be sold for a buck or two? How do you change it? Well, here are my guesses as to what you’d have to change:

  • Safer and faster payment system. People hate putting in credit card information on some unknown website. They’d rather just pass than take the risk for a small app that isn’t such a big deal after all.
  • Sense of ownership. A Tetris bookmark on a toolbar doesn’t feel like a product. It feels the same as all the free Tetris apps out there.
  • Pay once. Periodic billing doesn’t make sense for small apps. What is the periodic equivalent of a $0.99? $0.05 / month? It’s silly. But still, not a lot of webapps work on a pay-once system. Why not? Well, at that price point, wouldn’t it be easier to just throw some ads on there? A pay-once model for apps should be simpler to set up.

I think the Chrome Web Store is an attempt to fix these problems. You buy apps quickly and safely through Google, you get a nifty apps tray in Chrome that makes it feel like you actually own something tangible, and you only pay once.

Screen shot of Chrome's upcoming apps tray

I don’t think that the Chrome Web Store is the future of web application development. On the other hand, I do think Google’s efforts will make it more acceptable to make money by selling your web apps instead of by tacking on ads. Once people get used to the idea of buying access to a tic-tac-toe website, web developers will have an easier time selling such apps outside of Google’s ecosystem. And that’s great.

It makes me wonder what Google’s perspective is on this. They’re an ad empire, and here is their product supporting a different revenue model. Are they worried about what the web would be like without ads, or even, without Google? Would Google start charging for their own apps if things went this direction? You have to evolve to survive on the web, and maybe even Google needs a plan for survival.

I’m currently developing a game using HTML5 technologies. I always knew I’d never put ads on it, so I assumed it’d just always be free. Though now I have to wonder. Can I sell it for a buck? It’s starting to look like it might be an interesting experiment.

Uploading Large Files in Ruby on Rails

Thursday, May 6th, 2010

File upload is a common feature for web sites, yet for some reason a lot of frameworks make it hard on you. JSF doesn’t even support it by default; it requires the installation of additional libraries.

In Ruby on Rails it worked pretty well out of the box, but with a catch. File uploads are stored in memory, so if you are letting users upload large files, the server will quickly run out of memory.

To solve this I discovered a new (as of 2.3) component of Rails called Metal. Metal is a thin wrapper around Rack, a minimal piece of middleware that handles HTTP requests for Rails. While Metal is a part of Rails, it lets you bypass Rails for the most part, and work at a lower level for those performance-critical bits. Happily, Metal lets you grab an uploaded file without making a copy of it in memory.

Here is an example of a Metal class that does file upload. To test this you’d just need to throw it in a /app/metal directory for your Rails project, then navigate to http://example.com/uploadtest to try it out.

 
class Uploadtest

  def self.call(env)

    if env["PATH_INFO"] =~ /^\/uploadtest$/

      request = Rack::Request.new(env)

      # Get temp file from request
      # Format: {:filename, :type, :name, :tempfile, :head}
      file = request.POST["file"] 

      # Make sure we have the parameter
      if !file.nil?

        # Create new file path
        directory = File.join("uploads", "uploadtest")
        FileUtils.mkpath(directory)
        path = File.join(directory, file[:filename])

        # Copy the uploaded file
        FileUtils.cp file[:tempfile].path, path

        # Response
        [200, {"Content-Type" => "text/html"}, ["Upload Complete"]]

      else
        # Show an example submission form
        [200, {"Content-Type" => "text/html"},
              ['<form method="post"
                      action="/uploadtest"
                      enctype="multipart/form-data">
                <input type="file" name="file"/>
                <input type="submit" value="Upload"/>
                </form>']]
      end
    else
      [404, {"Content-Type" => "text/html"}, ["Not Found"]]
    end
  end
end

I hope this helps someone who runs into the same situation I was in!

Eating Alone

Tuesday, April 27th, 2010

Photo of a Reuben sandwich

Have you ever been to a restaurant by yourself? Taco Bell doesn’t count. Somebody asked you “How many people in your party?” and you said “One.”

Let’s say I’m walking home from work and I want a hot tasty Reuben. I can go to the grocery store, buy the ingredients, assemble the sandwich, heat up the griddle, and make it myself. But why should I? There are probably at least 10 places I walk past on my way home from work that serve this sandwich. I’ve decided to have dinner out.

But alas, I’m alone. I could call a few friends and see who is up for dinner, but I’m too hungry to wait, and quite frankly, maybe I just want to stare into space and daydream while I eat. I do it all day at work, why mess with success?

Given that I’m on my own, there are only a few types of places where I can go.

Go casual

If an eatery is sufficiently casual then eating alone there may not be a faux pas. How much the casual venue affects your ability to enjoy the meal depends on what you’re after. My bases are covered if I want a deli sandwich or a Double Quarter Pounder with cheese. If I want rare filet mignon with seared asparagus and Gorgonzola mashed potatoes, this option won’t help me.

At the bar

Due to the stigma surrounding drinking alone, you have to be careful here. It’s hard to explain exactly when this is acceptable. There are some bars that just feel more comfortable for eating by yourself. The staff may or may not be amenable to your behavior. If the bar is empty, you just look depressing. If the bar is full, you’re getting in the way when people are trying to order another round of Michelob Ultras. Sometimes when I intend to eat by myself I’ll walk past a few bars to try to find one where I feel like I’d be comfortable.

Takeout

I’ve found that you can get takeout from pretty much anywhere. Delivery is a major service for a venue to offer, but pick-up doesn’t inconvenience most venues in any way, so they seem happy to oblige. Though readily accessible, this option has more downs than ups. Your food may be cold by the time you get around to eating it, you won’t get to enjoy the restaurant’s ambiance, and it’s difficult to time the pickup.

OK, so there are options. But why the rigmarole? Why is it socially unacceptable to go to dinner by yourself? I guess I can see a few possibilities…

The Venues

Maybe guests by their lonesome just aren’t lucrative enough. A duo can split an appetizer and a bottle of wine, but a single guest is generally limited to a single drink and entrée. Then again, are solo eaters really discouraged by the venues proper? I haven’t tried to go to a fancy restaurant by myself. What would happen?

Personal Appearance

Maybe people are just self-conscious about being alone. Restaurants are a place for people to go and enjoy themselves. What is better than enjoying a nice hot meal and a few drinks with some friends? Why wouldn’t you bring a few buddies? That person at the table alone, playing Scrabble against the computer on their iPhone, what’s their problem? No friends? Are they so obnoxious/ridden with body odor that they… have no friends?

In any case, let’s fix this. Go to a restaurant by yourself. Order the duckling à l’orange and a stiff martini and treat yourself right. If we all do it, it’s no longer socially unacceptable. So, folks: get on it.

[image credit]

April Link Dump

Monday, April 12th, 2010

Some delicious oysters

Fun / Interesting

It’s OK for vegans to eat oysters. I really respect this pragmatic approach to ethics. Plus, oysters are damned delicious.

Harmony drawing tool. Great way to spend a few minutes when you need to get the creative juices flowing.

Vodka is often disregarded as “neutral” or “flavorless” but I’ve found that vodkas vary more than I once thought. This is one of the few treatises I’ve found on the subject.

Art

A neat street art series by “Ludo” called Nature’s Revenge.

The Impossible Cool. Simple, classic, black-and-white photos of famous actors, authors, and so on.

Gorilla Artfare is a great art blog, backed by a very creative (closed-doored) community.

InterfaceLIFT lets you view wallpapers for a given screen resolution. I really wish other sites where I get wallpaper, such as Deviantart, would do this.

Notcot is an interesting art / design blog. Their thumbnail-centric format is something that would sound like an awful idea if you described to me, but they pull it off.

Technology

A screen shot of the Remember the Milk iPhone app

Remember the Milk. A comprehensive to-do list organizational tool. It’s $25/year, but their iPhone app is really nice. I appreciate touches like being able to choose what the app badge represents (total due items, or items due today).

Feature checklists suck. Glad someone took the time to properly bash them so I don’t have to.

I always have trouble finding good starting point themes for blog designs. I think I’ll try out Thematic for my next WordPress project.

A presentation about Netflix’s corporate policies and culture. As surprising as it is inspiring. For example, they did away with vacation day policies, and just let people just take days off at will.

[image credit]

About | Other Stuff