Archive for the ‘Programming’ Category

Programmers of the World, remove the hyphens!

Friday, January 22nd, 2010

Like many of you, I’ve written code for web sites. How hard is it to remove spaces and hyphens in credit card numbers and phone numbers? Usually, it’s a one-line regexp. And some test cases. Don’t forget the test cases.

People make measurably fewer mistakes when they can punctuate long number strings. It’s easy enough for us to let them do it.

So write the code.

Loading JNI libraries on the Mac

Monday, January 18th, 2010

I’ve been trying to build a simple JNI library from C code on the Mac (Snow Leopard). Compiling it seems pretty straightforward, but the Java library loader isn’t happy. I can call

System.load("/tmp/jnitest.jnilib");

which works fine, or

System.loadLibrary("jnitest")
// or
System.loadLibrary("jnitest.jnilib")

with java.library.path set to “/tmp”, which doesn’t work.

I’ve given up trying to understand it for now. I spent way too long googling on the Intertubes for information, which points to problems with Java 1.6 on Snow Leopard, but I didn’t find anything that was even consistent with this behavior. On the other hand, I can at least make progress for the moment, since the JNI calls work.