Monthly Archives: February 2006

Tagged Code Snippet Repository

Peter Cooper has developed a simple source code snippet repository with tagging that I like. It’s far from perfect, the syntax highlighting is often squirrelly and if you enter in a multi-word tag like this “unit test” when you go to edit the code you get your tag back as two separate words so you always have to put the quotes back in place. Nevertheless, it works and it’s a good start. Plus people aren’t being shy about putting code out there.
What we need at this time are a small army of Java developers putting their code snippets into this repository. In no time it could be the place to go for a quick routine to fix a problem.
Here are my snippets thus far:

They will even give you a feed for when I post new snippets. Unfortunately they don’t have feeds for individual tags (e.g. Java) working yet. That’s a shame and it’s actually one of several glitches I’ve noticed. But even with the bugs this is still a more believable code snippet repository than many I’ve seen over the years. The tags go a long way towards making it really searchable and usable. But it will only be really useful if _everybody_ enters in some of their favorite utility functions and classes. So go sign up this minute and put in just three Java code snippets! It will take you less than 15 minutes and we will all benefit.
If there aren’t any more improvements or he never releases the source code or it never gets full text search then maybe I’ll move my snippets to another repository in the future. But it needs to be one with syntax highlighting, an easy framework for inserting the code in the first place (this is very very easy), and tagging.

The Democracy Player

I love the name of both the group producing this software and the software itself. I talked about Participatory Culture before on my podcast a long time ago when they brought out an early version of their BitTorrent based broadcasting software Broadcast Machine. Now they’ve managed to get out early versions of their client software for the Mac and Windows. It is named Democracy Player and I think that’s just great.
Having played around with it for a while, here’s what I can tell you about it:

  • The interface is easy enough for anyone to use and it comes pre-loaded with a set of channels so you can anticipate that there will be more channels in the future and a much better selection as well. It will never hit podcasting levels of popularity (i.e. 10,000 channels in less than 18 months) simply because it is so much more difficult to produce video than it is audio, but channels could easily number in the hundreds by the end of 2007.
  • Their website is channeling Firefox and their software interface is channeling iTunes. As far as I’m concerned, that’s just right.
  • They did a lot of things right. They understand that the costs of distributing video would make it completely impracticle and even setting up servers to deliver a lot of content at high speed is daunting so they’ve relied on BitTorrent to handle that from day one. Apple should have done the same thing with their iTunes client and there wouldn’t be a single podcaster out there worrying whether it was going to cost them more than they could afford for bandwidth or straining under an audience that keeps getting bigger.
  • Participatory Culture has based everything around RSS channels just like in podcasting but made sure that you’ve got a server that is easy to use to publish your video channels via Bittorrent and a client that can receive them. Just as with podcasting you don’t have to use their server or their client but can instead mix and match. Talk to any server that can handle Bittorrent downloads and RSS with the client or vice versa, serve up your channels to any client that can work with RSS and Bittorrent. They’ve just provided an easy turnkey solution.
  • Their Mac client software was out before the Windows version so it may be more stable. Nevertheless, I used the Windows version to browse various channels, pick videos to download, download them, and watch them all from within the Democracy Player.


  • I’ve had problems with it crashing repeatedly and with it being very unresponsive to me wanting to change to look at a channel after I start playing a video and I decide I don’t want to watch it all the way to the end. By very unresponsive I mean 30 seconds to a minute of delay before taking action on a click.
  • The video controls at the bottom of the screen on the Windows version do not appear to update and only sometimes control the video functions.

If you want an early look at a tool that is going to be as indespensible as iTunes has become for many people, download this and start playing with it.

Upgrading The Ant In Anthill

Like many, I use UrbanCode’s Anthill for automated builds. It’s easy to setup, easy to run, and it has the basic features I need even in its open source version. But recently I noticed that it was ignoring failed builds and at first I couldn’t figure out why. Everything else seemed to be working just fine and even installing the new Anthill 1.8.1 release didn’t fix the problem.
Just in case you run into the same problem, it was due to me installing a new version of Ant (1.6.5 in this case) and the ant.bat file, which is what Anthill runs under Windows XP, not passing through the error code to Anthill. This message from their mailing lists a few months ago includes a replacement ant.bat file you can use and it will fix your problem.

Quit Hardcoding Your *#%^ Database Connections!

Over and over I encounter Java code that hard codes database connection creation or resorts to pulling all of the connection parameters from a properties file bundled in with the .WAR or .JAR, or even a resource bundle (yes, that’s you Kasai). QUIT IT!
There are these things in Java called data sources. They are an object you can go to and ask for a database connection, it hands it off, you use it to perform a query or two, you close it. That’s it. If any database pooling, testing of new connections, etc. takes place it is hidden inside the data source and you don’t have to think about it. In fact, because some data source implementions do things like pooling and testing of connections, they will probably work better than that five line version of “how to create a JDBC connection” you found online and pasted into your code.
Just about any type of server or framework you might choose to use around your application typically makes it easy to create data sources, specify all the details of how they connect to a database, and all you have to do is perform a couple of calls to get a data source. In the majority of your code, you don’t even worry about the details of how the data source was obtained, you just accept it as one of the parameters to your class or to your method and you use it.
If your application isn’t running inside a J2EE server, or Tomcat, or Spring, or some other place where a data source object is easy to come by, you can use the Jakarta Commons DBCP library to quickly create one of your own (hopefully configured using parameters that can be easily changed).
Here’s an example of what I’m talking about that takes its configuration from system parameters:

BasicDataSource dataSource = new BasicDataSource();

There you go, a data source that has caching and all kinds of other features you can tweak if you need them. Once you’ve got it you can call dataSource.getConnection() and out pops the connection ready to use. If you are running inside of Tomcat or WebLogic or something like that then you have even less of an excuse. In Tomcat for example, they provide a way to create data sources inside the Administration interface, you can just go to a web page, log in and create them. Retrieving one of the data sources you created in your code is this simple:

// Obtain our environment naming context
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
// Look up our data source by the name we gave it when we created it. In this case that's "jdbc/EmployeeDB".
DataSource ds = (DataSource) envCtx.lookup("jdbc/EmployeeDB");

If you keep making everybody jump through hoops to set up your database connections when all we want to do is configure a data source, we’ll just start rewriting your code. If you are writing a library to be used by other people, or an application that has to be configured by someone other than you, make it take a data source!

EasyUbuntu Is About Filling The Linux Gaps

I did a Fedora Core Getting Started Guide once upon a time. For many years it and HotSheet competed every month to see which would be the most popular item on this website and many months the Fedora Guide took first instead of second. People crave an easy way to not only get Linux and install it, both things that have been well addressed by Linux distributions of the last few years, but also to get it setup to use in a manner similar to what they were comfortable with under Windows.
They want Flash and Java in their browser, they want to be able to listen to their MP3 files and play videos from off the web, install new fonts, plug in their USB key and have it work, etc.
While it doesn’t address all of these, EasyUbuntu is a program which Ubuntu Linux users can run and get set up automatically to play MP3 files, get Java/Flash and get them installed, as well as several other improvements which are fundamental to re-creating the computing experience most of us expect these days when we sit down at a computer. Everything it does is optional and the UI is designed to be simple. Just check the features you want installed and off you go.
I’m not running Ubuntu at this time, but it seems to have overtaken Fedora Core in the hearts and minds of many as the most likely candidate for a desktop Linux sufficiently friendly to be installed in a normal non-guru computer user’s desktop. EasyUbuntu takes that even further and is exactly the sort of thing I had envisioned Fedora Core getting someday but Ubuntu has it first.
Here is my one and only piece of advice for the EasyUbuntu guys. Beginning Linux users don’t need multiple ways to do the same thing. Don’t be afraid to go ahead and make some choices for them. For example, you list both Wengo and Skype as Voice Over IP solutions you’ll add. There’s no need for that. Pick Skype and be done with it, knowing that the end user will have the most common VOIP solution and will still be able to talk to multitudes of users still on other operating systems. For the majority of users who need something like EasyUbuntu, choices are just confusion. They will install both, or neither, and have no way to judge which they should be using.