Monthly Archive for August, 2009

How to get the Tata indicom aircard/CDMA modem working in OS X

No need to use Windows! Plug the thing into your Mac — if you have HardwareGrowler it’ll tell you that you just plugged in an EpiValley USB Modem. Go to System Preferences, then to Network Connections. It should tell you that you just plugged in a new device and that when you’re ready you should hit Apply then Connect to make it go. Make a couple of changes first.

  1. Set your phone number to #777.
  2. Set your account name to internet.
  3. Set your password to internet.
  4. Go into Advanced and change your vendor to Generic and your model to Dialup Device.
  5. ???
  6. Profit.

These instruction work for my Tata Indicom Plug2Surf Whiz CDMA 1x USB Modem, but should be valid for most modems. Enjoy.

jQuery plugin: Awesomecomplete

L'Autocomplete

So I stayed up until 4am writing what I think is a pretty awesome jQuery plugin for doing autocomplete.

Edit 08/21: I changed the name from L’Autocomplete to Awesomecomplete on Sunil Garg‘s suggestion. Updated urls and code as appropriate, but this article remains as-is.

L’Autocomplete?

It’s what you get when I write a plugin at 4am. The L is supposed to stand for lightweight, which was one of the key design philosophies in terms of plugin responsibility. You’ll see. I think.

The apostrophe is there as a clever play on words to make it French: “The Autocomplete.” Well, clever for 4am, anyway.

Why bother?

The problem with most jQuery autocomplete plugins is pretty simple: they suck. My hope is that mine does not, but only time (and all of you!) will tell. While writing my plugin, though, I came to understand why this was the case: it’s rather difficult to write a flexible, customizable autocomplete plugin without ending up with somewhat of a shell of a plugin. After all, let us consider the critical components of implementing autocomplete:

  • Data retrieval. Where does my data come from? How do I format my request to the server and interpret what comes back?
  • Data format. What field am I searching against?
  • Data render. How do I display my list of options? What if I want to render a picture in the list? When the user selects a value, what data should I end up with?
  • Keyboard/mouse navigation. Wiring things up.

Apart from the last item — which, trust me, is the easiest part of the whole thing thanks to the magic of jQuery — everything else on that list is extremely contextual to the development environment. So how do you write a plugin where 80% of the potential code is hardly reusable? Some plugins take the end-all, be-all approach to this problem — account for all scenarios. I take the opposite.

As far as data retrieval is concerned, for instance, I leave that as an exercise to the developer. You give me a function to call when I need data from you, since you know how to get it. If your application has been written solidly, it’ll probably be a one-liner. I’ll give you a function to call back to when you get that data, and then we can continue on our merry. Of course, L’Autocomplete also supports loading in a prefetched cache of data — it’s actually the most useful in that case where it can see all available data at once, as you’ll see.

So what makes this particular plugin cool?

We’ve dealt with the data retrieval problem listed above in what I think is a lightweight and elegant fashion. You do it. The data rendering problem is really rather simple — I tell you all the relevant information about what you need to render, and you can give me a function that will do it. There are defaults that should actually work for 90% of you, though.

What makes the plugin cool, I think, is the solution to the data format problem. The obvious solution, since I’m making you do all this work of getting the data anyway, is to expect it in some kind of format — a list of strings, a list of key-value pairs, etc. I think this is a bad solution.

JavaScript is a dynamically typed language that’s trivially easy to reflect against. Why should I care what you give me? Just give me a list of whatever JavaScript model objects you use. You can specify the name of the “primary field” that will always be displayed (eg the name of a person), but the plugin will automatically parse every field in the object (you can of course tell it to skip fields you want left alone) for the search phrase, highlighting them if desired and telling you what field the best match was.

So, it’s an autocomplete plugin that works against multiple fields, with a pretty powerful and flexible search algorithm. There’s not much more to say about the design philosophy behind it, so onward!

Demo!

Go here for a demo running with some statically preloaded data. As a bonus to Safari and Firefox users, there are CSS3 rounded corners and drop shadows just for kicks. The data has names, emails, and phone numbers in it, so feel free to search on any of those. I should probably have included a mixed number-string field so that you can see that it’ll match any field on any item independently, but you’ll just have to take my word for it for now.

Get!

Drop by GitHub to get the code.

I’ll write some real documentation for the thing tomorrow.

Warning!

There are known issues in Safari at the moment, and the plugin is completely untested in IE, Chrome, and Opera. This is a preview release, of sorts.

I’m excited about the future of the web

Here’s what you can do today if you decide that you simply don’t care about 68% of the browser market:

Look ma, no images!

Doesn’t look like much, you say? Sure. It was just me screwing around while writing a throwaway prototype application. But what if I told you that what you’re seeing is pure HTML and CSS? There are absolutely no images involved in that entire layout. The tab even animates up and down, and the gradient fades in and out — with no images, and not a line of JavaScript.

It’s an old drum that’s being beaten to death, but this is why IE needs to either get with the game or go away. IE8 is at least a huge improvement in terms of respecting rendering standards, but with the gaping release cycle that Microsoft has IE trundling away on, they can’t possibly keep up with how quickly amazing features like these are coming along.

Just how quickly, you ask? Here’s what you can already do in the latest version of Safari/WebKit (even on the iPhone version!), with nothing but CSS, and JavaScript to push it along (source):

This has been proposed to the W3C. Everything you see is hardware-accelerated. I am stoked.

Expect a second edition of this post in a couple of days.

Review: Dollhouse Episode 13 — “Epitaph One”

The short version (since I am well aware that I tend to wax poetic): Epitaph One is not merely an incredible episode that would have beautifully wrapped up the series, it gives Dollhouse new purpose, and a reason to exist.

Let’s face it — Dollhouse has been inconsistent. From what I hear, creator Joss Whedon is notorious for slow starts, but I’m not sure that I buy that, given how collected and engaging Firefly was from the very start. I think that what both the writers and audience of the new show have found over the course of the first year is that it is at its best when the metaplot and the mythology of the show kick in. In the Blu-Ray commentary, Joss seems to push back on this as much as he can, asserting that it was important for the first five episodes to be incremental and largely standalone.

He also states with strong conviction that he is strongly against shows that end up entangled within their own mythology — the prime example being LOST. He’s not wrong — no matter how interested they may be, no one is going to dive into LOST at this point, just before the final season, and try to follow along. However, I feel that there are a number of intrinsic benefits to investing in that aspect of a show — it generates a feeling of progress in each episode, and it pays dividends when you have a rich history of tidbits to draw from and connect.

Firefly is the vindication of his point of view. The reason that the standalone episode format worked so well for it was that it was really more or less the point of the show: the chronicles of the daily lives of people in a world rather unlike ours, but not unapproachably so. It was fun to watch Firefly and compare their daily bellyaches to your own, or to imagine yourself in that world. The mundane (and I use that word in the best light possible) was very nearly a mission statement of the show.

Dollhouse can’t take that claim. Being set very much in our day-to-day world — no demons, no spaceships — it’s much more difficult to find excitement out of self-contained story arcs. Originally, though, the show wasn’t meant to be quite as action-oriented as it is. It was meant to be more contemplative, focusing on the moral aspects of the Dollhouse’s much-vaunted technology. It’s a somewhat hidden element of the show, since the A-plots tend to draw so much immediate attention to themselves, but hearing Joss’s commentary on the episode Man On the Street really brings it out and into focus, and it’s actually a rather deep concept of the show.

But that’s exactly the problem. With all of the aspects that it is trying to balance, Dollhouse tended to get lost in itself. Sure, it was great storytelling, but it was missing that draw, that cerebral aspect that the morality of the show sets up, and perhaps ultimately its most interesting component.

Epitaph One turns that all on its head. Yes, it’s still Dollhouse — but it’s not, really. It’s well known that it takes place a few years into the future. I won’t tell you how many. It’s shot mostly handheld and on video rather than on film — one of the biggest cost-saving elements of the episode, if I understand correctly (the episode cost half as much as the others, and its model became a big reason Dollhouse was renewed in the first place).

But the most interesting part of the episode is that while watching it, you’re no longer faced with hypotheses. There was always the consideration of what could be done with the technology should it ever slip out of Rossum’s grasp, but never being brought face-to-face with it was precisely the reason that the morality aspect of the show suffered. In Epitaph One, you’re faced with one very specific example of precisely what happens — and it’s frightening. Thus, my argument that the episode gives the show much-needed focus.

In addition, it drive the show along narratively in spades — more, almost, than in the entire rest of the first season. It feels like LOST in more than a few ways: in terms of narrative structure, writing, and mood. This is a good thing for the show, and should the next few seasons make good on the promises of this episode, we’re in for a wild ride yet. But now I’ve spent more than enough time discussing narrative — time to talk about the other things that make a show successful.

In term of acting, while Felicia Day does a great job, it is really Adair Tishler that steals the show. Completely. She was the most adorable thing ever on Heroes (back when I [anyone?] still watched it), but here she proves that her acting chops are to be feared. Watch out for this one.

And writing-wise, Jed Whedon and Maurissa Tancharoen knock this one out of the park. They wrote Dr. Horrible along with Joss, if you didn’t know. I get the distinct feeling that apart from the seed of the plot and the usual edits, Joss really left the two of them to their own devices on this one, and they prove themselves more than worthy of the trust.

Oh, and the song at the end? Performed by Maurissa? Let’s just say that I bought it on Amazon and I’ve listened to it 42 times already in 2 days. It’s been a long time since I put anything on one-song repeat.

Epitaph One is fantastic. It ends on a note that would have been an absolutely beautiful way to end the series, and I challenge the writers to come up with an even better one when the time comes. But it’s really the promise it makes of the things to come that have me — for the first time ever — actively and completely excited about Dollhouse.

(Excited enough to write a blog post at 2 in the morning. Ugh.)