Testing the Impossible: Asserting Several Values At Once

23. March, 2009

So you want to check several values at once, maybe because that helps you to locate the error more easily. Simple:

int v1 = list1.size();
int v2 = list2.size();
int v3 = list3.size();

assertEquals (
      "list1=5\n"
    + "list2=2\n"
    + "list3=0\n"
    , "list1="+v1+"\n"
    + "list2="+v2+"\n"
    + "list3="+v3+"\n"

hpaio: unable to read device-id

21. March, 2009

I recently bought a multi-function device printer scanner (HP Color LaserJet CM1312nfi MFP). Setup on openSUSE 11.1 was pretty painless with the hplip package (version 3.9.2) from packman. The original openSUSE package would core dump. Duh.

Today, I had a strange error all of a sudden:

scan/sane/soapht.c 486: unable to open device hp:/net/HP_Color_LaserJet_CM1312nfi_MFP?ip=xxx.xxx.xxx.xxx
io/hpmud/jd.c 84: unable to read device-id

Of course, I hadn’t changed anything in my setup … until I remembered that, for security reasons, I had disabled SMNP in the web interface of the printer. Guess what, after enabling “SNMP-Lese-Schreib-Zugriff aktivieren” (“Activate SNMP-Read-Write access”), the error went away.

For the record: Most functions of the device are accessible from Linux:

  • Color printing
  • Scanner
  • Automatic document feeder (ADF)
  • Remote printing and scanning

I haven’t yet managed to make the “Scan to PC” button on the front of the device work but that’s just a minor issue for me.

The price/performance ratio is very good. The printouts look very good and the ADF could cope with all media that I’ve fed him so far (even these thin, glossy, cohesive catalogue pages; you just have to spoon feed them one at a time).

The scanner is good, but not top notch. The quality of the scans is OK, colors are pretty close to the original but the images could be sharper. The scanner uses a CCD line, so no warmup time (if you don’t have to switch on the whole machine).

If you want better quality color copies, set the resolution to 300 DPI (factory setting is a poor 150 DPI which makes thin lines really smear).


On Strength

16. March, 2009

Strength means you can afford to be polite.


Found My Friends From The Talon Company

5. March, 2009

Disclaimer: This is a cynical virtual diary of my journey through Fallout 3. If you don’t like strong language or cynicism, this is not for you.


While wandering the landscape, I ran into this fort. Fort Bannister. Guess who lives here? The friendly guys of Talon Company! You know, the guys who supply me with ammo, guns and armor in the field? Whenever I need it, three of them would show up and, after a friendly round of sparring, they’d hand over their goods to me. XP for free, too!

What can I say? As I saw their crest, I had to drop in and say hello! Until I reached the poorly hidden access grate, like seven guards had forced their stuff onto me. I could barely walk under the weight!

Down in the guts, the boss, a Commander Jacobs or Jabsco or something, couldn’t really hear him over the firing of my brand new laser rifle, stood target himself so I could improve my skills in energy weapons! Whow! That’s customer service, eh? And every time I as about to run out of anything, another of his chaps would shop up and leave me stuffed!

Guys, I’ll miss you.


Random Idea: Public Data Safe

5. March, 2009

A lot of places offer free data storage these days but I’m concerned about security. How safe it is to store something sensitive there? You may think that your address is not sensitive data but you’ll have to reconsider as soon as some crook uses it to open a new eBay account…

So my idea is create a public data safe where you have full control what someone else can see. For example your address: Instead of giving a online shop your address, you give them a random ID and you give access rights for the delivery service to resolve that ID. The shop doesn’t know where you live (and your address doesn’t go “somewhere” when the shop goes bankrupt) and you still get your goods.

Imagine you have an accident. You’re unconscious and are brought into a hospital. They need to run tests to figure out your blood group. If they have to give you medicine, then you’re better not allergic to it. And how about alerting your relatives? Here, a random ID which only registered health care services can decode would help: You could put your health data (allergies, medicine that works better on you than other, blood group, relatives to alert, important facts like whether you have a heart disease, etc) online without risking to find them on the loose.

How would it work? The service itself would only store data which you send encrypted. So the encryption would happen on your computer. Better get that anti-virus up to date, though. Health or delivery services would put their “public keys” online on this site, too, so you could encrypt the data in such a way that you and they can read it (basically, you make a copy and encrypt both). This way only certain people can read the data.

When data is uploaded, it gets tagged as “address”, “name”, “age”, “medical information”, etc. and each piece gets a unique, random ID (so you can’t tell from the ID who it belongs to). When another service should be allowed to see some of your data, you take their key to encrypt a copy for them and send them the ID.

If your address changes (because you move), you’d have to update it only in a single place.

Drop me a comment if you like to implement this idea.


Random Idea: Guided Public Transport

5. March, 2009

Just got this idea: You can download train and bus schedules on your mobile, you can buy tickets online, so why doesn’t the system combine the two to guide me through the public transport?

The idea is that I send a request to travel to some spot. The software should know which coupons and other discounts apply for me, what tickets I already own, etc. So the first step would be to tell me what tickets I need in addition to what I already have and what that would cost.

If I pay, the system should guide me to the next bus stop or train station where I can start my journey. During the travel, the system should inform me a few minutes before arrivial at my next destination. This should include the estimated time of arrival, where I’ll arrive (which platform), where I need to go next (platform or location on a map), how much time I have and what connections are available.

It should also be possible to interrupt a travel, say, to have lunch on a long trip. As necessary, the system should buy new tickets and cancel preordered ones. If I stay overnight, I should get a list of connections on the next morning so I can ask the hotel service to wake me at the right time.

If you like the idea and want to implement it, drop me a note.


Verifying Results in Tests

5. March, 2009

So you finally got yourself writing a test against a database. In the test, you have to verify that a row in the table is correct, so you write:

assertEquals (
    "2008-09-16-13.50.18.000000;;;;1;2008-08-07;2008-08-07;JUNIT;2008-09-16;t0001;001;;Doe;Jane;;Street;2;Doe Jane;;;;;X;2575;John;;;;US;E;;01;;;;125;01425;0;Shop;;;DOE;JANE;JOHN;032;1;;0001010301;;;;",
    dumpRow(key));

and it sucks. Yeah, junit will notify you when something in that row is wrong and if you have a cool IDE, you can even compare the fields … but it still sucks. If one of the fields in the middle change, you have to scroll and eyeball-diff, wasting your time. The solution is pretty simple:

assertEquals (
    "2008-09-16-13.50.18.000000\n"
    + "\n"
    + "\n"
    + "\n"
    + "1\n"
    + "2008-08-07\n"
    + "2008-08-07\n"
    + "JUNIT\n"
    + "2008-09-16\n"
...
    dumpRow(key).replaceAll(";", "\n");

Instead of dumping the data in a single long string, split it into lines so you can compare fields side by side and without scrolling sideways.