source code

A Java "extract method" refactoring example

If you don't own a copy of Martin Fowler's Refactoring book, I highly recommend it. The basic idea of refactoring source code is that the code "smells" in one way or another, and there are a variety of ways to improve smelly code. More specifically, Mr. Fowler describes refactoring as this:

Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code, yet improves its internal structure.

A Java Active Directory JAAS example

I normally don't like to put source code out here that I can't support, but in this case I thought I'd make an exception, because I remember a former co-worker having a really hard time getting this Java Active Directory JAAS code working properly. It's been over two years since I got it working for him, so I don't remember what the problems were. Hopefully if you're trying to get Java working with Active Directory (using JAAS), this example source code will get you pointed in the right direction.

A Drupal categories block PHP script

A lot of people have written me to ask how I generate the Drupal categories block on this website. There are probably a lot of different ways to generate a Drupal categories block these days, but the way I do it is with the PHP script shown below. (Sorry, I'm too lazy to look to see if there is a new Drupal categories block module/solution; I'm pretty content with what I have.)

How to read command-line arguments with Perl

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

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

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.

JSP calendar - Source code for my web calendar (JSP) project

Update (August, 2010): This website no longer runs under my earlier Java servlet/JSP blog code, so the JSP calendar I used to have running here is not running any more. That being said, I am still sharing my JSP calendar source code, as it still works just fine.

My JSP calendar source code

As I've mentioned in other blog posts, I like my servlet/JSP calendar approach for the following reasons:

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.

Syndicate content