How to write a simple CAPTCHA in Java
Posted by Kaleb Brasee on Sunday, April 12th, 2009 at 12:16 AM
When I opened up my site earlier this week, I was surprised to find over 300 replies on one post. "Wow", I thought to myself, "I am now a powerful force in the blog-o-sphere." Turns out, some stupid spambots kept selling dipophedrin and tranzambol and eptexerdoze on my site every 5 minutes. I tried changing the URL used to post comments but the bots were far too smart for that feeble attempt at a fix, and they were posting comments again 10 minutes after I put up the new build.

So I decided it was time to add CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) validation. CAPTCHA provides a way to block bots from interacting with your site by providing something that's hard for them to read, but easy for people to read. I wanted to try something simple that I could write myself to see how it works. Read on to see how I implemented simple CAPTCHA in my Java web app.
Site update: free MP3s and new album!
Posted by Kaleb Brasee on Tuesday, March 31st, 2009 at 11:25 PM
I just deployed a new update to Brasee.com, and it includes a couple of big changes. First off, all of my songs are now available as free MP3 downloads! I figured that since the best things on the internet are free, these songs should also be free. You get free songs, my site meets best-things-on-the-internet eligibility requirements, everyone wins! Plus, PayPal never let me set up a micropayment account (despite me calling them multiple times), so they charge a 30-cent fee for a 50-cent song, LOL.

So you can now download the MP3s directly from the album pages. I had to cut the bitrate down slightly to make bandwidth more manageable, but they still sound pretty good IMHO. I still have the CDs for sale too, so if you'd prefer to listen to the songs in pristine quality, that's the way to go.

I've also started working on a new ragtime album entitled 'Dusty Keys'. Ragtime is so amazingly fun to play, especially Scott Joplin's pieces, so I thought it would be fun to put together the songs I have played over the years. I have also written a couple of rags, so when I get a chance I'll record those too.
Using Hibernate Search in a JPA application
Posted by Kaleb Brasee on Sunday, February 22nd, 2009 at 07:30 PM

When I finished the blog features on this site, the next big thing on my list was developing a way to index and search the contents. I didn't want to let Google do it for me, because that's like cheating. I had heard good things about Lucene (actually great things, I know a guy who uses it for everything from searching for products in a web store to indexing biological information), so I started looking into that.

I was happy when I discovered Hibernate Search, a library that simplifies mapping a Hibernate domain model to Lucene's searching capabilities. I was even happier when I discovered that Hibernate Search has excellent support for JPA, which is the API I used for this site. In the rest of this post I'll outline the steps I had to take to add Hibernate Search to this site. It ended up being much easier and more intuitive than I had expected...

Proud soon-to-be owner of Bacon Salt
Posted by Kaleb Brasee on Thursday, February 19th, 2009 at 10:35 PM
Bacon Salt Woot.com has been running a woot-off for the last couple of days, selling tons and tons of random stuff. I didn't check on it until tonight, when I noticed to my great shock and amazement that I had arrived just in time for Bacon Salt®!!! I had no choice but to order all three flavors, Original, Hickory, and Peppered.

I've always wanted to try the stuff — it does make everything taste like bacon, after all — but I don't think there's a store that sells it within 50 miles of my house. But Woot.com came through in a big way, and I'm already tasting the bacon. I should probably find a way to use this for every meal I eat.

Edit: I wonder how this will taste on the Snyder's Honey Mustard and Onion pretzel pieces?! That might be too much deliciousness for me to handle...
Rodent's Revenge and SkiFree - Good Old Days of Gaming
Posted by Kaleb Brasee on Saturday, February 14th, 2009 at 03:09 PM
Download Rodent's Revenge
Download SkiFree

I was looking through my directory on my hard drive today and reminiscing (yeah, I have files that are 15 years old, I think that counts as reminiscing). In the "ancient" directory I found two awesome old games that I had forgotten all about: Rodent's Revenge and SkiFree.

Rodent's Revenge is a great little strategy game where you're a mouse that has to corner cats using blocks so that they don't catch and eat you. Somehow, cornering a cat means that it evaporates, but I'm not exactly sure how or why that happens. You can download Rodent's Revenge here.

SkiFree is a twitch action game where you ski down a hill, slaloming or freestyling among trees and hills and lifts and dogs and other skiers. And eventually if you ski far enough down the hill, a yeti eats you. The slalom mode keeps track of your best times — I remember trying for hours to get better and better times on the tree slalom. You can download SkiFree here.
Snyder's Honey Mustard and Onion pretzel pieces: Best. Food. Ever.
Posted by Kaleb Brasee on Wednesday, January 28th, 2009 at 08:48 PM
Snyder's Honey Mustard and Onion Pretzel Pieces I just have to put a plug in for Snyder's of Hanover Honey Mustard and Onion pretzel pieces. They are without a doubt the best snack food on the planet. Every piece just bursts with an addictive flavor that's not too mustardy or oniony. They have totally redefined what a pretzel is capable of. I can no longer go one day without eating some of them.

I'm pretty sure that the pretzels are making me post this, I wouldn't put it past them. Speaking of which, I need to go get another handful.

The worst thing about the "Credit Crunch"...
Posted by Kaleb Brasee on Saturday, January 24th, 2009 at 03:35 PM
... is that people will call it the "Credit Crunch" for the rest of my life, and I'm going to hate the name every time I hear it. I'm pretty sure that the nickname is the worst part of the recession.
Unit testing - how did I live without it?
Posted by Kaleb Brasee on Friday, January 23rd, 2009 at 10:12 PM
Test Driven book cover I remember a time when I didn't write unit tests. I'm not sure why I didn't. Maybe because I thought that the projects I was working on were too simple to warrant unit testing (which actually wasn't true, my thesis project would have really benefited from it). Or maybe because I thought it would take too much time when the schedule was really tight. Or maybe because I doubted the time-effectiveness of spending time writing a lot of basic tests.

But no longer. A couple weeks ago I started development for an enhancement to an existing project at work. Prior to this phase, no unit tests had been written for the project, and I figured it was a good time to start. So I bought the book Test Driven: TDD and Acceptance TDD for Java Developers, read up on some of the basics of JUnit, and started writing tests alongside my components (not always test-first, but at the very latest, test-right-after). And the immediate effectiveness shocked me.
Gilels + Rachmaninoff = Awesome
Posted by Kaleb Brasee on Saturday, January 17th, 2009 at 08:47 PM

I found this months ago on YouTube, and I still find myself watching it at least once a week. The song itself (Rachmaninoff Prelude Op. 23 No. 5) is fantastic, but Gilels' performance is simply perfect, with expression that blows away all the other ones I've heard. I had to go out and buy the music, but it's crazy hard – I still haven't gotten the first 30 seconds down yet.

Maybe it would help if I grew an awesome combover-style hairdo like his.

Fixing Spring + JPA "Removing a detached instance" exception
Posted by Kaleb Brasee on Saturday, January 17th, 2009 at 07:56 PM

I've been working on an update to this site that adds blogging & commenting features. It's a Spring + JPA site, so I created a Post object and a PostDAO and built all the new features using those classes. Everything worked perfectly until I implemented the delete controller. When trying to delete a Post, I was getting the following exception:

org.springframework.dao.InvalidDataAccessApiUsageException: Removing a detached instance com.musicstore.model.Post

I debugged the exception, searched all over the place and couldn't figure what was causing the exception, which was occurring within a getJpaTemplate().remove(post) call. After an hour or two of fruitless googling, I decided to read up on JpaSupport (which the PostDAO extends) and look more closely at my code. I finally realized what the problem was when I noticed that JpaSupport provides callbacks when you need to access an EntityManager directly – but I wasn't using them...

Newer posts »