ActionScript 3.0 – Global Variable & On Mouse Click Event
April 22, 2008
Categories: Web & Software Development
Tags: ActionScript 3.0, Flash
I got to do a little ActionScript 3.0 work today. I can’t help but wonder what type of things I could create using Flash and ActionScript. Seems like it could be pretty fun. Do ActionScript programmers make good rates compared to .Net programmers?
Anyways. Here’s a few examples of some really basic ActionScript 3.0 stuff.
Here’s an example of how to create and use a global variable in ActionScript 3.0.
var intClicks:int = 0;
function showDoves():void {
++intClicks;
if(intClicks >= 5){
_movieDoves.visible = true;
}
}
And here is an example of how to add an “on click” mouse event listener function in ActionScript 3.0.
_btnFact1.addEventListener(MouseEvent.CLICK, onClickBtnFact1);
function onClickBtnFact1(evt:MouseEvent):void {
_fact1.visible = true;
}
That’s all I got. I just wanted to document this so I can reference it later. I hope it’s helpful to you.
Why is “Content-type: text/html” displayed at the top of my CGI pages?
April 2, 2008
Categories: IT & Administration, Web & Software Development
Tags: IIS, Perl, PerlIS
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.
How to delete an entire directory via SSH
March 31, 2008
Categories: IT & Administration, Web & Software Development
Tags: Linux, SSH, Unix
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
Convert from Blogger to Wordpress
March 29, 2008
Categories: Web & Software Development
Tags: Blogger, Wordpress
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!
How To: NHibernate Parent/Child Relationships
November 23, 2007
Categories: Web & Software Development
Tags: ASP.Net, C#, NHibernate
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.
