title

fire chief's random developer tidbits

Friday, December 17, 2010

Extremely useful vim settings

make the mouse work like it should by default:
:set mouse=a

make vim use vim improvements instead of defaulting to older vi behavior
:set nocompatible

show hidden characters like dos carriage returns (^M)
:set list

Debugging remotely and waiting for debugger attachment

Starting with Java 5, you can run a java program this way and have it suspended until you attach a debugger remotely:

-agentlib:jdwp=suspend=y,server=y,transport=dt_socket,address=HOST:PORT

More info here:

Thursday, December 16, 2010

Crazy Vim Stuff

Given a huge text file you want to extract some things from, here's how to delete all the lines that DON'T start with a regex in Vim:

:%s/^\(\(search text\)\@!.\)*$//g

then remove all the blank lines:

:g/^$/ d
(there's a space before the d)

then sort it with:
:sort

Help came from these pages:
http://vim.wikia.com/wiki/Search_and_replace
http://www.computing.net/answers/unix/delete-blank-line-thro-vi-editor/4552.html

Monday, November 8, 2010

Value 'blah' is not facet-valid with respect to pattern 'meh'

I haven't done much with XSD, but I'm fixing an application that validates its (overly complex) xml config file against an XSD.


It reads in a database host address and validates it with a regex.  I needed to add a port config entry so it looked simple enough.  I just wanted to validate that the port is 1 to 5 digits and don't want to limit it to actual port ranges.  It's just a simple validation to help catch typos.  So I whipped up a regex "^\d{1,5}$".


Then I got the error "Value '3307' is not facet-valid with respect to pattern '^\d{1,5}$'".  What does this mean? Well, I ran across this page which says "Particularly noteworthy is the complete absence of anchors like the caret and dollar."  So I took out my caret and dollar and then the validation worked.

What this blog isn't

This blog isn't a place to put pictures of my kids.
This blog isn't a place for me to be a pundit.
This blog isn't a place for me to show off.
This blog isn't a place for innane product tie-ins, just to get google ad revenue.

It's just me, solving problems with Java and posting the particularly strange ones where the solution wasn't collected in a single place already.

Maybe it will evolve to more than that, but don't hold your breath.