source code

How to read command-line arguments with Perl

Perl command line FAQ: How do I read command-line arguments with Perl?

Answer: With Perl, command-line arguments are stored in the array named @ARGV.

$ARGV[0] contains the first argument, $ARGV[1] contains the second argument, etc.

$#ARGV is the subscript of the last element of the @ARGV array, so the number of arguments on the command line is $#ARGV + 1.

How to add stylesheet information to a JEditorPane

Did you know that you can use CSS styles when displaying HTML in a Java Swing application? It's pretty cool, and it can help spice up any simple HTML you may currently be showing in a Java-based editor or viewer. In this tutorial I'll share some source code that shows how this works.

How to create a simple Swing HTML viewer with Java

I've been working on writing my own Java text editor on and off for several years now, and one feature I just added to this editor is the ability to view (or preview) HTML and CSS content. Using just the base Swing classes this turned out reasonably well -- I'm not looking to write a complete browser here -- so I thought I'd share some source code to show how this works.

Source code for my web calendar (JSP) project

As promised, here's the complete source code for my JSP based "Web Calendar" project. If you haven't seen it yet, here's a link to my working JSP-based Web Calendar (calendar.jsp) project.

A complete Java program to open, read, and display an image file

In an earlier blog post I shared a small section of Java code that showed how to place an image on a JLabel. When I just looked back at that post I thought it would be cool if I showed a complete Java program that could read an image from the local filesystem, create a BufferedImage from that image file, create an ImageIcon from that image, place that ImageIcon on a JLabel, and finally show the image in a JFrame.

How to write text to the system clipboard from a Java application

I was just digging around through one of my Java Swing applications, and I found this method that writes a given String to the system clipboard, using the Toolkit, Clipboard, and Transferable classes, and I thought I'd share it here.

How to sort an array of Ruby objects by multiple class fields

In a previous tutorial I wrote about how to sort an array of Ruby objects by one field in the object. In today's tutorial I'd like to demonstrate how to sort an array of Ruby objects by multiple attributes (or fields) of the class contained by the array.

Several examples of the Ruby ternary operator syntax

Here's a quick example of some Ruby source code, showing how I used Ruby's ternary operator in a method that prints a CSV record for a class I defined:

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.

How to read from a named pipe (fifo)

Here's some code from a Perl program where I open up a named pipe (a FIFO file), then read data from that file until the end of time ... or at least until someone kills this program.

Syndicate content