Phil’s Hobo Humor and Insights

Hobo humor, funny stories, and maybe something useful too.



Free Perl Script - Random Quote Generator for Your Website

December 27th, 2006 by Phil Stewart

I recently added a random quote to the bottom of this site. Each time a page on this website loads, a different random quote is displayed. This was fairly easy to add, didn't take much time, and I hope it will be a nice little humorous touch.

There are many uses for a random quote generator, not simply to display a funny or goofy phrase. You may have a tagline, and want an easy way to change it from time to time. Or you may have a list of links, and want to show them randomly. The script running the quotes at the bottom of this site is custom, and very simple in nature. It will take regular text and/or HTML code from a regular text file. This makes it easy to maintain, and add or remove items from the list. Plus, this means you could even make a list of images, and use this script to randomly display them on your site. So it's not only a random quote generator, it can also be used as a random image generator.

Now to the good stuff. I am making the random quote generator available for free on this site. It is written in PERL and is what is known as a CGI script. All this means is that it was made to run on the web. As long as your webhost allows CGI scripts, there should be no problem running this little program on your website.

So, if you want a random quote (or image) generator on your website, the first thing you want to do is download the script.

Download Random Quote Generator

I have included the random quote script and sample quotes in a “zip” file. When the downloaded file is unzipped, a directory called “random-quote-generator” is created. Inside this directory are two files, the PERL script (“random-quote.cgi”) and the sample quotes file (“quotes.txt”). This is all that is needed to run the random quote generator.

To get started, open quotes.txt in a text editor and enter your quotes, taglines, or other HTML you would like displayed. An example for random quotes may look something like this:

The early bird may get the worm, but the second mouse gets the cheese.
One time I woke up taped to the soda machine.
Here is another quote with something apparently witty or funny.

Make sure to put each item on its own line.

Once you have entered your own random quotes (you can always add more later), it's time to upload the files to your website. It doesn't really matter where you upload the files to, but they must be in the same directory, the directory must be web-accessible (meaning you can view the files on the web), and you must be able to run CGI scripts from this directory.
When both files have been uploaded, the CGI script must be made executable (so it can run over the web). This can be done through most FTP programs, or by typing the following “chmod” (change mode) command at the command line prompt:

chmod 755 random-quote.cgi

At this point you should be able to view the script in a web browser and see one of your quotes randomly displayed. An example is at http://www.philstewart.org/random.cgi

If you run into problems, it is possible PERL is installed in a different location on your webserver, or CGI scripts cannot be run in the directory where the script is. Solutions to these problems are beyond the scope of this post, but if you run into issues, let me know and I'll see if we can work it out.

Now that the random quote generator is running, we need to include it in a webpage. There are several ways the random quotes can be included in your site, but it will mostly depend on how your site is setup, and the types of files you are using.
One method for displaying random quotes is by loading the CGI script in a frame, but that seems kind of cumbersome. So here are two other easy ways to add the random quote generator to your site.

Method 1: Use “Server Side Includes”. Not all webhosts have this setup, but if they do, it is an easy way to include CGI scripts (or other files) in your webpages. These are like normal webpages, but they end in “.shtml” and use special syntax to include other files. For our random quote generator, use the following code inside any “.shtml” file:

<!--#exec cgi="/path_to_this_script.cgi" -->

Make sure to set the path to the random quote script or it will not function correctly.

Method 2: Use a PHP file. The random quote generator can also be included in a PHP file. I plan on writing a PHP version soon, but until then, use the following code inside any PHP pages:

<?php print file_get_contents('http://www.domain.com/random-quote.cgi'); ?>

Remember to change the code to point to your copy of the random quote generator or you may experience some weird results.

If all went well, you should now have a random quote generator running on your site. I can't possibly cover all the problems one might encounter when trying to set this up, so if you ran into problems, I would be more than happy to resolve them with you. And if you have suggestions or ideas for improvements (or new scripts), please feel free to send them my way.

Enjoy.

Stumble This Post DiggIt! Del.icio.us Yahoo Reddit Newsvine Technorati

Posted in , Phil's Blog, Website Tips & Tricks | No Comments »

Lists of Available Domain Names

December 12th, 2006 by Phil Stewart

I have just added a page with lists of available domain names. Currently there are two lists on the page, one for all available three-letter .cc domains (LLL.cc) and one for all available three-character .org domains ("three-character" domains include numbers and letters).

I am tracking these domains because, being short and in limited supply, I feel they will eventually sell out. This seems to happen with a lot of the shorter domains, and when it happens, demand drives prices up. A recent example is the three-number .cc domains (NNN.cc). Just two weeks ago, there were almost 200 of these available to register. That is nearly 20% of the total possible combinations of NNN.cc domains. Now, every single one of them is gone, they have all been registered. And since domain owners are just realizing this, the prices on NNN.cc domains are going up. This happens every time there is a sell out of these short domains.

Anyway, if you're into domain names, enjoy the lists. I'll be updating the page and adding more domain lists soon.

Stumble This Post DiggIt! Del.icio.us Yahoo Reddit Newsvine Technorati

Posted in Phil's Blog, Website Tips & Tricks | No Comments »

Blog Posts: Quality vs. Quantity

December 5th, 2006 by Phil Stewart

When I first started this website, my strategy was to post "when inspiration struck". This sort of worked, but left wide gaps of inactivity on the site. It was a brand new website, so no posts meant no visitors and to me that meant little inspiration. It's tough to keep something going when you feel like you aren't getting anything out of it.

The next method came with an unexplained surge in motivation where I wanted to post as much and as often as possible. It has taken me less than a week to realize this will not work either. Ok, the website has grown quite a bit with all the new content. Stinky Hobo and his pal the Office Hobo have new stories, there are new jokes, and I'm brushing up on satire. A lot has happened on this website in the past week but I feel this monkey-on-crack method of mass posting is not working for me either.

For one, I can't keep up at this pace. Several posts per day means a couple hours of writing per day. Working a full-time job, I simply don't have the time. This is a lame excuse... I have obviously made time to do it so far and if I wanted it bad enough, would continue to make the time for it.
But the clincher, whether we have time to spend or not, is that making a bunch of posts does not equal making a bunch of GOOD posts. Most of the time, the opposite is true because we are scrambling for more and more stuff to post and a whole lot of junk makes it in there.

Now, I'm not saying that all of my first posts were quality posts and all of the recent ones are junk. But I am saying that focusing on a post count makes the junk posts a lot more likely to slip through. Do you really want a blog full of two sentence junk posts that don't amount to, or contribute anything? Are the posts you're making going to be relevant five years from now? How about a year from now or even a month from now? Are your posts going to be relevant tomorrow? Is anyone going to want to read them or find them of value?

Maybe we should be asking why we're really doing a blog in the first place... But I will leave that question for another post.

Working on this website for the past few months has taught me that quality is absolutely more important than quantity. If you have a thousand articles on your website but only ten of them are any good, what are the chances that your visitors will find the good ones? Or will you just overwhelm them with fluff and posts about your day as to turn them away? When they leave your website, will they ever return?

On the flip side, it is a lot more difficult to come up with a quality post. That takes gasp time and effort. And they usually take some thought, too. It's much easier to put the brain and fingers on auto-pilot and write whatever random blurb comes to mind.

There are many ways that quality posts will not only increase the value, but also the potential of your site or blog. Content will bring visitors to your website but only quality content will keep them returning. Well written posts on a specific theme or idea will also rank well in search engines, bringing in a continual stream of new readers to your site. Good articles will get linked on other sites and blogs. These are all positive for your website.

I am convinced that in the long run, quality will always win out over quantity but the trick is to find what works for you to achieve your purpose and intentions. In the end, it is all up to you. It is your site, after all.

Stumble This Post DiggIt! Del.icio.us Yahoo Reddit Newsvine Technorati

Posted in Phil's Blog, Website Tips & Tricks | No Comments »

Support PhilStewart.org


BlueHost.com was voted best support in 2004, 2005 & 2006! Offering a free domain, 600GB space, 6TB transfer, SSH, SSL, FTP, Stats, CGI, Ruby, Perl, PHP & MySQL all for just $6.95/monthSign up now!


    Game of the Day

    Fish Hunter 2 - Caveman fishing<br> with spears.<br>(No, not Britney)

    Fish Hunter 2
    Caveman fishing
    with spears.
    (No, not Britney)
    Play

Recent Posts

Categories

Stinky Hobo Stories


    This hilarious paperback book is now available.

Cool Links

Subscribe