Sometimes when creating a Maven plugin (Mojo) or when running java tools with maven using the exec plugin it’s helpful to debug the actual JVM that’s been started by maven. This is a snippet which you can throw into your ~/.bashrc to allow you to quickly toggle in and out of debug mode for Maven. Tweak the java debugger settings as you wish, as configured this will cause maven to wait on port 5005 for a remote debugger to attach.
$ mvn exec:java -Dexec.mainClass="com.jontodd.MyClass"
Listening for transport dt_socket at address: 5005
I’ve written about how to count unique occurrences of a string in a file in unix but today I needed to push the unix sort command a little further.
Consider the case where you have a CSV file with a column of text and a column of numbers like the following:
How would you sort it numerically by column two and then by column one such that if there are multiple numerical values in column two with the same value then column one will be sorted alphabetically? Well, of course the sort command has everything you need:
For the last few years I’ve been using Growl and Growl Notifier on the command-line to get asnc notifications when long running builds and tests have finished. Now that OSX Mountain Lion has it’s built-in Notification Center, the next inevitable question is how to get this same functionality in Notification Center.
The answer is a utility called terminal-notifier which can be downloaded from github. Just unzip the binary and drag it to your Applications folder and you’ll have access to the terminal-notifier command in terminal.
Here’s an example of how I use this for running tests in the background. When the tests finish you’ll get a notification which you can click on if you want the results.
I’m working through a big refactor in our code base and I wanted to quickly find a count of all the unique matches to a string search expression. Here’s an example of how to do this on a unix command-line with the help of grep, cut, sort, and uniq.
Let’s break that down. The first part says: recursively search the current directory and any subdirectories for lines containing “import javax.xml.bind.annotation”. This part alone will result in something like:
Now we want to get the count of each unique match so we can first do a sort which will group all the like elements together. Then pass it to uniq to take the sorted results and squash duplicates to a single line with a count. Then finally to sort the aggregated results we pass it to sort once more this time with -n which tells sort to do a numeric (not lex) sort and -r which makes the order descending. So our final output looks like:
I recently updated to the latest version of OSX Mountain Lion and everything went well. In standard fashion the upgrade blew away some cruft and among other things it removed Java. Upon opening the first program that requires Java, in my case Intellij, you’re prompted to install a newer version of Java which doesn’t have jvisualvm packaged.
I don’t really know how to say this but Windows 7 is kind of a big deal. So much so that it’s probably worth throwing a party, you know, like tupperware. In case you don’t know how to throw a party, Microsoft will tell you, take a look at this gem.