the magic growing text box

Here’s a text box that grows as you type to hold just the right amount of text:

<textarea name="foo" rows="1" cols="20" onkeypress="resizeme(this);"></textarea>

<script type="text/javascript" charset="utf-8">
// <![CDATA[
function resizeme(t) {
	var characterCount = t.value.length;

	// assuming proportional font
	var columnCount = Math.floor(t.cols * 1.25);
	var height = t.rows;
	var newHeight = 1 + Math.floor(characterCount/columnCount);

	if (newHeight != height) {
		t.rows = newHeight;
	}
}
// ]]>
</script>

Here it is in action:

top 20 CDs of 2005

  1. Luke Doucet/Broken (and other rogue states)
  2. Kyler England/Live Wire
  3. Jason Mraz/MR. A-Z
  4. Sylvie Lewis/Tangos & Tantrums
  5. Libbie Schrader/Taking the Fall
  6. Samantha Murphy/Somewhere Between Starving & Stardom
  7. Josh Rouse/Nashville
  8. Pocket Dwellers/PD-Atrics
  9. Erin McKeown/We Will Become Like Birds
  10. Sarah Harmer/I’m a Mountain
  11. Kathleen Edwards/Back to Me
  12. Emm Gryner/The Great Lakes
  13. Great Big Sea/The Hard and The Easy
  14. Adrianne/Down To This
  15. Charlotte Martin/Darkest Hour
  16. Anya Marina/Miss Halfway
  17. Tristan Prettyman/twentythree
  18. Krister Axel/Permanent Friday Night
  19. Peter Bradley Adams/EP
  20. Dave’s True Story/Nature

fixing the airlines

Sites like Expedia, Yahoo Travel and Travelocity all have one thing in common: they suck. Actually, they probably all use SABRE, too.

It’s very hard to use these sites to compare trips with multiple airports; refining your results is hard, too. Maybe the UI is bad on purpose — they want you to give up and just buy the more expensive flight.

And why not? They’re travel agents; they make money on ticket sales. There’s hardly an incentive to be objective.

Three new players are filling the void. The first is SideStep, which my friend Samantha told me about. With SideStep, you can easily exclude flights out of your price range, favourite airlines or agreeable departure times. The UI is really slick, and it’s very responsive.

Someone at BarCamp Austin mentioned Kayak, which does much the same thing.

What looks even more interesting is FlySpy, which TechCrunch highlighted in February. FlySpy takes this to a whole new level, letting you track pricing trends and figuring out just when is the right time to buy. You can play with the alpha now, and see what it’s like to fly out of Minneapolis.

Lastly, if you ever want to find out which airlines and flight numbers will take you from A to B, check out SkyGuide.

(keywords: airline airfare flight price cheap)

Using CURL in PHP

In Python, to read a URL, I do the following:

import urllib
data = urllib.urlopen('http://foo.com/').read()

PHP links against cURL, which lets you accomplish the same thing … in five lines of code.

If this is something you plan to do more than, say, once, you’ll want an easier way of doing this. Here’s the function I use:

function readUrl($url) {
	$curlHandle = curl_init();
	curl_setopt($curlHandle, CURLOPT_URL, $url);
	curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
	$data = curl_exec($curlHandle);
	
	if (!$data) {
		print curl_errno($curlHandle) . "  " . curl_error($curlHandle);
		curl_close($curlHandle);
		return false;
	}

	curl_close($curlHandle);

	return $data;
}

(keywords: curl php wrapper example)

congrats Mark and Catie!

Mark Erelli and Catie Curtis just won the grand prize in the International Songwriting Competition.

Their song, “People Look Around,” is a stark, honest portrait of the United States and a cry for humanity — for us to be more human:

Mississippi River divides this land in two,
Like the way we tend to think of things;
Black and white, red and blue.
If they can keep us fighting about marriage and God,
There’ll be no one left to notice if the leaders do their jobs.

(lyrics, lyrics and mp3)

the importance of net neutrality

the execs at the telcos (perhaps the same people whose secretaries print their emails — who knows) have this great idea to make money off the internet: meter everything.

their argument is that google is getting a “free ride” on their network. well, no, they aren’t. they are paying for bandwidth at their end, and you, the end user, are paying on your end as well.

that’s like at&t saying they should get 5% of the profits of every telemarketing call. sigh.

for a great overview of this, listen to Burnie Burns’s SXSW keynote and read Brad Templeton’s essay. (Scot Hacker has notes from Burnie’s talk.)

technical confidence

Sally Carson, a designer I met at SXSW, put together a thoughtful examination of what happens when people are intimidated by technology:

I think that instilling confidence into our audience — whether on the web or on an electronic device — is an important component of good interface design. Something about Phil’s phone intimidates him, and eventhough he is embarrassed when his phone rings so loudly (keep in mind, embarrassment is a strong motivational tool) he doesn’t even attempt to change the settings himself because he is sure he won’t be able to figure it out.