Sunday, November 19, 2006

finding includes in html

For the second time in the a few months I've wanted to be able to fish through the includes in an shtml file in perl.

This while statement will itterate once for each time it matches a pattern for a virtual include, letting me check to see if the include is there, slurp it up, whatever:


while ($file_contents =~ m{<!--#?include\s+virtual="([^"]*)"\s*-->}gis){
# do something with $1 (a path)
}

bidi fun

&#8238; and &#8237; entities can be use to give browsers instructions on what order to display characters:


<div>&#8238;Left-to-right</div>
<div>&#8237;Right-to-left</div>


‮Left-to-right

‭Right-to-left


"dir" attribute can be used to provide block or page level direction on direction of the page:


<div dir="ltr">Left-to-right</div>
<div dir="rtl">Right-to-left</div>


Left-to-right

Right-to-left


A good overview:

w3c tutorial: http://www.w3.org/International/tutorials/bidi-xhtml/

Friday, November 10, 2006

when you need more ports

So I'm guessing there's more than one way to tell apache to listen beyond port 80. Here's what I figured out:


Listen 81
Listen 82
Listen 83
Listen 84
Listen 85


<VirtualHost _default_:81>
DocumentRoot /srv/www/port_81
</VirtualHost>
<VirtualHost _default_:82>
DocumentRoot /srv/www/port_82
</VirtualHost>
<VirtualHost _default_:83>
DocumentRoot /srv/www/port_83
</VirtualHost>
<VirtualHost _default_:84>
DocumentRoot /srv/www/port_84
</VirtualHost>
<VirtualHost _default_:85>
DocumentRoot /srv/www/port_85
</VirtualHost>

Thursday, November 02, 2006

line breaks

I've been meaning to try to put together a full set of notes on line break wierdness for years. This isn't it. But it might be a start.

Script works on PC but not UNIX



It took me way longer than it should of for me to figure out what's wrong with this interpreter path today:

#! /perl/bin/perl

I'd look at the line in vi. It looked fine. Then I'd go to the command line and type:

%/perl/bin/perl

which would give me the interpreter (wierd path to match where perl is on my windows box, ln'd over to /usr/bin/perl)

And eventually it dawned on me that since I'd never run this script on a unix box, it probably had PC line breaks. In the old days, I would have seen this:

#! /perl/bin/perl^M

But I guess vi or vim or whatever is on the box is smarter than it used to be. Not me though. How many times have I stubbed my toes on this?

At least I'm smart enough to use Textpad. Save As, select Unix as the file type, and I'm up and running again. In utopia, there will only be one kind of line break. That's all I'm saying.

Wednesday, November 01, 2006

perl array cheat sheet

How long is my array?



my @hw_array = ("hello","world","wassup?");

print "<br>size: ", scalar @hw_array; # 3
print "<br>size: " . @hw_array; # 3, scalar is implicit
print "<br>index of last: ", $#hw_array; # 2

At least it's not raining rotten blubber

Nathan reminded us in a meeting today that no matter how grim things may seem, at least it's not raining rotten blubber.

A great way to take a meeting off on a tangent

Monday, October 30, 2006

It's the request, stupid!

Just tripped over a nifty article 'Optimizing Page Load Time' that suggests that thinking about HTTP makes a great deal of sense when thinking about performance.

As an example, here's one of the cookies on the site that I work on:

SMIDENTITY=0gzinsuUJJp+/tRSC5ZaV0WudjvPIRSZc06S2wfBFp39qMk3IbwLjlr1yo
C1MhhFxqBPclz6XDo4tClYYnoQR7ZUh5s5z8doG63QTqetXr/pFIRyEKY7wWHtZhcKj4S
Ck43mU7JuRvPhiSuVaEZC2Cfk4N01qZE47y+nfAFD/ZAwXRBraUfKzUYHl9d+uADHFcz8
pGEHPCch1+6g0LtuRuGxO+IdELXiduWUJfs6kozvBvPGqUltBYTHv2XiLwj6AN9xDdY1K
UHQ5/DX5g0OQuud8NuBGLvF7BQyfNtHqGduOGGXgkLs3+GsD2D5ro83w/WuHt/B6DMbK8
M6FEE8t7q419KMPWxngxFA5d6rP7qxAxUXQDf4blC3POGWTGMMkV/YJvd4mqayiSEPZpH
PceeZs1WZ0GAibVtm2q4f/aYyFbv4iHvYabePsU7GP4FFpUAKoavF2GqJOTa2bUc17rtO
bQcxUrdMAV3YaHA+FodiEpVWXymdj94r95deNKjYgrC64AkGyQTTcUJpsZ3cG+9x1/j2g
mK+0Dx2XI507Azr6aFcz31X2aQ+TdtMvoCnvw664BGgs4lVT7HT9ATMKkJNTNaruM8hqF
zu0Jz0lASUlguCp9NfJQDt6ar/BUMDS/516dHZgQyXh9HTBDKzi5q8LP975mPU;

Now multiply that times the 44 http requests it takes to load one our most popular pages! That's 30K worth of cookies! sweet!

Tuesday, October 24, 2006

YUI Graded Browser Support

The YUI article on graded browser support is a nice overview of the nuts and bolts of browser support in a world where different browsers provide different levels of support for web content. It links to a chart that shows how different browsers are currently supported.

Browser support is a nice example of a class of strategic issues that are surprisingly prevalent on web projects. This is small 's' strategy: web developers don't need to understand your business model or care about financial engineering, we just need to know which users we _must_ support, a business/technical question that will determine which browsers we need to support well, which browsers we should support on at least a rudimentary level, and which browsers we shouldn't worry about.

The standard scenario is the business owner (aka stakeholder) of a project asks for tricky functionality (and this could be something as simple as fly-down menus or precise layout of text and images on a page) and, when asked about browser support, asserts that 'all browsers' or 'all major browsers' should be supported. This is usually about ten minutes before the business owner expects to head out of the office on vacation for two weeks, and before she goes she wants a firm commitment that the project will be completed or at least well underway when she gets back.

My job is often to try to figure out how to share the unwelcome news that there are some basic business questions that need to be thought about fairly carefully in order to make sure expectations are met when the site is completed. They involve thinking about people who turn of javascript (no fly-downs), accessibility (how should keyboard navigation work? Where do we need alternate content), maybe even localization (You can bet that somewhere on the carefully laid out page, localized text just won't fit without blowing something out or wrapping in a surprising way).

And of course there's the unwelcome news that we don't plan to test on IE 5 and a number of other browsers, and that people using these are likely to have difficulty with the page in proportion to the complexity of the page.

This problem is about to get worse, not better: with IE 7, Firefox 2, Ajax, and Web 2.0 we've got a new generation of browsers, some wonderfully tricky client-side technology, and rising expectations from stakeholders as to the kind of experience we can deliver.

This means a lot more conversations ahead about which browsers we need to support and which browsers we will disregard to some extent.

Thursday, October 19, 2006

Quick Tabs are nifty



Hey look, IE7 has something called quick tabs that lets me see thumbnails of all my open windows.

OK, so I'll probably only use as often as the powerpoint slide sorter (which I did use once), but it's nifty. How many years has it been since anyone has been able to looke at IE and notice anything nifty? Hint: you were still building web sites to support Netscape 4.7.

Moving files from ibook to macbook is sooo easy!

I can't believe how easy it was.

OK, so the part where the ibook stopped booting sucked. And getting the hard drive out was bizarely hard (50 screws? 10 pieces to remove first? something like that).

But once that was done, I booted up the new macbook, connected the drive using a USB enclosure I picked up at fries a while back, and an hour later all of my wife's files and applications were migrated over. iTunes. Email. Word & Mozilla. Palm desktop. user accounts and passwords. The ssid & key for our wep network. Probably other stuff I can't think of right now.

Monday, October 16, 2006

Collaboration is tricky

Bruce Schneier's article about opposition to Facebook news feeds tells the story of how Face book introduced a new feature to automatically log changes in feeds -- and the masses were not happy.

It's one thing to know intellectually that the kind of privacy folks could enjoy in the twentieth century is pretty much gone if you want to participate in 21st century society. It's another to realize that what a wrenching transition it will be as various technological forces inexorably chip away at the masks we present to the world. Increasingly, strangers and co-workers will be able to google our secrets.

Tuesday, October 10, 2006

Head Shot



I've decided to put my picture in my profile. So have uploaded one as part of this post. The process is marvelously user-unfriendly:




  1. Load a photo using the upload widget, which is cryptic, but not so bad

  2. Find the url of your photo in the code:

    <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"
    href="http://photos1.blogger.com/blogger/3099/3814/1600/elijah_lovejoy.jpg"
    ><img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;"
    src="http://photos1.blogger.com/blogger/3099/3814/400/elijah_lovejoy.jpg"
    border="0" alt="" /></a>


  3. Then take the photo url (http://photos1.blogger.com/blogger/3099/3814/400/elijah_lovejoy.jpg) and paste it into the proper field on the profile page.



Why can't there just be an upload button on the profile? Why are computers so gosh-darned hard to use?

Sunday, October 01, 2006

6 months without perl

My memory is that I reimaged somtime around march, and I haven't installed activeperl until now. Scary thought.

Anyhow, as usual, I'd completely forgotten how to setup perl cgi on Apache (which for whatever reason did not take 6 months to install, so maybe I can still call myself a web developer...), but a quick google diggs up a page on a site called the site wizard that provides much of the information that I need, with apache error logs providing the rest.

Folks who wrote the error handling code for apache deserve major good karma, and probably more credit than they get for the success of this application. Amazing how often you can find the information you need in the error log.

So the steps I took, so I can look here next time I do it:

  1. create super simple CGI.pm script

    use CGI qw/:standard/;

    print header,
    start_html('A Simple Example'),
    h1('A Simple Example');


  2. Add Handler directive so apache knows that .pl means cgi script

    AddHandler cgi-script .pl


  3. set +ExecCGI permission on the relevant directory (I turn off apache when I'm out in the wild).

    <Directory "C:/htdocs">
    Options Indexes FollowSymLinks +ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>


  4. Tell apache where to find perl, so my script now looks like this

    #! /Perl/bin/perl

    use CGI qw/:standard/;

    print header,
    start_html('A Simple Example'),
    h1('A Simple Example');



Voila. apache is up and running. Now to see if I can remember why I installed perl in the first place.

Sunday, September 17, 2006

Someday

It was probably in 2004 that my friend Nathan briefly set up his signature so that it said something along the lines of the title of this blog.

Up until I heard this, I'd spent years explaining to people that the tradeoff between quality, budget, and schedule as a sort of triangle where unfortunately, in the real world, in my experience, to the best of my knowledge, etc. ... building web sites / applications / yada yada required people to make decisions they'd rather not make about what it was that they wanted versus what they wanted to pay for it and how long they were willing to wait for it.

I've never had the guts to actually tell a client or stakeholder that they could have fast, cheap, or good if they could only bring themselves to accept that they could only get two. My theory is that one of the reasons that I have a job doing web stuff has something to do with my intermittent efforts to be diplomatic, even helpful.

But someday I'm going to crack, and I'll probably snarl something to someone that they just need to decide which two they want. Which will no doubt be the end of that particular opportunity.