i haz teh codez's Image
More about this blog
Latest Post
03 Dec 2009
Total Posts
18
Readers
182
Liked
0
Disliked
0
Views-Per-Post
10.11
vote up
0
vote down

Code Dump: Stripping out HTML

Two solutions for this seam to pop up - Regex and using HTMLEditorKit. The first is very broken and can not handle escape characters, the latter works well but does not maintain formatting. So here is my expanded version which also breaks when it
 
Mike Lee
tags: teh codez
Dec 03 2009 08:35 PM
vote up
0
vote down

Code Dump: Stubbing with a map

A year or so back I wrote a cool little utility class MyInvocationHandler. This is used by simply creating a map of the proprieties and their values simply as I felt that: Map backing = new HashMap(); backing.put("title", "ihaztehcodez");
 
Mike Lee
tags: teh codez
Nov 30 2009 08:32 PM
vote up
0
vote down

How to render HTML in Java then save this as an image

A few Java based HTML renders exist, all with different sets of drawbacks. The most common is the one built in. This is quite simple and can only render fairly basic HTML. The most interesting I know of is The Flying Saucer Project. This can render
 
Mike Lee
Nov 14 2009 08:05 AM
vote up
0
vote down

Mocking System Classes

Today I answered a question about mocking system classes in Java on Stack Overflow. I found the documentation for doing this somewhat limited, so I'm going to rework and repost my answer here. First things first. If you have to mock system classes then
 
Mike Lee
Oct 30 2009 05:27 PM
vote up
0
vote down

JUnit 4.7 - TemporaryFolder

JUnit 4.7 adds a cool looking new feature - Rules. These should get rid of the need to write a new Runner every time you want something nifty to happen. One of the rules is TemporaryFolder. This automatically creates and destroys a temporary folder at
 
Mike Lee
tags: junit
Oct 29 2009 09:46 PM
vote up
0
vote down

Sad day. Sad sad day.

Today I found out that schmidt.devlib.org has been eaten by the great Noodly One in the sky. A real shame it was a very useful resource for Java developer. Hopefully it has found a new home.
 
Mike Lee
Oct 29 2009 05:15 PM
vote up
0
vote down

Preventing multiple instances of an application from running.

This is a common question, with a very common answer - create a machine wide semaphore. The most common recommendation in Java is to use a socket. However this answer has a flaw. In a multi-user environment you do not want a machine-wide, you want a
 
Mike Lee
Oct 26 2009 04:43 PM
vote up
0
vote down

*headbash*

I got sucked into the evil time vortex that is StackOverflow again and decided to have a go on a PMD question. My god people put some sodding docs up. I spend the last few hours digging about for any documentation that I could find on the tree structure
 
Mike Lee
Oct 22 2009 03:26 PM
vote up
0
vote down

My Nifty Idea

I have had a cool idea floating at the back of my mind for a little while and today as I have work I really don't want to do I worked out how to make it work and have thrown together a prototype. So first some background. I find myself writing a fair
 
Mike Lee
tags: oracle
Oct 20 2009 09:05 PM
vote up
0
vote down

Code now on GitHub

I need to play with Git for a bit as I just don't understand what all the fuss is about. So I've thrown the code I've written for this blow on to GitHub. The public repository is: git://github.com/mlk/ihaztehcodez.git
 
Mike Lee
tags: teh codez
Oct 20 2009 07:53 PM
vote up
0
vote down

Mocking a Get/Set Pair using EasyMock

Once again I'm going to tart up a post of SO and throw it on here: Say you have an interface with a get/set pair that get populated and retrieved. And you need these to match. public interface GetSetId {     public int getID();
 
Mike Lee
tags: teh codez
Oct 20 2009 03:47 PM
vote up
0
vote down

Integration vs Unit test for the database layer

A commonly posted question on Stack Overflow is how to unit testing the database layer. Any question about this generally ends up with two diverse answers. The first is that all database activities should be mocked and tested during integration testing,
 
Mike Lee
Oct 01 2009 08:09 PM
vote up
0
vote down

Options for deploying desktop software in Java

Like my yesterday I'm going to copy & paste an answer from Stack Overflow. Java software can be release in a number of ways depending on the target market. The simplest for the developer (but hardest for the end user) is to just release a jar file
 
Mike Lee
Sep 25 2009 07:57 PM
vote up
0
vote down

Randomly Ordered JUnit Tests

Could not be arsed to work for a bit, so got sucked into Stack Overview for a bit. Never a good thing. Anyway one question was about how to run JUnit tests in a random order. So I sat down and looked over the APIs and gave it a bash: import
 
Mike Lee
tags: teh codez
Sep 25 2009 07:56 PM
vote up
0
vote down

How to become a developer

Every now and again I see a request on the JDC for teh magick knowledge that will turn a person from random guy to developer. So for the second time today I'd like to vomit my wisdom all over the internets. First learn how to use the command line.
 
Mike Lee
Sep 25 2009 07:55 PM
vote up
0
vote down

Defensive Coding

Google Testing recently recommended against being defensive. The rationale behind this was that testers found it easier to simply pass a null when testing than passing in a constructed object. I disagree with this. Creating a null object either with an
 
Mike Lee
Sep 25 2009 07:54 PM
vote up
0
vote down

Generating Word Documents In Java

UPDATE: I think need to depricated this post. Go with FOP. Very now and again I see this on the JDC, and as I have recently needed to do this I thought it would be good to write down how to do this. Are you creating word documents or editing existing
 
Mike Lee
tags: rtf
Sep 25 2009 07:53 PM