Don’t trust iTunes gift cards

December 23rd, 2010

This is what happened to me. I gave a friend $300 to buy gift cards for iTunes, and he got me six $50 cards in the Woodlands Best Buy store in Texas. This was in november 2009. Me and a relative redeemed three of these cards during the following months, but I only got around to redeeming the last three in september 2010. When I did, they didn’t work. The error I got was that these codes did not exist.

Read the rest of this post »

The first thing you should do on a new Mac

December 21st, 2010

The very first thing you should always do on your new Mac is to make sure you run as non-admin. This protects you against most malware out on the net, since it makes it very difficult to install anything without you knowing about it. It doesn’t exclude it entirely, but it makes a major difference.

Read the rest of this post »

Macport and mono

December 19th, 2010

Just a heads-up: Macport quit working on my machine. Link errors, missing architecture in sqllite3 dynamic libs or something. After much agonizing, I began to suspect mono, especially since the sqllite3 library port wanted to link against was in the mono path. There’s a shell script in mono called uninstallMono.sh that does a fine job of getting rid of it. Run that, and things work fine again.

I’m guessing the mono libraries are simply put in too early in paths, which may cause the problem, but since I’ve got actual work to do, I’ll just roll my eyes and get on with life.

Update: the above did solve most of my problems, but not all. After perusing more forums than I’d like to peruse, I hit on a remark from one of the Macport developers that you should always reinstall the entire Macport system after every major OSX upgrade. In other words, I installed my Macport under Leopard, then upgraded to Snow Leopard, so it got unhinged. The solution is to entirely remove the /opt/local directory contents, then reinstall Macport from source. Personally, I find it a little bit scary (like, is Macport really the only system using opt/local?) so I tarballed the directory first, just in case. But I don’t think that is necessary, but time will tell.

Anyway, after reinstalling Macport this way, the rest seems to have straightened itself out.

Lecture

December 11th, 2010

I was invited to give a lecture to the International Masters Programme in Health Informatics at Karolinska Institute, and we recorded a video of the entire lecture, in total around 3.5 hours. The last part is about iotaMed, our open source project for a “new and improved” electronic health care record, which is knowledge support, medical record, and national registries all rolled into one.

The rest of the lecture is about a lot of different things I have opinions about, and as there is no lack of things I feel strongly about, it went almost an hour longer than it should have.

The full lecture consists of 12 chapters (“parts”), each 1-4 video segments (YouTube limits videos to max 15 minutes, and that makes for a lot of dividing of videos). You can find the lecture notes here. Oh, by the way, the site for the iotaMed project is here. The playlist with all 20 videos is on YouTube here.

If all else fails, try Preview

November 25th, 2010

I’m totally amazed at all the things Preview does in OSX Snow Leopard. I already use it for knocking out backgrounds, using the “Instant Alpha” tool in the “Select” dropdown. But what happened today is more interesting.

To my everlasting regret I got me a Canon Lide 60 scanner a couple of years ago. Canon’s hardware is pretty nice, but their driver support stinks, especially for OSX. This scanner costs me on average much more work than it should to keep going. Same for my Pixma 5200 Canon printer, by the way. Awful.

Anyway, I needed to scan a page from a mag to show on a slide. Hooked up the scanner, tried Canon Toolbox, and sure enough “Failed to open driver”. Internet next, user groups, downloads, complicated shit about uninstalling, reinstalling, rebooting the Mac Pro ten times. No joy. After a few hours (!) of this, I got an inspiration: hey, since I saw “Twain” mentioned, maybe Acrobat Pro 9 (CS4) could import it, instead of using Canon Toolbox? Sure enough, Acrobat found the scanner, looked it over, and promptly crashed.

And then I got my second inspiration: check out OSX Preview. And yes, that one worked. Not only that, but it automatically calibrated the scanner, proceeded to analyze the page, divided it into sections, scanned it, and served it up already partitioned into useful chunks. See the screenshots below. All the time I was just sitting there watching, doing nothing. The only thing I had to do was select the image and hit cmd-R twice to turn it the right way up.

Jeez, that innocent looking little Preview app is becoming mighty useful for any number of things.

I probably should mention that the driver I installed came in a file called “lide60osx11131en.dmg” to be found, somehow, on Canon’s support site. It installs both the drivers and the toolbox, but the toolbox doesn’t work.

Don’t do parts.parts

November 17th, 2010

I just found another weirdness in Apple’s Objective C. If you have the same name for several components of an object path, the runtime starts stuttering and behaving very badly. Intermittently, you can’t scroll, or only extremely slowly, everything turns into molasses. No errors, mind, just mindbogglingly slow.

This stuttering and slowness seems to affect the simulator, mainly, not so much if you run code on your device (in my case the iPad). Also, if you run under instruments, things work better (Murphy strikes again), except I had it stutter under “Allocations” but not under other instruments.

I had these repeat names in two places in my code and resolving those two seems to have fixed the stuttering entirely. To illustrate what I mean, see this code snippet:

for (IDRBase *idr in self.parts.parts) {
   if ([idr isSuperCell]) break;
   CGRect newFrame = myCGRectDown(hugeFrame, verticalOffset);
   UIView *view = [idr getAsView:newFrame];
   if (view) {
      [returnView addSubview:view];
      verticalOffset += view.frame.size.height;
   }
}

(Yes, it’s the same snippet as in the previous example with nil or not nil. Coincidence. My code does indeed consist of more than just this.)

In the very first line you see a property referred to as “self.parts.parts”. That is what screws things up. Even though the two names “parts” refer to entirely different things, and even though the code actually delivers the values it should, this repetition of identical literal names confuses the crap out of the runtime, it seems. The solution is to not name these two things the same, of course. In this case, I changed the innermost “parts” to “aParts”, resulting in “self.parts.aParts”, and hey presto, no stuttering no more.

Fighting the good fight

October 22nd, 2010

Comment spam on a site like this is out of this world. Completely nuts. I just looked over the stats and this is what they look like:

Click the image for a better look at it. No, you’re not misreading it, 99.27% of all comments I get are spam. Un-frickin-believable. Only between one and five a month get through and have to be manually removed.

Without Akismet, there’s no way I’d allow comments at all. Killing on average 30 spam comments a day to get one sensible comment a week is not what I’d call a fruitful use of time.

Even the machine agrees

October 8th, 2010

Picture this. I’m a little nervous, not much, but a little, since I’m to present my first running code on an iPad of my own entirely different idea of what a medical record should actually look like. I’m presenting this to a group of industry folks, doctors, and professors of different kinds, a power group. So we park the car at Karolinska Hospital in Stockholm and I swipe my credit card in the parking ticket dispenser and this is what comes out:

Now, seriously, if even the parking ticket dispenser calls you “leet”, how can you lose? It went beyond great, by the way. But I can’t figure out how the machine knew that in advance.

Is it nil or isn’t it?

October 4th, 2010

A bit of Objective-C weirdness I don’t quite get. The weirdness occurs if “view” in the code below is nil, that is if [idr getAsView:newFrame] returns nil. You’d expect the verticalOffset not to be incremented, but it is. Even though view is nil, view.frame.size.height still evaluates to “21″ (in this case) and verticalOffset gets incremented. (The first returned view was 21 high, the second returned view was nil in the debug run I’m referring to.)

- (UIView *)getAsView:(CGRect)theFrame {
	CGFloat verticalOffset = 0.0;
	CGRect hugeFrame = myCGRectHuge(theFrame);
	IDVBase *returnView = [[IDVBase alloc] initWithFrame:hugeFrame];
	hugeFrame = myCGRectResetToZero(hugeFrame);
	
	for (IDRBase *idr in self.parts.parts) {
		CGRect newFrame = myCGRectDown(hugeFrame, verticalOffset);
		UIView *view = [idr getAsView:newFrame];
		[returnView addSubview:view];
		verticalOffset += view.frame.size.height;
	}
	[returnView sizeToFit];
	return [returnView autorelease];
}

To avoid the unintended increment, I have to add the conditional if (view) {…} (which is a pretty good idea anyway, since it’s rather pointless, or maybe even bad, to add a nil as a subView):

- (UIView *)getAsView:(CGRect)theFrame {
	CGFloat verticalOffset = 0.0;
	CGRect hugeFrame = myCGRectHuge(theFrame);
	IDVBase *returnView = [[IDVBase alloc] initWithFrame:hugeFrame];
	hugeFrame = myCGRectResetToZero(hugeFrame);
	
	for (IDRBase *idr in self.parts.parts) {
		CGRect newFrame = myCGRectDown(hugeFrame, verticalOffset);
		UIView *view = [idr getAsView:newFrame];
		if (view) {
			[returnView addSubview:view];
			verticalOffset += view.frame.size.height;
		}
		[returnView addSubview:view];
		verticalOffset += view.frame.size.height;
	}
	[returnView sizeToFit];
	return [returnView autorelease];
}

I don’t know what the moral of this story is. I assume that if I should delve into the language reference, this will turn out to be undefined behaviour. Trying to figure out what could have been defined behaviour, I can’t come up with a reasonable answer, so I guess it’s just one of those things you should avoid doing. Maybe a compiler warning would have been nice, though.

An ode to Juniper

October 1st, 2010

I have a Juniper SSG-5 and the school I’m doing the network setup for also got one identical unit on my recommendation. I wanted to set up a fixed VPN between the two but failed miserably, so I logged a support request with Juniper on my machine, which is still in warranty but without any kind of support contract. Oh, boy, do these guys have great service.

After just a day I got an engineer connecting to my system with desktop sharing software and we together went through a number of different configurations. It wasn’t really trivial, since the first config took us nearly three hours. Then I had another question of how to implement more finegrained control over the firewall policies in one direction, but not the other, which had us online another two hours using desktop sharing. The final result was perfect and I’ve learned so much more about the details of autokey VPN tunnels.

I’m totally blown away by the level and quality of support I got for this issue from Juniper. Maybe this particular engineer was exceptionally good and persistent, but I have the impression that it is more of a rule with Juniper. When I bought the SSG-5 I thought it was a little expensive, but after this experience, I’ve totally changed my mind. The support level and quality makes it worth the price hands down.

No, I don’t have shares in Juniper, but after this experience I think I may get some.