Jan 132014
 

Mac command line gold!

Copy a file to the clipboard:

The contents of my .zshrc are now on the clipboard and I can paste them into any other application (Mail.app, Word, whatever).

Paste the clipboard contents to the shell:

Anything that was on the clipboard is now in the file foo.txt.

Oct 252013
 

A cool bit of CLI trickery that James Humphrey shared with me. This allows you to use IDEA for diffing and merging via git’s mergetool and difftool commands.

First, add IDEA to your path (everything is in Mac-speak here):

Bash

Fish

Next, add these lines to your ~/.gitconfig file:

That’s it. Now you can use IDEA to diff and merge from git CLI like this:

Mar 082013
 

I’ve found another annoyance with MyBatis (there are many so be on the lookout for a long blog post that covers everything). This one has to do with how MyBatis handles missing TypeHandlers and required a bit of time stepping through their code.

If you have an object that contains a field whose type is not registered with the TypeHandler registry, MyBatis does not always produce a nice exception for you. Instead, it sometimes decides to return null instead of creating your object.

Here is an example:

I’m using Joda’s DateTime object here. If you don’t register this with MyBatis, it can cause this code to fail:

The fix is to register the TypeHandler like this:

Mar 062013
 

If you are using MyBatis TypeHandlers in your Configuration, you need to register them BEFORE you add your Mapper instances. As it turns out, MyBatis proactively parses your XML and completely configures each mapper when it is registered. If you mapper XML uses results that need a TypeHandler, you must register those before hand.

Here’s some quick code:

This works because the TypeHandler is registered before the mapper that requires it. This won’t work: