Recently one of my clients was having some issues with a CGI script they purchased. They’re running IIS on all of their servers, and oddly, this purchased script worked on one of their servers but not the other. On the server where the script wasn’t running correctly, IE displayed “Content-type: text/html” at the top of the CGI page. If I remember correctly FireFox displayed the entire markup of the page in text.

After quite a bit of research I found this excellent Perl for Win32 FAQ and learned that when you setup Perl for IIS you have two options, you can use “Perl for Win32″ or you can use “PerlIS.” In my client’s case, they were running Perl for Win32 on the server with the working script and PerlIS on the server with the broken script.

Perl for Win32 = perl.exe
PerlIS = perlis.dll

They are both the same version of Perl, and both come included when you download Perl for Windows. However, even though they are the same version of Perl, they are different “interpreters.”

Perl for Win32 and PerlIS are mostly alike, but PerlIS requires that your scripts include the HTTP response status line as well as all headers for the response. Using Perl for Win32 you only need to specify the headers.

PerlIS is about two times faster than Perl for Win32. However, most CGI script that you purchase, or download for free, do not specify the HTTP response status line. This is because most scripts are not written for PerlIS. (Ok, I can’t backup that claim, but that seems to be the case in my experience.)

If your Perl scripts are displaying the content-type at the top of the page, try configuring your IIS server to run Perl using perl.exe instead of perlis.dll.

I know this is probably common knowledge to Linux and Unix geeks. But every time I need to remove a directory with files in my NearlyFreeSpeech.Net SSH terminal I end up having to google for the command. So here it is for anyone else who’s out there googling!

rm -r -f YourDirectory

rm = remove / delete
-r = recursively deletes the directory and all files in it, including subdirectories
-f = will not ask for confirmation before deleting

I recently converted this blog from Blogger (published via FTP) to Wordpress. It actually turned out to be a whole lot easier than I anticipated. I’ll lay out the steps I took for you below.

Also, I should note, it was very important to me that all of my old Blogger links do a proper 301 permanent redirect to their new home on my WordPress blog. I cover this below. However, I do not cover how to convert your Blogger template to a WordPress template. I took the transition as an opportunity to create a new look for my blog. So I skipped that process.

Step 1

First! I installed WordPress on my NearlyFreeSpeech.NET hosting account. (Fact: NearlyFreeSpeech.NET is the best web host on the planet.)

Step 2

In Blogger (under Settings -> Publishing) I switched from “publish via FTP” to “publish on blogspot.com.”

Step 3

Then I used WordPress’s awesome Blogger Import feature! (Found under Manage -> Import) You’ll notice that you can not import blogger posts hosted via FTP. This is why I temporarily switched to blogspot.com.

Step 4

After the successful Import, I installed the “Maintain Blogger Permalinks” plugin. This plugin makes your new Wordpress permalinks match your old Blogger permalinks. You only need to run this plugin once, then you can uninstall it.

Step 5

Now that my imported posts had their old permalinks, I took it a step further. I no longer wanted the archive folders (ie: /2006/03/) in my permalinks. Nor did I want my permalinks to end with the HTML file extension (ie: .html). So I added the following to the top of my .htaccess file.

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /
   RewriteRule ^([0-9]{4})/([0-9]{1,2})/([^/]+)\.html$ $3/ [QSA,R=301,L]
</IfModule>

Step 6

To preserve links to your old Blogger archives add the following to the top of your .htaccess file.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^archives/([0-9]{4})_([0-9]{1,2})_([0-9]{1,2})_archive.html$ $1/$2/ [QSA,R=301,L]
</IfModule>

Optional Step 7

During your Blogger import into Wordpress, all of your Blogger “labels” are converted into WordPress “categories.” So if you want to maintain any old links to your old labels, add the following to the top of your .htaccess file.

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /
   RewriteRule ^(labels)/([^/]+)\.html$ category/$2/ [QSA,R=301,L]
</IfModule>

I say this is optional because after I got my posts into Wordpress, I immediately started changing all my categories and tags. So the precaution I took above turned out to be not very helpful. Oh well.

The End!

That about sums it up. It was a pretty easy transition. Of course I’ve spent hours setting up and tweaking my new template, and I’ve spent countless more hours playing with all the cool community created plugins. I just can’t help myself.

Drop me a comment if this was helpful to you! :)

So my last blog post was in November 07! What can I say, I’m a geek not a writer!

Lack of posting excuses aside, since November a lot of great things have been going on. I started Jelly in Austin, a casual coworking group. That has been going great. I’ve met tons of really smart and interesting people at Jelly and I’ve made a lot of friends.

Spawned from the Jelly meetups, me and a few new friends have co-founded a venture that we’ve dubbed Conjunctured. Our goal is to create a company based around coworking and the values found in commons-based peer productions. We’re calling our endeavor a co-company and have started a co-company Google Group to solicit feedback from the community at large. We’re interested in any feedback you may have about the idea, so drop us a line at the Google Group if you get a chance.

I’ve also begun work on some web applications that have been rattling around in my head for awhile. The first being MileTrackr.com. The premise of the site is to leverage Google Maps to calculate your business travel mileage for tax deduction purposes. I imagine the site shining if you don’t log your miles daily, but you keep records of your hours and/or client meetings. You can then use the calendar view on MileTrackr.com to retroactively log your miles, letting Google Maps calculate the distance for you. The site has a lot of work to go, but I’m pleased with the progress I’ve made so far.

Floating Head Studios, the brand I have developed for my personal web services work has been sailing steady. However, I’m considering dividing my branding efforts into 3 segments. Floating Head Studios for the web applications I develop, Conjunctured for technical and marketing services, and Dusty Reagan as an independent consultant. Yeah, I consider “Dusty Reagan” a brand. I’m that guy. :P

And most recently I’ve upgraded (emphases on the upgrade) my blog from Blogger to Wordpress! Woot! Hopefully I’ll have a post about the process up soon. (Aka, within the next 3 months! No, I’m kidding. Hopefully this week.)

So you’re trying to setup a Parent/Child relationship using NHibernate. This is easy enough when you allow the foreign keys to be null in your database. Of course this is not desirable for data integrity so you disallow nulls. Now NHibernate is pissed because it wants to insert the child row first then update it with the parent id.

You can fix this by setting up a bi-directional relationship. Simply put, try the following.

In your Parent.hbm.xml add:

<set name="Children" inverse="true" cascade="all-delete-orphan">
 <key column="parent_id"/>
 <one-to-many class="Child"/>
</set>

In your Child.hbm.xml add:

<many-to-one name="Parent" column="parent_id" not-null="true"/>

Now you need to make sure you update the Child class to “know about” the Parent. To make this easy add this method to your Parent class:

public void AddChild(Child c)
{
 c.Parent = this;
 this.Add(c);
}

Now we can do this:

Parent p = new Parent();
Child c = new Child();
p.AddChild(c);
session.Flush();

That’s the tall and skinny of it. To really understand this concept check out Chapter 16 of the NHibernate Reference Documentation.