script

A Ruby script to remove binary (garbage) characters from a text file

Problem: You have a file that should be a plain text file, but for some reason it has a bunch of non-printable binary characters (also known as garbage characters) in it, and you'd like a Ruby script that can create a clean version of the file.

Solution: I've demonstrated how to do this in another blog post by using the Unix tr command, but in case you'd like a Ruby script to clean up a file like this, I thought I'd write up a quick program and share it here.

Ant - How to use a date or timestamp in an Ant build script

Summary: An Ant date and timestamp (tstamp) task example.

I was just digging through some Ant build scripts I've created, and I noticed a segment of a build script that first creates a timestamp, and then uses that timestamp in the process of creating a manifest file. (This build script is used for building a Java Swing application.)

Here's the code from my Ant script that does this timestamp magic:

How to turn a list of jar files into an Ant classpath string

Summary: Using a list of jar files to create a dynamic classpath to write to a manifest file in an Ant build script.

In this tutorial I'd like to demonstrate how to convert a list of jar files in a standard lib directory into a classpath string you can use to define a manifest file in an Ant build script. By converting this list of jar files into a classpath string, the build process for your jar file can depend on any number of external jar files, and you can create this classpath dynamically.

How to embed data in your Perl program

Here's a sample Perl program that demonstrates how you can include (embed) data inside of your Perl program, right in there next to the source code.

This simple program takes the data after the special __END__ tag, and makes it available to your Perl source code.

#!/usr/bin/perl

while (<main::DATA>)
{
  print $_;
}

__END__
George Washington
Abraham Lincoln
John F. Kennedy

As you can see, you loop through the data with this line of code:

Where to put your AppleScript programs

I was just working on a new AppleScript program on my Mac, when I had to remember where to install my script so I could access it from the Mac menu bar.

After digging around real quick, I saw that I installed all of my original scripts in this Mac folder:

/Library/Scripts/AlsScripts

I think I did this so my scripts would appear near the top of the list of available AppleScript programs, as shown in the following figure:

OpenSSO and PHP - A simple PHP script to retrieve OpenSSO identity information

Here's a simple PHP program I wrote to test how PHP works with OpenSSO, specifically how it works with OpenSSO identity information.

I saved this file with the name info.php, then put it in a directory on my Apache web server that is protected by an OpenSSO login policy. To access this page, I enter the URL for the page in my browser and try to access it, with the URL being something like this:

Deploy only your JSP files with this Ant build task

A lot of times when you're working on a Java web application you only need to deploy your JSP files. This happens, for instance, when you're just editing the JSP files to modify the look and feel of your web application. In cases like this there's no need to rebuild your entire application, deploy it, then restart your application server (Tomcat, Glassfish, JBoss, whatever).

Syndicate content