... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)


Line Breaks in Mathematica

In Mathematica, running on Windows, I wanted to generate a text file using UNIX newline conventions.  Unfortunately, the Export / Text function does not provide an option governing line terminators -- you always get the convention of the host platform.  As a workaround, if you export using String format, then the file will use Mathematica's convention, which is UNIX-style.


MS SQL Server Executable Code

The following query will list all user-defined executable objects (procedures, functions, views):

select name
from sysobjects
where objectproperty(id, 'IsExecuted') = 1
and objectproperty(id, 'IsMSShipped') = 0


Dynamic Test Suites in JUnit 4

Here is how you create a dynamic test suite using the JUnit 4 (instead of the old JUnit 3 suite mechanism):

public class MyRunner extends Runner {

    private static final Description TEST1 = Description.createSuiteDescription("test1");
    private static final Description TEST2 = Description.createSuiteDescription("test2");

    public MyRunner(Class<?> testClass) {
        // required by JUnit

    public Description getDescription() {
        Description description = Description.createSuiteDescription(MyRunner.class);
        return description;

    public void run(RunNotifier notifier) {
        notifier.fireTestFailure(new Failure(TEST2, new RuntimeException()));




BeanSetter.java contains a class that converts a table of strings into a list of Java beans.

DOM getElementById vs HTML Parsing in Java

If you parse an HTML document using JTidy, the DOM instance that it returns only supports DOM level 1.  The DOM level 2 method  getElementById is "supported", but it unconditionally returns null.

Using htmlcleaner 1.55 and Java 1.5, a native Java DOM object is returned.  It supports getElementById, but it will not recognize the id elements defined by HTML.  Thus, it also unconditionally returns null.  Java 1.5 uses Xerces internally, so it is probably possible to use some of the Xerces HTML parsing capabilities, but this would be an unsupported solution.


Windows vs USB Drives

Under Windows, you might plug in a USB pen drive, but it does not appear.  No error message is given, and the device is listed in the Safely Remove Hardware list, but you cannot find it in Explorer.

A possible cause for this behaviour is that the drive is trying to use a drive letter that is already assigned to something else.  You can check this by right-clicking on My Computer, selecting Manage, then Disk Management.  Look for the drive.  If it is there, right-click on it and use the Change Drive Letters and Paths option to assign a different drive letter.

SQL Server: Offline vs DROP DATABASE

If you issue the command DROP DATABASE for a SQL Server database that is offline, the associated MDF and LDF files will not be deleted.

In a related note, if you take a database offline using

sp_dboption 'mydb','offline','true'

you may get this error message when you attempt to bring it online:

Device activation error.  The physical file name 'c:\blah\mydb.ldf' may be incorrect.

Use the following command instead:

alter database mydb set offline with rollback immediate

The former appears does not appear to offline the database files cleanly.

Blog Archive