Showing posts with label internet. Show all posts
Showing posts with label internet. Show all posts

Tuesday, November 10, 2009

Wordle - A Java Based "Word Cloud" Generator


  "What is a word cloud?", you may ask. Simply put, a word cloud is a visualization of word frequency in a given text as a weighted list. The more often the word appears in the given text, the larger the word appears in the cloud.

  Wordle is a nifty tool that allows anyone to easily create word clouds. Available at http://www.wordle.net, Wordle can be used to create custom word clouds that are limited only by your imagination!

  The Wordle website provides a variety of methods for providing the text to be "wordled". The text can be pasted from the clipboard, referenced as an Atom or RSS feed, or linked from a del.icio.us user tag list.

  The resulting Wordle is created completely client-side (on your browser) using an imbedded Java applet. A series of drop-down menus allow an amazing amount of customization to be applied to the word cloud. The font, color, layout, and even number of words displayed are all editable.

  One down side of Wordle is that there isn't an easy way to save a Wordle creation as an image. Java doesn't have any provision for saving images. Images can either be saved as screenshots, or saved as a PDF through the use of a PDF printer driver like CutePDF Writer (Windows) or cups-pdf (Linux).

  Head on over to the Wordle website and give it a try. I'm positive you will soon be addicted!

Read More...

Monday, October 26, 2009

Calling a Perl Script from a web page using JavaScript

Ever wanted to include some dynamic data on your web page, but didn't want to (or restrictions didn't allow you to) code the entire page server-side? There is actually a pretty straightforward way to accomplish this, by making the Perl script return valid JavaScript and then calling the Perl script as if it were JavaScript. Confused? I was too until I developed a working example of how it works.

For this example, I will combine the random quotation Perl script I outlined in a previous post with cowsay, also outlined in a previous post on this blog. The Perl script will call the random quotation script, pipe it through cowsay, then return the output in JavaScript to be executed by the browser.

First, the Perl code; I'll call it "cow_quote.pl":
#!/usr/bin/perl 

use strict;
my $line;

# Get a random quotation from www.quotationspage.com
# using random_quote.pl, then pipe the output through
# the cowsay program, limiting the output to 30 columns
my $cowsay = `perl random_quote.pl | cowsay -W 30`;

# Substitute all occurrences of the backslash ("\")
# with the HTML escape code ("\")
$cowsay =~ s/\\/\/g;

# Substitute all occurrences of the space (" ")
# with the HTML escape code (" ")
$cowsay =~ s/ / /g;

# Split the resulting cowsay text into individual lines
my @cowsay = split(/\n/, $cowsay);

# Declare the Internet Media (MIME) type  - The browser
# REQUIRES this to be declared; without it this example
# WILL NOT WORK!
print "Content-type: text/html\n\n";

# Using CSS, declare a style for our DIV tag, setting the
# font to bold courier, with the size of the font being
# 83% of the normal size.  This will permit us to utilize
# all 30 columns of the cowsay text in the narrow sidebar. 
print "document.write(\"<style>\\n\");\n";
print "document.write(\"  \#cowsay\\n\");\n";
print "document.write(\"  {\\n\");\n";
print "document.write(\"    font-family:courier;\\n\");\n";
print "document.write(\"    font-weight:bold;\\n\");\n";
print "document.write(\"    font-size:83%;\\n\");\n";
print "document.write(\"  }\\n\");\n";
print "document.write(\"</style>\\n\");\n";

# Create the cowsay DIV tag, and output the multiple lines
# of the cowsay text, separating each line with an HTML
# break, then close the DIV tag.
print "document.write(\"<div id=\'cowsay\'>\\n\");\n";
foreach $line (@cowsay)
{
  print "document.write(\"  $line\\n\");\n";
  print "document.write(\"  <br />\\n\");\n";
}
print "document.write(\"</div>\\n\");\n";
As you can see, all the output from the Perl script is in JavaScript, allowing the code to be executed client-side by the browser.

Now all that we need to do is to call the script from the web page, using the following code:
<script type="text/javascript" src="http://yourdomain.com/cgi-bin/cow_quote.pl"> 
</script>
Of course, you would substitute your domain for the one listed above.

This is by no means the limit of what could be done utilizing this method. As long as the output is in JavaScript, the sky is the limit!

The Perl source for cow_quote.pl is available here. In order for function properly, it does require that cowsay and random_quote.pl (and it's dependent Perl modules) be installed on your server.

Read More...

Saturday, October 10, 2009

Where Wizards Stay Up Late - The Origins of the Internet


While perusing the computer books at my local library I came across a book entitled Where Wizards Stay Up Late - The Origins of the Internet, by Katie Hafner & Matthew Lyon

It looked interesting, so I checked it out.

What a fascinating read. I couldn't put the book down. I ended up reading the entire book in one sitting.

From early meetings discussing the need to link distant computers together, all the way through the development of HTML and Mosaic (the first browser) this book details not only the technologies that were developed, but also the people and organizations that made it all happen.

It is written so even a person with no background in the underlying hardware, software, and protocols involved with the internet can read it and understand, but yet someone with a basic understanding of those concepts isn't put off.

This book is a really good read, and anyone with even the slightest interest in how the internet as we know it came to be should read it.

Read More...

>