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