Clever 404 Pages

Everybody who has been on the Web more than five minutes knows the 404, we’ve all seen our share.  In fact, I’m willing to bet most people can recall seeing a default Apache 404 and IIS 404, even if they don’t know what a Webserver is.  It’s relatively easy to change the default error page that your website serves to something more useful and elegant, but the simple fact of the matter is that hardly anyone ever does.  Even when they do, it’s usually just to put some nice styling around the big bold type that says "404 - Not Found" so that it matches the theme of the website.

That’s why I enjoy it when, every so often, I come across a clever, witty, funny, or sarcastic error page.  But I rarely remember them after I’ve moved on to the page I was looking for, and I suppose that even though they may give a few people a chuckle before they hit the back button, the majority of people are gone as soon as the number 404 hits the back of their retina.

So I’ve decided that I will start collecting these witty error pages, here on this blog, in a category called "404".  And to start it all off, I will point you to the 404 page that prompted me to write this post in the first place.  This 404 page is from mikeschinkel.com and I therefore presume that it was created by Mike Schinkel, although I have no other evidence to support that claim.  Enjoy!

Posted by mcollins Mon, 13 Apr 2009 14:19:00 GMT


mk_ext.sh - Making a Firefox extension the quick & dirty way

Sometimes it’s nice to be able to create a separate extension that you install into a Firefox profile, to test things out quickly, or to experiment with some new functionality.  But a simple HTML file won’t do, either because you need chrome privileges or you need to access XUL elements or XPCOM components. There’s a lot of boilerplate code that is involved setting up the structure of a Firefox extension, though.  Normally when I need to do this I spend a few minutes copying and pasting things from some other extension I’ve written that still happens to be lying around.  But years ago I realized "I should just write a script to do that" and unlike the other five thousand times I’ve said that, this time I’ve actually done it.

 

#!/bin/bash
#
# Copyright 2009 Michael G. Collins.

# The contents of this file are subject to the Mozilla Public License
# Version 1.1 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/

# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
# License for the specific language governing rights and limitations
# under the License.
#

if [ -n "$1" ]
then
    EXTENSION_NAME=$1
else
    echo "You must provide a name for the new extension."
    exit
fi

#get a guid
UUID=`uuidgen | tr A-Z a-z`

echo "Creating extension $EXTENSION_NAME with ID $UUID in directory `pwd`/$EXTENSION_NAME"

#make dirs
mkdir -p "$EXTENSION_NAME/chrome/content/$EXTENSION_NAME"

#create a skeleton install.rdf
cat > "$EXTENSION_NAME/install.rdf" <<EOF
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
  <Description about="urn:mozilla:install-manifest">
    <em:id>{$UUID}</em:id>
    <em:name>$EXTENSION_NAME</em:name>
    <em:type>2</em:type>
    <em:version>0.1</em:version>
    <em:creator>mk_ext.sh</em:creator>
    <em:targetApplication>
      <Description>
        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
        <em:minVersion>1.5</em:minVersion>
        <em:maxVersion>3.0.*</em:maxVersion>
      </Description>
    </em:targetApplication>
  </Description>
</RDF>
EOF

#create a basic chrome.manifest
cat > "$EXTENSION_NAME/chrome.manifest" <<EOF
content     $EXTENSION_NAME     chrome/content/$EXTENSION_NAME/
overlay chrome://browser/content/browser.xul chrome://$EXTENSION_NAME/content/$EXTENSION_NAME.xul
EOF

#create a stub overlay XUL file
cat > "$EXTENSION_NAME/chrome/content/$EXTENSION_NAME/$EXTENSION_NAME.xul" <<EOF
<?xml version="1.0"?>
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
         <script type="application/x-javascript" src="chrome://$EXTENSION_NAME/content/$EXTENSION_NAME.js"/>
</overlay>
EOF

#create a JS file
cat > "$EXTENSION_NAME/chrome/content/$EXTENSION_NAME/$EXTENSION_NAME.js" <<EOF
const Cc = Components.classes;
const Ci = Components.interfaces;

EOF

echo "Done."
echo "You can install this into a Firefox profile with:"
echo "echo \"`pwd`/$EXTENSION_NAME\" > \"extensions/{$UUID}\""
exit

If this is something you’re looking for, and you haven’t already copied and pasted this code into a file, you can download it here (but really why haven’t you just copied & pasted already?).  It’s a Bash script and I’ve tested in bash shells on Mac OSX, Linux, and FreeBSD, but I think it should work on any system which has bash and uuidgen installed (If anyone wants to try it out on cygwin let me know if it works for you).

To get started go ahead and create a new Firefox profile as described here or here.

Then just find the directory you created your new profile in, and copy the script over there. On Mac OSX, the default is /Users/<user_name>/Library/Application Support/Firefox/Profiles, on *NIX it’s something like ~/.mozilla/Firefox/Profiles/ and on Windows, well, who cares they can figure it out for themselves, I don’t use Windows.

Run the script with something like $sh mk_ext.sh my_new_extension with the only argument being the name you want to use for the new extension. The script will generate a unique ID for the new extension as well as the chrome manifest and install RDF file and a very simple XUL and JS file (using the name you supplied on the command line) for you, and will output the ID for you as well as a simple "echo" command that will create a pointer for the newly created extension directories in whatever profile you choose to run it in.  If your still sitting in the directory you ran the script in, just copy that command and run it.  Fire up the Firefox profile you installed the new extension into, and start hacking!

Posted by mcollins Sat, 07 Feb 2009 22:49:00 GMT


A New Host

Last week I quietly moved this blog along with everything else on my old server to a new host.  Why, you ask?  Well cost was a big factor, I simply felt that I was paying too much for way more server than I actually needed.  But another equally important factor was the server OS.  I moved from RHEL4 to FreeBSD 7, and I am glad that I did.  I’ve been running various flavors of Linux on desktops and servers for over 10 years, and have only toyed with FreeBSD occasionally, but I’ve always wanted to find an excuse to start using it more.

Installing all the software I needed was a breeze thanks to the ports collection, and overall the administration has just been a lot less painful.  My new hosting provider, RootBSD, were really quick getting everything setup, and their support (though I haven’t needed anything from them besides getting my domains on their DNS) were really fast and helpful.

I also feel a little better about supporting BSD-licensed software over GPL, but I am going to resist the temptation to turn this into a "You got your politics in my software!" rant.  I’m just going to run the software that works best for my needs, and I plan to continue running Slackware on my desktop at home for a long time.

Posted by mcollins Sun, 18 Jan 2009 03:57:00 GMT


Older posts: 1 2 3 4 ... 6